Skip to content

Commit e612e52

Browse files
committed
Update ILL
1 parent 6902b43 commit e612e52

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

modules/ILL/ILL.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module_version = "1.5.9"
1+
module_version = "1.6.0"
22

33
haveDepCtrl, DependencyControl = pcall require, "l0.DependencyControl"
44

modules/ILL/ILL/Ass/Shape/Path.moon

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Path
99

1010
-- Create a new Path object
1111
new: (path) =>
12+
@hasCurve = false
1213
if type(path) == "string"
1314
@import path
1415
elseif type(path) == "table"
@@ -118,12 +119,17 @@ class Path
118119
j += 1
119120
insert newPath, newContour
120121
@path = newPath
122+
@hasCurve = false
121123
return @
122124

123125
-- Simplifies the number of path points
124126
simplify: (tolerance = 0.5, highestQuality = true, recreateBezier = true, angleThreshold = 170) =>
125127
@cleanContours!
126-
@path = Path.Simplifier(@path, tolerance, highestQuality, recreateBezier, angleThreshold)
128+
if @hasCurve
129+
@flatten!
130+
if recreateBezier
131+
@hasCurve = true
132+
@path = Path.Simplifier @path, tolerance, highestQuality, recreateBezier, angleThreshold
127133
return @
128134

129135
-- Move the @path by specified distance
@@ -367,33 +373,17 @@ class Path
367373
length += seg\getLength!
368374
return length
369375

370-
-- Gets the normalized tangent on the Path given a time
371376
-- Gets the normalized tangent on the Path given a time
372377
getNormalized: (t = 0.5) =>
373-
sumLength, length, newPath, tan, p, u = 0, t * @getLength!, Path!, nil, nil, nil
374-
@callBackPath (id, seg, k) ->
375-
path, segmentLen = {}, seg\getLength!
376-
if newPath.path[k] == nil
377-
newPath.path[k] = {seg.a}
378+
sumLength, length, tan, p, u = 0, t * @getLength!, nil, nil, nil
379+
@callBackPath (id, seg) ->
380+
segmentLen = seg\getLength!
378381
if sumLength + segmentLen >= length
379382
u = (length - sumLength) / segmentLen
380383
tan, p, u = seg\getNormalized u
381-
spt = seg\split(u)[1]
382-
if id == 'l'
383-
insert newPath.path[k], spt.b
384-
else if id == 'b'
385-
insert newPath.path[k], spt.b
386-
insert newPath.path[k], spt.c
387-
insert newPath.path[k], spt.b
388-
return "break", p, u, newPath
389-
if id == 'l'
390-
insert newPath.path[k], seg.b
391-
else
392-
insert newPath.path[k], seg.b
393-
insert newPath.path[k], seg.c
394-
insert newPath.path[k], seg.d
384+
return "break"
395385
sumLength += segmentLen
396-
return tan, p, u, newPath
386+
return tan, p, u
397387

398388
-- Distort the Path into another Path
399389
-- http://www.planetclegg.com/projects/WarpingTextToSplines.html
@@ -468,6 +458,8 @@ class Path
468458
-- checks if the shape has only m, l and b commands
469459
unless cmd\find "[mlb]"
470460
error "shape unknown", 2
461+
if cmd == "b" and not @hasCurve
462+
@hasCurve = true
471463
currCmd = cmd
472464
insert path, Point tonumber(x), tonumber(y), currCmd
473465
path[1].id = "l"

0 commit comments

Comments
 (0)