-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add gradient support #71
Conversation
4d3262e
to
f4e970b
Compare
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.
[redacted]
55fc664
to
f1569cd
Compare
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.
I'm not gonna pretend to understand how any of this works, but the code organization looks good, and the gradient example looks just the same as before.
LGTM!
f1569cd
to
c0367a4
Compare
This has been rebased to resolve conflicts.
I'd be happy to walk through any of this, if it would be helpful! I think it could be explained easily. |
The model now supports having SVG gradients applied to individual chunks. A new `gradients` property has been added to the JSON model that contains a map of gradient IDs to definitions. A gradient is applied to a chunk by setting the optional chunk property `gradient` to a gradient ID. Both linear and radial gradients are supported, along with most SVG attributes. Any attribute with a limited set of options is validated to ensure it is set correctly, but the attributes that take lengths or colors simply ensure the value is a string (validating them property would be challenging). Validation has been added to throw an error if any unsupported attributes are present. The "gradient" demo has been updated to use this new gradient support. Now that example sets the gradient on each chunk rather than applying an overlay and masking it to match the model's shape. This greatly simplifies the example. Also the example-specific model files have been moved into the `example` directory. A new model was needed for the updated gradient example, and this seemed like a better place for it to go, so that the top-level of the repository doesn't get too cluttered.
Color and gradient are mutually exclusive options, so they should not both be set. An error is now thrown if both are set, so that there is no ambiguoity about how the polygon will be colored.
This attribute was supported by both types of gradient, but it was missing from the list of common attributes.
c0367a4
to
21f2416
Compare
Updated! I added JSDoc comments, and I added validation to ensure |
JSDoc comments have been added for the two functions that have been modified in this PR.
21f2416
to
0e3fb23
Compare
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.
LGTM!
The model now supports having SVG gradients applied to individual chunks. A new
gradients
property has been added to the JSON model that contains a map of gradient IDs to definitions. A gradient is applied to a chunk by setting the optional chunk propertygradient
to a gradient ID.Both linear and radial gradients are supported, along with most SVG attributes. Any attribute with a limited set of options is validated to ensure it is set correctly, but the attributes that take lengths or colors simply ensure the value is a string (validating them property would be challenging). Validation has been added to throw an error if any unsupported attributes are present.
The "gradient" demo has been updated to use this new gradient support. Now that example sets the gradient on each chunk rather than applying an overlay and masking it to match the model's shape. This greatly simplifies the example.
Also the example-specific model files have been moved into the
example
directory. A new model was needed for the updated gradient example, and this seemed like a better place for it to go, so that the top-level of the repository doesn't get too cluttered.