Skip to content

Feature/paint stroke options - #8914

Open
griffpatch wants to merge 11 commits into
ScratchAddons:masterfrom
griffpatch:feature/paint-stroke-options
Open

Feature/paint stroke options#8914
griffpatch wants to merge 11 commits into
ScratchAddons:masterfrom
griffpatch:feature/paint-stroke-options

Conversation

@griffpatch

Copy link
Copy Markdown
Contributor

Changes

Adds a new addon paint-stroke-options that injects stroke join and cap controls into the outline colour picker in the vector costume editor.

Corner: Miter or Round stroke join
Cap: Butt, Round, or Square stroke cap
Controls appear at the bottom of the stroke colour popup, match the Scratch colour picker visual style, and highlight the currently active option. Changes are applied to all selected items and trigger an undo snapshot.

image

Reason for changes

Paper.js exposes strokeJoin and strokeCap on path items but Scratch's paint editor provides no UI to change them. This addon fills that gap for users who want more control over how strokes render on vector shapes, particularly useful for custom block designs and illustrations.

Tests

Tested in Chrome 146. Verified:

Controls appear only in the stroke (Outline) popup, not the fill popup
Clicking each option applies immediately to selected items
Active option is highlighted correctly
Undo works after applying a change
Addon enable/disable works without page reload

@CST1229

CST1229 commented Mar 27, 2026

Copy link
Copy Markdown
Member

Paper.js exposes strokeJoin and strokeCap on path items but Scratch's paint editor provides no UI to change them

*except for the line tool being able to change caps to round if you connect a line to an existing shape (e.g a rectangle with a part erased, which uses a butt cap)

@griffpatch
griffpatch force-pushed the feature/paint-stroke-options branch from be20305 to 154c795 Compare March 27, 2026 15:46
@Samq64 Samq64 added type: enhancement New feature for the project new addon Related to new addons to this extension. `scope: addon` should still be added. labels Mar 28, 2026
@DNin01 DNin01 added this to the v1.46.0 milestone Mar 28, 2026
@griffpatch

Copy link
Copy Markdown
Contributor Author

Paper.js exposes strokeJoin and strokeCap on path items but Scratch's paint editor provides no UI to change them

*except for the line tool being able to change caps to round if you connect a line to an existing shape (e.g a rectangle with a part erased, which uses a butt cap)

Quite so, an slightly inexplicably so :)

@pufferfish101007
pufferfish101007 self-requested a review June 28, 2026 20:38
Comment thread addons/paint-stroke-options/userscript.js
Comment thread addons/paint-stroke-options/userscript.js Outdated

@pufferfish101007 pufferfish101007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work well with its intended use cases.

However, I would expect to be able to select the stroke options before drawing a shape (for instance while I have the rectangle or line tool selected, I might change the stroke colour before drawing, and would expect the visible stroke buttons to be useable).

Dark mode styling probably needs a bit of work - the text contrast is quite low and the buttons don't really match up with other buttons around them:
image.png

Looks good in light mode though.

Only a couple of very minor code comments and otherwise l;ooks great.

Comment thread addons/paint-stroke-options/addon.json Outdated
@griffpatch
griffpatch force-pushed the feature/paint-stroke-options branch from e1e5a81 to 421dac9 Compare July 3, 2026 08:15
@griffpatch

Copy link
Copy Markdown
Contributor Author

I would expect to be able to select the stroke options before drawing a shape (for instance while I have the rectangle or line tool selected, I might change the stroke colour before drawing, and would expect the visible stroke buttons to be useable).

Yeah, I didn't want to overcomplicate this PR - but you are right - I've added support for this now too, but it will need some good testing! :)

@sad-birds

Copy link
Copy Markdown

This is cool! Would it make sense to also add UI for dashed lines? https://paperjs.org/reference/style/#dasharray

@DNin01 DNin01 removed this from the v1.46.0 milestone Jul 25, 2026
@pufferfish101007

Copy link
Copy Markdown
Contributor

The new changes seem to work great, thank you!

I've tested this out with the new round corners addon and it seems to work well which is good.

Minor problems with compat with the boolean shape operations addon - which could perhaps be fixed in a followup PR? - are that combine & expand cause round joins to become mitered.

Also re. name and description - could 'stroke' maybe be replaced with 'outline' if that is correct? That is probably more accessible to most scratchers. 'Corner' and 'end' might be more understandable that 'join' and 'cap', but again not sure if they're actually the same thing. Also a note explaining what a miter would probably be useful.

@griffpatch

Copy link
Copy Markdown
Contributor Author

Thanks for testing this and for the wording suggestions! I've updated the addon to use Scratch-facing terms. It's now called "Outline corners and ends", and the visible headings are "Corner" and "End". The icon tooltips explain the technical terms, including "Sharp corner (miter)" and "Flat end (butt)".

I agree the boolean shape operations issue is best handled in a follow-up PR. Those operations create replacement paths, so they should preserve the original outline's corner and end styles when doing so.

@mxmou

mxmou commented Aug 4, 2026

Copy link
Copy Markdown
Member

I have a very minor design suggestion: the added buttons might look better with no gap between them.

image

This would make them more similar to other button groups in Scratch, such as the zoom buttons in the paint editor and the stage size buttons in the stage header.

@griffpatch

Copy link
Copy Markdown
Contributor Author

I have a very minor design suggestion: the added buttons might look better with no gap between them.

image This would make them more similar to other button groups in Scratch, such as the zoom buttons in the paint editor and the stage size buttons in the stage header.

As you wish!

@griffpatch

griffpatch commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Minor problems with compat with the boolean shape operations addon - which could perhaps be fixed in a followup PR? - are that combine & expand cause round joins to become mitered.

@pufferfish101007 - Talking of follow up PR for the shaping tool - did you want one for inclusion in this coming release if it's small or a followup release - I can look into fixing it sooner than later if that's what you meant :)

In case you want it - here it is: #9149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new addon Related to new addons to this extension. `scope: addon` should still be added. type: enhancement New feature for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants