-
Couldn't load subscription status.
- Fork 262
Implement gradient outlines #1004
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
Implement gradient outlines #1004
Conversation
|
This is awesome! |
8aaf088 to
45a8b22
Compare
b0f73cf to
f431b2e
Compare
src/reducers/fill-color-2.js
Outdated
| return state; | ||
| // Gradient type may be solid when multiple gradient types are selected. | ||
| // In this case, changing the first color should not change the second color. | ||
| if (colors.gradientType !== GradientTypes.SOLID || colors.fillColor2 === MIXED) { |
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 think we figured out that the getColorsFromSelection function returns GradientType = SOLID, fill colors 1 and 2 = MIXED to indicate that the gradient type isn't actually solid, you've selected a bunch of things with different gradient types. (Just clarifying this for myself)
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.
Let's separate everything up to e89bed9 as a "refactor" pr
(caveat: we need to have getColorsFromSelection return mixed for all stroke gradients until the rest is hooked in)
Now, you can pass null in for a color instead of
{primary: null, secondary: null, gradientType: GradientTypes.SOLID}
and it'll still clear the color. Passing strokeWidth is also
optional now.
This *should* be safe because OvalTool and RectTool's wrapper "mode" components, the only places that call onSelectionChanged, also update the tools' color, and the color state reducers will always set the color every time the selection changes, meaning it'll be updated anyway.
This means that gradient tools will also be enabled for the stroke color indicator even in fill and bitmap modes, but that's okay because the stroke color indicator will be disabled or hidden in those modes anyway.
Hopefully the comments help; the logic is kinda convoluted here
This fixes the bug where percertly horizontal gradients on perfectly vertical lines and vice versa would not be rendered at all
The UX here isn't the best thing in the world but I think having the functionality is important judging from the playtest
Previously, if you selected a shape with a gradient outline that had a width of 0, its outline color wouldn't be null when it should have been.
- Set the stroke color to "null" when the width is set to 0 - Properly set the stroke color state when the width is increased from 0
5e5890d to
cca0832
Compare
|
@fsih The latest 4 commits are new, and should fix issues relating to changing the outline width to 0. Did you run into "something strange" in a local build or my build? It looks like you ran into the bug that scratchfoundation/paper.js#40 fixes, so you may need to |
|
@adroitwhiz Yup, it was a local build. You're right, that's probably what it was! |
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.
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.
ignore this comment
ede67d9 to
272a10c
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.
Good catches

Depends on scratchfoundation/paper.js#39, scratchfoundation/paper.js#40, #1166
Resolves
Resolves #540
Diff: https://github.com/adroitwhiz/scratch-paint/compare/stroke-gradient-part-1...adroitwhiz:stroke-gradient?expand=1
Proposed Changes
This PR adds support for (and contains a bunch of supporting changes for) setting outlines' colors to gradients in select mode, fill mode, and shape tools:

The supporting changes include:
style-path.jsto work on both fill and stroke.FillColorPickerComponentandStrokeColorPickerComponentinto aColorPickerComponent.FillColorPickerandStrokeColorPickercontainers into aColorPickercontainer component generator.It deliberately does not yet add support for gradient strokes in fill mode-- there's some behavior there that would best be ironed out at some point in the future.Per design meeting we agreed to include gradient outlines in select mode, gradients in shape tools, and gradient outlines in the fill tool in one release
Reason for Changes
This has been a commonly-requested feature ever since 3.0 was first released to the public.
The supporting changes should also make it easier to implement things like #1003.
Test Coverage
Existing fill/outline color reducer tests have been merged together into one big color reducer test