Skip to content

New addon: Shape operations in costume editor - #8129

Closed
CST1229 wants to merge 30 commits into
ScratchAddons:masterfrom
CST1229:paint-editor-shape-ops
Closed

New addon: Shape operations in costume editor#8129
CST1229 wants to merge 30 commits into
ScratchAddons:masterfrom
CST1229:paint-editor-shape-ops

Conversation

@CST1229

@CST1229 CST1229 commented Jan 31, 2025

Copy link
Copy Markdown
Member

Resolves #8052

Changes

Adds an addon for boolean shape operations in the costume editor. Mostly complete, aside from maybe behavior when undoing stuff and when dealing with more than 2 shapes (feedback is welcome!).

Reason for changes

It's a frequently requested feature that's common in vector image editors, and is in PenguinMod.

Tests

Tested on Firefox.

@CST1229 CST1229 added new addon Related to new addons to this extension. `scope: addon` should still be added. scope: addon Related to one or multiple addons labels Jan 31, 2025
@CST1229
CST1229 marked this pull request as ready for review February 1, 2025 09:25
@CST1229

CST1229 commented Feb 1, 2025

Copy link
Copy Markdown
Member Author

actually, changes are straight up not applying on the stage when i do boolean operations merging. will have to work on that

@CST1229
CST1229 marked this pull request as draft February 1, 2025 09:44
@CST1229
CST1229 marked this pull request as ready for review February 1, 2025 10:28
@WorldLanguages

Copy link
Copy Markdown
Member

actually, changes are straight up not applying on the stage when i do boolean operations merging. will have to work on that

So only the merging operation has problems as far as you know?

@WorldLanguages WorldLanguages added the type: enhancement New feature for the project label Feb 3, 2025
Comment thread addons/costume-editor-shape-ops/userscript.js Outdated

@Samq64 Samq64 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could the scratch-paint library be added to the addon.json?

Comment on lines +173 to +183
// kinda ugly solution to remove duplicate objects
/*for (const result of results) {
if (!result.parent) continue;
for (const result2 of results) {
if (!result2.parent) continue;
if (result === result2) continue;
if (result && result2 && result?.compare(result2)) {
result2.remove();
}
}
}*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a better solution for this now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i think it isn't needed anymore?

if (Array.isArray(item)) {
const newArray = [];
for (const child of item) {
newArray.push(...recursiveDecompose(child, dryRun));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can fail when one of the selected objects is grouped.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, forgot about grouping.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This function is supposed to ungroup all grouped objects, though that might not be what the user wants sometimes, and I might not be flattening the returned array correctly (in the bottom case).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function is supposed to ungroup all grouped objects, though that might not be what the user wants sometimes

I would think it's reasonable to ungroup them.
What do you mean by "the bottom case" though?

@CST1229

CST1229 commented Mar 1, 2025

Copy link
Copy Markdown
Member Author

Could the scratch-paint library be added to the addon.json?

paint-skew could also have scratch-paint added to its libraries in that case (iirc it copies a lot of ScaleTool's code)

@WorldLanguages

Copy link
Copy Markdown
Member

paint-skew could also have scratch-paint added to its libraries in that case

Sure, it can be added as part of this PR

@CST1229

CST1229 commented Mar 2, 2025

Copy link
Copy Markdown
Member Author

there's also the issue of handling items with the different properties (like color) when merging in some ways (like masking)

@WorldLanguages

Copy link
Copy Markdown
Member

there's also the issue of handling items with the different properties (like color) when merging in some ways (like masking)

By this do you mean, the issue of deciding how it should behave in those cases?

@CST1229

CST1229 commented Mar 6, 2025

Copy link
Copy Markdown
Member Author

there's also the issue of handling items with the different properties (like color) when merging in some ways (like masking)

By this do you mean, the issue of deciding how it should behave in those cases?

By this i mean just implementing support for it in general. (for example, having several shapes with different properties and then subtracting one shape from them. IIRC this will cause all the other shapes to have their properties changed to one of them)

@Joeclinton1

Copy link
Copy Markdown
Member

Is this still in development?

@CST1229

CST1229 commented Sep 7, 2025

Copy link
Copy Markdown
Member Author

Is this still in development?

ummmm no

@Joeclinton1

Joeclinton1 commented Sep 7, 2025

Copy link
Copy Markdown
Member

Is this still in development?

ummmm no

You should probably close it then, if it's abandoned. Or do you mean it's done?

@CST1229

CST1229 commented Sep 7, 2025

Copy link
Copy Markdown
Member Author

abandoned (i just don't feel like fixing the remaining bugs)

@CST1229 CST1229 closed this Sep 7, 2025
@Joeclinton1

Copy link
Copy Markdown
Member

abandoned (i just don't feel like fixing the remaining bugs)

I thought it was mostly done though :(

@CubesterYT

Copy link
Copy Markdown

It would be great if someone finished this

@Joeclinton1

Copy link
Copy Markdown
Member

It would be great if someone finished this

What was left? If you could just write it out I could finish it.

@WorldLanguages WorldLanguages reopened this Sep 7, 2025
@WorldLanguages

Copy link
Copy Markdown
Member

@CST1229 Feel free to mute notifications, but I think it's better if we keep it open, since it's almost working.

@CST1229

CST1229 commented Sep 7, 2025

Copy link
Copy Markdown
Member Author

It would be great if someone finished this

What was left? If you could just write it out I could finish it.

mainly just this

there's also the issue of handling items with the different properties (like color) when merging in some ways (like masking)
By this i mean just implementing support for it in general. (for example, having several shapes with different properties and then subtracting one shape from them. IIRC this will cause all the other shapes to have their properties changed to one of them)

and testing to ensure it's stable with different types of objects and outlines and stuff (i think it should just ignore non-shapes like text and bitmap images, not sure if it currently does?)

@DNin01

DNin01 commented Sep 7, 2025

Copy link
Copy Markdown
Member

there's also the issue of handling items with the different properties (like color) when merging in some ways (like masking) By this i mean just implementing support for it in general. (for example, having several shapes with different properties and then subtracting one shape from them. IIRC this will cause all the other shapes to have their properties changed to one of them)

There's only so much you can do about that, but these are some simple ways to intuitively merge properties:

  • The shape with the largest area "wins", in that its fill and outline color will apply to the resulting shape.
  • The properties of the shape in the back layer or the shape that is being cut out will apply to the resulting shape.
  • The properties of the first shape that is not black, white, or transparent will apply to the resulting shape.

Also, if some shapes are completely transparent, like if two shapes are being combined and one of them only has a fill and the other only has an outline, their properties could be combined.

@TSFBCE24RhythmHeaveners

Copy link
Copy Markdown

I tried it too 😃

@Samq64

Samq64 commented Jul 25, 2026

Copy link
Copy Markdown
Member

@CST1229 Should this be closed in favour of #8917?

@Samq64 Samq64 added the status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. label Jul 25, 2026
@CST1229

CST1229 commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

probs

@CST1229 CST1229 closed this Jul 25, 2026
@Samq64 Samq64 removed the status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. label Jul 25, 2026
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. scope: addon Related to one or multiple addons type: enhancement New feature for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combine shapes in costume editor

8 participants