11export script_name = " Shapery"
22export script_description = " Does several types of shape manipulations from the simplest to the most complex"
3- export script_version = " 2.6.1 "
3+ export script_version = " 2.6.2 "
44export script_author = " ILLTeam"
55export script_namespace = " ILL.Shapery"
66
77haveDepCtrl, DependencyControl = pcall require , " l0.DependencyControl"
88
9- local depctrl, Clipper , ILL
9+ local depctrl, ILL
1010if haveDepCtrl
1111 depctrl = DependencyControl {
1212 feed : " https://github.com/TypesettingTools/ILL-Aegisub-Scripts/main/DependencyControl.json" ,
1313 {
14- {
15- " clipper2.clipper2"
16- version : " 1.3.2"
17- url : " https://github.com/TypesettingTools/ILL-Aegisub-Scripts/"
18- feed : " https://github.com/TypesettingTools/ILL-Aegisub-Scripts/main/DependencyControl.json"
19- }
2014 {
2115 " ILL.ILL"
22- version : " 1.6.5 "
16+ version : " 1.8.0 "
2317 url : " https://github.com/TypesettingTools/ILL-Aegisub-Scripts/"
2418 feed : " https://github.com/TypesettingTools/ILL-Aegisub-Scripts/main/DependencyControl.json"
2519 }
2620 }
2721 }
28- Clipper , ILL = depctrl\ requireModules!
22+ ILL = depctrl\ requireModules!
2923else
30- Clipper = require " clipper2.clipper2"
3124 ILL = require " ILL.ILL"
3225
3326{ : Aegi , : Ass , : Config , : Line , : Curve , : Path , : Point , : Util , : Math , : Table , : Util } = ILL
3427clipboard = require " aegisub.clipboard"
3528
36- checkPathClockWise = ( path) ->
37- sum = 0
38- for i = 1 , # path
39- currPoint = path[ i]
40- nextPoint = path[ ( i % # path) + 1 ]
41- sum += ( nextPoint. x - currPoint. x) * ( nextPoint. y + currPoint. y)
42- return sum < 0
43-
4429interfaces = {
4530 config : -> {
4631 { class : " label" , label : " Expand" , x : 0 , y : 0 }
@@ -61,7 +46,6 @@ interfaces = {
6146 offsetting : -> {
6247 { class : " label" , label : " Stroke Weight" , x : 0 , y : 0 }
6348 { class : " floatedit" , x : 1 , y : 0 , name : " strokeWeight" , value : 0 }
64- { class : " checkbox" , x : 1 , y : 1 , name : " cut" , value : false }
6549 { class : " label" , label : " Corner Style" , x : 0 , y : 2 }
6650 { class : " dropdown" , items : { " Miter" , " Round" , " Square" } , x : 1 , y : 2 , name : " cornerStyle" , value : " Round" }
6751 { class : " label" , label : " Align Stroke" , x : 0 , y : 3 }
@@ -197,26 +181,39 @@ OffsettingDialog = (sub, sel, activeLine) ->
197181 if button != " Cancel"
198182 cfg = getConfigElements!
199183 ass = Ass sub, sel, activeLine, not cfg. saveLines
200- { : strokeWeight, : strokeAlign, : cornerStyle, : miterLimit, : arcPrecision, : cut } = elements
184+ { : strokeWeight, : strokeAlign, : cornerStyle, : miterLimit, : arcPrecision} = elements
201185 if strokeWeight < 0
202186 strokeAlign = " Inside"
203187 cornerStyle = cornerStyle\ lower!
204- cutsOutside = cut and strokeAlign == " Outside"
205188 for l, s, i, n in ass\ iterSel!
206189 ass\ progressLine s, i, n
207190 ass\ removeLine l, s
208191 Line . extend ass, l
209192 Line . callBackExpand ass, l, nil , ( line) ->
210- path, clip = Path line. shape
211- if cutsOutside
212- clip = path\ clone!
193+ path = Path line. shape
194+ clip = path\ clone!
195+
196+ line. tags\ insert {{ " bord" , 0 }}
197+
198+ if strokeAlign == " Outside"
199+ line. shape = path\ export !
200+ ass\ insertLine line, s
201+
213202 switch strokeAlign
214203 when " Outside" then path\ offset strokeWeight, cornerStyle, " polygon" , miterLimit, arcPrecision
215204 when " Center" then path\ offset strokeWeight, cornerStyle, " joined" , miterLimit, arcPrecision
216205 when " Inside" then path\ offset - math.abs ( strokeWeight) , cornerStyle, " polygon" , miterLimit, arcPrecision
217- if cutsOutside
218- path\ difference clip
206+
207+ if strokeAlign == " Center" or strokeAlign == " Inside"
208+ line. shape = clip\ difference( path) \ export !
209+ ass\ insertLine line, s
210+
211+ if strokeAlign == " Outside"
212+ line. shape = path\ difference( clip) \ export !
213+
214+ line. tags\ insert {{ " bord" , 0 }} , {{ " c" , line. data. color3}}
219215 line. shape = path\ export !
216+
220217 ass\ insertLine line, s
221218 return ass\ getNewSelection!
222219
@@ -596,13 +593,7 @@ ShaperyMacrosDialog = (macro) ->
596593 ass\ warning s, " Expected a shape"
597594 when " Shape without holes"
598595 if l. isShape
599- newShape = Path !
600- shapePath = Path l. shape
601- shapePathFlattened = Path ( shapePath) \ flatten!
602- for j = 1 , # shapePath. path
603- if checkPathClockWise shapePathFlattened. path[ j]
604- table.insert newShape. path, shapePath. path[ j]
605- l. shape = newShape\ export !
596+ l. shape = Path ( l. shape) \ withoutHoles!\ export !
606597 ass\ setLine l, s
607598 else
608599 ass\ warning s, " Expected a shape"
0 commit comments