Cleanup.
This commit is contained in:
parent
dffad18641
commit
ba5681e452
1 changed files with 9 additions and 7 deletions
|
@ -1056,19 +1056,21 @@ proc shapesToSegments(shapes: seq[Polygon]): seq[(Segment, int16)] =
|
||||||
## Converts the shapes into a set of filtered segments with winding value.
|
## Converts the shapes into a set of filtered segments with winding value.
|
||||||
|
|
||||||
# Quantize the segment to prevent leaks
|
# Quantize the segment to prevent leaks
|
||||||
template quantize(v: Vec2, q: float32): Vec2 =
|
template quantizeY(v: Vec2): Vec2 =
|
||||||
vec2(v.x.quantize(q), v.y.quantize(q))
|
vec2(v.x, v.y.quantize(1 / 256))
|
||||||
|
|
||||||
for poly in shapes:
|
for poly in shapes:
|
||||||
var
|
var
|
||||||
vec1 = poly[^1].quantize(1 / 256)
|
vec1 = poly[^1].quantizeY()
|
||||||
vec2 = poly[0].quantize(1 / 256)
|
vec2: Vec2
|
||||||
segment: Segment
|
segment: Segment
|
||||||
for i in 0 ..< poly.len:
|
for i in 0 ..< poly.len:
|
||||||
if i != 0:
|
vec2 = poly[i].quantizeY()
|
||||||
vec2 = vec1
|
if i == 0 and vec1 == vec2:
|
||||||
vec1 = poly[i].quantize(1 / 256)
|
continue
|
||||||
segment = segment(vec1, vec2)
|
segment = segment(vec1, vec2)
|
||||||
|
vec1 = vec2
|
||||||
|
|
||||||
if segment.at.y == segment.to.y: # Skip horizontal
|
if segment.at.y == segment.to.y: # Skip horizontal
|
||||||
continue
|
continue
|
||||||
var
|
var
|
||||||
|
|
Loading…
Reference in a new issue