This commit is contained in:
Ryan Oldenburg 2021-11-21 01:10:15 -06:00
parent 4362523080
commit b8c1dbc4f2
2 changed files with 13 additions and 8 deletions

View file

@ -1940,10 +1940,7 @@ proc overlaps(
let
scanline = line(vec2(0, test.y), vec2(1000, test.y))
segments = shapes.shapesToSegments()
for i in 0 ..< segments.len: # For gc:arc
let
segment = segments[i][0]
winding = segments[i][1]
for (segment, winding) in segments:
if segment.at.y <= scanline.a.y and segment.to.y >= scanline.a.y:
var at: Vec2
if scanline.intersects(segment, at):
@ -1953,8 +1950,7 @@ proc overlaps(
sort(hits, 0, hits.high)
var count: int
for i in 0 ..< hits.len: # For gc:arc
let (at, winding) = hits[i]
for (at, winding) in hits:
if at > test.x:
return shouldFill(windingRule, count)
count += winding

View file

@ -5,8 +5,16 @@ let pathStr = "m57.611-8.591c-1.487,1.851-4.899,4.42-1.982,6.348,0.194,0.129,0.5
timeIt "parsePath":
keep parsePath(pathStr)
let image = newImage(500, 300)
image.fill(rgba(255, 255, 255, 255))
block:
let path = parsePath("""
M 10,30
A 20,20 0,0,1 50,30
A 20,20 0,0,1 90,30
Q 90,60 50,90
Q 10,60 10,30 z
""")
timeIt "fillOverlaps":
doAssert path.fillOverlaps(vec2(1, 1)) == false
timeIt "roundedRect":
const radius = 20
@ -15,4 +23,5 @@ timeIt "roundedRect":
path.roundedRect(0.5, 0.5, 499, 299, radius, radius, radius, radius)
# path.roundedRect(0, 0, 500, 300, radius, radius, radius, radius)
let image = newImage(500, 300)
image.fillPath(path, rgba(0, 0, 0, 255))