Closed bcamper closed 4 years ago
It's possible the alpha
support for font
fill and stroke is overkill, though it led to me having some fun with fonts... :D
cc @matteblair @meetar @sensescape @burritojustice @nvkelso @tallytalwar for comment.
@bcamper Looks great from here! Couple of questions about the PR description:
In cases where a color value is required, the alpha parameter has no effect if no color is specified.
This is because nothing will draw, correct? So this line is clarifying that there won't be some kind of default color applied in order to apply an alpha to it.
If a sub-layer sets alpha: null, it un-sets any value set by an ancestor layer. The color's alpha channel returns to its original, unmodified value.
Are there cases where the "original unmodifed value" could be something other than 1.0?
@meetar:
In cases where a color value is required, the alpha parameter has no effect if no color is specified.
This is because nothing will draw, correct? So this line is clarifying that there won't be some kind of default color applied in order to apply an alpha to it.
Yep, that's right, feel free to help clarify the language if you have suggestions.
If a sub-layer sets alpha: null, it un-sets any value set by an ancestor layer. The color's alpha channel returns to its original, unmodified value.
Are there cases where the "original unmodifed value" could be something other than 1.0?
For sure! Any time color
sets an alpha already, like this:
depth1:
draw:
points:
color: [1, 0, 0, 0.25] # renders at 25% opacity
depth2:
draw:
points:
alpha: 0.5 # overrides color, renders at 50% opacity
depth3:
draw:
points:
alpha: null # back to the original 25% opacity
I should have put in an example where it is very explicitly overriding, even at one level, like:
draw:
points:
color: [1, 0, 0, 0.25]
alpha: 0.5 # overrides color, features will render w/50% opacity
Basically, whenever alpha
is present, it overrides the color
alpha. All the other behavior, including the alpha: null
"un-set", falls out of the regular draw
group and import
merging (because an explicitly set null
gets merged on top of others, like any other value).
Again, 👏 on the great description @bcamper. Sorry couldn't jump on this before. But looks good to me too.
This PR adds a new
alpha
parameter inside severaldraw
group contexts. It allows the scene author to set only the alpha channel of a color, independently of the RGB channels.Use cases where this is helpful include:
Syntax
draw
groups, where thealpha
parameter, if present, will override the alpha channel set by the corresponding color parameter:polygons
:color
lines
:color
outline
block):color
points
:color
outline
block):color
text
blocktext
font
block):fill
font.stroke
block):color
alpha
values can be set by:alpha: 0.5
alpha: [[14, 0.5], [16, 1]]
(fade in opacity from z14-16)alpha: function(){ return feature.height/200; }
(set building opacity by height)alpha
parameter has no effect if no color is specified. In cases where a default color applies, thealpha
parameter will modify the default color if no color is specified.The
alpha
parameter inherits through sub-layers like any otherdraw
parameter, and does not need to be defined at the same depth as acolor
it modifies; it will modify the nearest ancestor layer where color is defined.If a sub-layer sets
alpha: null
, it un-sets any value set by an ancestor layer. The color's alpha channel returns to its original, unmodified value.polygons
andlines
, alpha channel is only applicable for appropriateblend
modes (translucent
,overlay
, etc.), and is not intended to be used with the defaultopaque
blending.