-
Notifications
You must be signed in to change notification settings - Fork 38
Support color operation functions #38
Comments
Syntax idea. I assume we need to support multiple operations. {
"text-color": {
"value": "#0000FF",
"operation": [["lighten", 10], ["spin", 35]]
},
"text-halo-color": {
"value": "white",
"operation": ["mix", "#FFCCFF", 50]
}
} |
@nickidlugash What's your current sense on the importance of this feature? |
@jfirebaugh My current sense is that it is still very important to be able to transform colors (specifically color constants), but I don't have a strong feeling as to whether it's better to implement this in the style spec or only in the editor. @edenh @tmcw @lbud ? |
If I recall correctly trying to implement this in the editor was a beast (in that compiling and decompiling transforms written into a style in the editor would never really work). I would think having these in the spec would be a much cleaner option… |
@jfirebaugh @tmcw @edenh thoughts? |
👍 what @lbud said. |
Per chat with @nickidlugash we're comfortable going with the syntax @edenh suggested above with the exception of "mix", which we're leaning toward doing as follows: "text-halo-color": {
"value": ["white", "#FFCCFF"],
"operation": [["mix", 50]]
} so as to accommodate the idea that edit: we'll also be enforcing always using an array of arrays for |
One important feature that the syntax should support is composition of operations. For example, think about how you would express a composed operations like |
@jfirebaugh interesting. If we want to support that my inclination would just be to nest as much as desired, right? Like "text-halo-color": {
"value": {
"value": ["red", "green"],
"operation": ["mix", 50]
},
"operation": ["lighten", 20]
} — so we'd drop the concept of arrays of arrays of operations, as they could all be expressed like this. It's a little less nice but I guess it's the only way to represent |
(similarly:) "text-halo-color": {
"value": [{
"value": "red",
"operation": ["lighten", 20]
}, "green"],
"operation": ["mix", 50]
} |
I'm wondering if we need named properties versus a more compact array-based syntax:
|
I like the array syntax. We also want to be consistent with other nested constructs like filters. |
Cool — going down that (array) path now. |
Just wondering — would it be better to have the syntax "text-halo-color": ["lighten", ["mix", "red", "green", 50], 20]
"text-halo-color": ["mix", ["lighten", "red", 20], "green", 50] |
@mourner hm...since |
Status on this implementation: #264 (comment) means some refactors to -spec (#271), -gl-js (mapbox/mapbox-gl-js#1111), -native (https://github.com/mapbox/mapbox-gl-native/tree/color_operations), and mapbox-gl-color-operations (https://github.com/mapbox/mapbox-gl-color-operations). Other than that, this is mostly close:
|
So this is in v8 and implemented. Is it actually going to be used? How will the app expose this? Is it still valuable in a constantless world? |
Can we support color operation functions similar to the LESS-type color functions supported in cartoCSS?
E.g.
lighten(constant, %)
darken(constant, %)
desaturate(constant, %)
spin(constant, %)
mix(constant1, constant2, %)
fadeout(constant, %)
fadein(constant, %)
These are useful when you want colors to maintain a relationship with another color – e.g., landuse or text halo colors to the land color.
The text was updated successfully, but these errors were encountered: