-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functions for pattern properties #976
Conversation
return type === 'color' ? parseColor(value) : | ||
type === 'number' ? parseNumber(value) : | ||
type === 'boolean' ? Boolean(value) : | ||
type === 'image' ? String(value) : | ||
type === 'string' && (prop === 'fill-image' || prop === 'line-image' || prop === 'background-image') ? parsePattern(value) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this in a way that's not hard-coded to particular property names? Either support non-interpolated functions for all properties, or look to the style spec to tell whether functions are supported for a particular property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is one of the todo's. I was thinking that would need to create a separate type to handle these, but now that we have layout property functions I think I can implement them for the other string properties.
return type === 'color' ? parseColor(value) : | ||
type === 'number' ? parseNumber(value) : | ||
type === 'boolean' ? Boolean(value) : | ||
type === 'image' ? String(value) : | ||
type === 'string' ? String(value) : | ||
type === 'string' ? parsePattern(value) : | ||
type === 'array' && prop === 'line-dasharray' ? parsePattern(value) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jfirebaugh I added functions for all the other string properties, but I think we'll need to make dasharrays a different type than other number arrays. Other number arrays would use interpolated stops functions instead of faded stops functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should distinguish them in the style spec. "function": "interpolated"
vs "function": "piecewise-constant"
or something.
Is there any reason not to support non-interpolated functions for every remaining property (i.e. enums and booleans too)? |
Nope. Everything can be a function. How about this: There are two types of functions:
Colors, numbers, arrays and paint string properties can all be either Non-default types can be specified like this:
How would this look in the spec? |
Is is necessary / useful to give style authors a choice between interpolated and piecewise for properties that could support both? I'd rather just spec that each property is one or the other. |
Probably not that useful. I'll just stick to one. thanks |
There are now three types of functions:
By default everything is a @jfirebaugh how does this seem? |
The spec uses Relatedly, instead of:
it should be like other transitionable properties:
|
I avoided this approach earlier because I thought it would be weird that |
Interesting point. I think that *-transition should affect between-class transitions though. Like if you switched between night and day classes and both had function-valued fill-image properties, it would ideally fade between the two, right? |
Yes, it could affect both. I'm not sure that if you change the duration for one you'll want the duration for the other to be the same, but maybe changing either is rare enough that it doesn't matter. I'll make the change. If it's actually a problem we can change it later. |
This should now be all implemented. Everything is a function. By default properties are Transitions are set using |
There are a number of failures in the test-suite:
|
The implementation now wants
instead of
This was briefly discussed at mapbox/mapbox-gl-style-spec#237 (comment) but wasn't decisively decided. Should I work on migrations, or switch the implementation back? |
Implemented in -native in mapbox/mapbox-gl-native#821 I think this is ready now |
74253d6
to
ba3899f
Compare
This implements functions for line, fill and background patterns. They look like this:
Duration is optional.
todo: