-
Notifications
You must be signed in to change notification settings - Fork 232
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
Boolean operations #1341
Boolean operations #1341
Conversation
Okay, after finding I will soon add an Icon and the index entries, and it should be ready. |
I think the script should be ready now. |
I updated the script with a check for supported types and limited the selection to those only. if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.9.20")) {
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
return;
}
const ShadowGroupMarker = "ShadowCloneOf-";
const elements = ea.getViewSelectedElements().filter(el=>["ellipse", "rectangle", "diamond"].indludes(el.type) || element.groupIds.some(id => id.startsWith(ShadowGroupMarker)));
if(elements.length === 0) {
new Notice ("Select ellipses, rectangles or diamonds");
return;
}
const PolyBool = ea.getPolyBool();
const polyboolAction = await utils.suggester(["union (a + b)", "intersect (a && b)", "diffrence (a - b)", "reversed diffrence (b - a)", "xor"], [
PolyBool.union, PolyBool.intersect, PolyBool.difference, PolyBool.differenceRev, PolyBool.xor
], "What would you like todo with the object");
const shadowClones = elements.filter(element => element.groupIds.some(id => id.startsWith(ShadowGroupMarker))); |
@zsviczian Thank you for merging! |
In that case, I will modify the filter to include sharp lines and arrows as well. |
Hello,
This is what the title says, an ea script to make boolean operations on shapes.
But it is still kind of janky right now. But I've got some problems/questions that I want to ask.
So first of all: I tried using the package polybooljs, but when building I got an error with the colormaster package (see error message below, maybe you have an Idea why it didn't work?). I implemented bolybooljs in the pullrequest how I think it would be done, but couldn't test if it works.
So to still be able to write and test the script, I simply copied the single build file from bolybool into the script. So the script actually works in the current version of excalidraw, but it's kind of bodged together right now.
But if the polybool would be implemented in the excalidraw automate api I can change it, so it uses the api properly.
Then I wanted to ask if it's okay that I assign a custom property to some of the object that my script makes. I added the
isShadowCloneOf
property, which marks any shadow clone and stores the ID of the element it is the shadow clone of. I need a shadow clone in the script in case you want to cut a hole into another element, and being able to quickly filter out shadow clones and find out which object they belong to is super useful.Lastly I was wondering, if you have an Idea how the curve of curvy lines is calculated or maybe if there is some function in the excalidraw api that could be ported to Excalidraw automate, that would help with that. Because right now, curvy lines would be handled like regular lines with sharp edges.