CityScope / CS_Brix

A python library for CityScope modules which handles communication with City I/O
GNU General Public License v3.0
5 stars 3 forks source link

Opacity not supported by brix #33

Closed guadalupebabio closed 3 years ago

guadalupebabio commented 3 years ago

I'm working with a table that has types defined as transparent. Since brix takes the color from GEOGRID/properties/types this means I cannot update any transparent types.

Could we use 8-digit hex codes (that include transparency) in the types definitions?

Alternatively, can we add a parameter to Handler.reset_geogrid_data to prevent brix from overriding the colors set in GEOGRID/features?

RELNO commented 3 years ago

@guadalupebabio I did a couple of tests, and from the Editor/CSjs point of view, there's no simple way now to include transparent colors. The reason is that the editor is using hex color that are later converted to [r,g,b,a] array, so that deckgl could read them. problem is that hex ->rgba conversion is not super straight forward without type checking. Therefore my suggestion to you is to create a placeholder color (say full red) and later edit the json by replacing all 'reds' with [0,0,0,0]

crisjf commented 3 years ago

That's a good suggestion @RELNO. Since @guadalupebabio is only using transparency for the non-interactive cells, the solution for now is to make sure that when she resets GEOGRIDDATA from brix, brix uses the colors defined in GEOGRID/features instead of getting all smart and trying to set the colors to the ones defined in GEOGRID/properties/types.

crisjf commented 3 years ago

@guadalupebabio, your table seems to be working now. I ran:

from brix import Handler
Handler('lomas').reset_geogrid_data()

image

crisjf commented 3 years ago

@RELNO random thought: Could we add opacity as a feature to each type?

For example:

Water_WarkaTower: {
  LBCS: [
    {
      proportion: 1,
      use: {
        5210: 1
      }
    }
  ],
  NAICS: null,
  color: "#2f395a",
  opacity: 1,
  height: 0,
  interactive: "Web",
  name: "Water_WarkaTower",
  tableData: {
    id: 4
  }
}
RELNO commented 3 years ago

We can, but a simpler way would be to either input RGBA vals, or allow hex transparency (more complex to type check tho https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4). In both cases, it's a matter of convention across the apps.

crisjf commented 3 years ago

This seems to be working now.

The solution was the following: Whenever a new geogrid_data is trying to be pushed that has a transparency value for the color (e.g. [0,0,1,0]), brix remaps the first three numbers to the color defined in GEOGRID/properties/types and keeps the transparency. This means that if a user defines the color with transparency in GEOGRID/features, those transparency values are used by Handler.reset_geogrid_data(), but the colors still come from the type definition.