Skip to content

Commit 2070099

Browse files
committed
Add Shape to clip (clipboard)
1 parent d6fd9ee commit 2070099

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

macros/ILL.Shapery.moon

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export script_name = "Shapery"
22
export script_description = "Does several types of shape manipulations from the simplest to the most complex"
3-
export script_version = "2.5.6"
3+
export script_version = "2.5.7"
44
export script_author = "ILLTeam"
55
export script_namespace = "ILL.Shapery"
66

@@ -32,6 +32,8 @@ else
3232
ILL = require "ILL.ILL"
3333
{:Aegi, :Ass, :Config, :Line, :Curve, :Path, :Point, :Util, :Math, :Table, :Util} = ILL
3434

35+
clipboard = require "aegisub.clipboard"
36+
3537
checkPathClockWise = (path) ->
3638
sum = 0
3739
for i = 1, #path
@@ -44,10 +46,10 @@ interfaces = {
4446
config: -> {
4547
{class: "label", label: "Expand", x: 0, y: 0}
4648
{class: "floatedit", x: 0, y: 1, name: "cutBordShadow", min: 0.1, max: 2, step: 0.1, value: 1}
47-
{class: "checkbox", label: "Cut", x: 0, y: 2, name: "expandBordShadow", value: false}
49+
{class: "checkbox", label: "Shape Expand Outline", x: 0, y: 2, name: "expandBordShadow", value: false}
50+
{class: "checkbox", label: "Comment Current Lines", x: 0, y: 3, name: "saveLines", value: false}
4851
{class: "label", label: "Reset Macro", x: 0, y: 5}
49-
{class: "dropdown", items: {"All", "Config", "Pathfinder", "Offsetting", "Manipulate", "Transform", "Utilities"}, x: 5, y: 5, name: "reset", value: "All"}
50-
{class: "checkbox", label: "Save lines", x: 5, y: 0, name: "saveLines", value: false}
52+
{class: "dropdown", items: {"All", "Config", "Pathfinder", "Offsetting", "Manipulate", "Transform", "Utilities"}, x: 0, y: 6, name: "reset", value: "All"}
5153
}
5254
pathfinder: -> {
5355
{class: "label", label: "Operation:", x: 0, y: 0}
@@ -464,7 +466,7 @@ ShaperyMacrosDialog = (macro) ->
464466
ass\insertLine line, s
465467
else
466468
ass\warning s, "Expected \\clip or \\iclip tag"
467-
when "Shape to clip"
469+
when "Shape to clip", "Shape to clip (clipboard)"
468470
clip = {}
469471
Line.callBackExpand ass, l, nil, (line) ->
470472
{px, py} = line.data.pos
@@ -476,7 +478,10 @@ ShaperyMacrosDialog = (macro) ->
476478
l.tags\insert {{"clip", clip}}
477479
unless l.isShape
478480
l.text\modifyBlock l.tags
479-
ass\setLine l, s
481+
if macro == "Shape to clip (clipboard)"
482+
clipboard.set "\\clip(#{clip})"
483+
else
484+
ass\setLine l, s
480485
when "Clip to shape"
481486
{:an, :pos, :clip} = l.data
482487
if clip
@@ -629,18 +634,19 @@ if haveDepCtrl
629634
}
630635

631636
depctrl\registerMacros {
632-
{"Shape expand", "", ShaperyMacrosDialog "Shape expand"}
633-
{"Shape clipper", "", ShaperyMacrosDialog "Shape clipper"}
634-
{"Clip to shape", "", ShaperyMacrosDialog "Clip to shape"}
635-
{"Shape to clip", "", ShaperyMacrosDialog "Shape to clip"}
636-
{"Shape merge", "", ShaperyMacrosDialog "Shape merge"}
637-
{"Shape trim", "", ShaperyMacrosDialog "Shape trim"}
638-
{"Shape to 0,0", "", ShaperyMacrosDialog "Shape to 0,0"}
639-
{"Shape to pos", "", ShaperyMacrosDialog "Shape to pos"}
640-
{"Shape to origin", "", ShaperyMacrosDialog "Shape to origin"}
641-
{"Shape to center", "", ShaperyMacrosDialog "Shape to center"}
642-
{"Shape without holes", "", ShaperyMacrosDialog "Shape without holes"}
643-
{"Shape bounding box", "", ShaperyMacrosDialog "Shape bounding box"}
637+
{"Shape expand", "", ShaperyMacrosDialog "Shape expand"}
638+
{"Shape clipper", "", ShaperyMacrosDialog "Shape clipper"}
639+
{"Clip to shape", "", ShaperyMacrosDialog "Clip to shape"}
640+
{"Shape to clip", "", ShaperyMacrosDialog "Shape to clip"}
641+
{"Shape to clip (clipboard)", "", ShaperyMacrosDialog "Shape to clip (clipboard)"}
642+
{"Shape merge", "", ShaperyMacrosDialog "Shape merge"}
643+
{"Shape trim", "", ShaperyMacrosDialog "Shape trim"}
644+
{"Shape to 0,0", "", ShaperyMacrosDialog "Shape to 0,0"}
645+
{"Shape to pos", "", ShaperyMacrosDialog "Shape to pos"}
646+
{"Shape to origin", "", ShaperyMacrosDialog "Shape to origin"}
647+
{"Shape to center", "", ShaperyMacrosDialog "Shape to center"}
648+
{"Shape without holes", "", ShaperyMacrosDialog "Shape without holes"}
649+
{"Shape bounding box", "", ShaperyMacrosDialog "Shape bounding box"}
644650
}, ": Shapery macros :"
645651
else
646652
aegisub.register_macro "#{script_name}/Pathfinder", "", PathfinderDialog
@@ -651,15 +657,16 @@ else
651657
aegisub.register_macro "#{script_name}/Cut Contour", "", CutContourDialog
652658
aegisub.register_macro "#{script_name}/Config", "", ConfigDialog
653659

654-
aegisub.register_macro ": Shapery macros :/Shape expand", "", ShaperyMacrosDialog "Shape expand"
655-
aegisub.register_macro ": Shapery macros :/Shape clipper", "", ShaperyMacrosDialog "Shape clipper"
656-
aegisub.register_macro ": Shapery macros :/Clip to shape", "", ShaperyMacrosDialog "Clip to shape"
657-
aegisub.register_macro ": Shapery macros :/Shape to clip", "", ShaperyMacrosDialog "Shape to clip"
658-
aegisub.register_macro ": Shapery macros :/Shape merge", "", ShaperyMacrosDialog "Shape merge"
659-
aegisub.register_macro ": Shapery macros :/Shape trim", "", ShaperyMacrosDialog "Shape trim"
660-
aegisub.register_macro ": Shapery macros :/Shape to 0,0", "", ShaperyMacrosDialog "Shape to 0,0"
661-
aegisub.register_macro ": Shapery macros :/Shape to pos", "", ShaperyMacrosDialog "Shape to pos"
662-
aegisub.register_macro ": Shapery macros :/Shape to origin", "", ShaperyMacrosDialog "Shape to origin"
663-
aegisub.register_macro ": Shapery macros :/Shape to center", "", ShaperyMacrosDialog "Shape to center"
664-
aegisub.register_macro ": Shapery macros :/Shape without holes", "", ShaperyMacrosDialog "Shape without holes"
665-
aegisub.register_macro ": Shapery macros :/Shape bounding box", "", ShaperyMacrosDialog "Shape bounding box"
660+
aegisub.register_macro ": Shapery macros :/Shape expand", "", ShaperyMacrosDialog "Shape expand"
661+
aegisub.register_macro ": Shapery macros :/Shape clipper", "", ShaperyMacrosDialog "Shape clipper"
662+
aegisub.register_macro ": Shapery macros :/Clip to shape", "", ShaperyMacrosDialog "Clip to shape"
663+
aegisub.register_macro ": Shapery macros :/Shape to clip", "", ShaperyMacrosDialog "Shape to clip"
664+
aegisub.register_macro ": Shapery macros :/Shape to clip (clipboard)", "", ShaperyMacrosDialog "Shape to clip (clipboard)"
665+
aegisub.register_macro ": Shapery macros :/Shape merge", "", ShaperyMacrosDialog "Shape merge"
666+
aegisub.register_macro ": Shapery macros :/Shape trim", "", ShaperyMacrosDialog "Shape trim"
667+
aegisub.register_macro ": Shapery macros :/Shape to 0,0", "", ShaperyMacrosDialog "Shape to 0,0"
668+
aegisub.register_macro ": Shapery macros :/Shape to pos", "", ShaperyMacrosDialog "Shape to pos"
669+
aegisub.register_macro ": Shapery macros :/Shape to origin", "", ShaperyMacrosDialog "Shape to origin"
670+
aegisub.register_macro ": Shapery macros :/Shape to center", "", ShaperyMacrosDialog "Shape to center"
671+
aegisub.register_macro ": Shapery macros :/Shape without holes", "", ShaperyMacrosDialog "Shape without holes"
672+
aegisub.register_macro ": Shapery macros :/Shape bounding box", "", ShaperyMacrosDialog "Shape bounding box"

0 commit comments

Comments
 (0)