pixie/examples/masking.nim

33 lines
637 B
Nim
Raw Normal View History

2021-02-25 16:51:09 +00:00
import pixie
let
image = newImage(200, 200)
lines = newImage(200, 200)
2022-07-26 02:00:30 +00:00
mask = newImage(200, 200)
2021-02-25 16:51:09 +00:00
lines.fill(parseHtmlColor("#FC427B").rgba)
image.fill(rgba(255, 255, 255, 255))
let ctx = newContext(lines)
ctx.strokeStyle = "#F8D1DD"
ctx.lineWidth = 30
ctx.strokeSegment(segment(vec2(25, 25), vec2(175, 175)))
ctx.strokeSegment(segment(vec2(25, 175), vec2(175, 25)))
2021-02-25 16:51:09 +00:00
mask.fillPath(
"""
M 20 60
A 40 40 90 0 1 100 60
A 40 40 90 0 1 180 60
Q 180 120 100 180
Q 20 120 20 60
z
2022-07-26 02:00:30 +00:00
""",
color(1, 1, 1, 1)
2021-02-25 16:51:09 +00:00
)
2022-07-26 02:00:30 +00:00
lines.draw(mask, blendMode = MaskBlend)
2021-02-25 16:51:09 +00:00
image.draw(lines)
image.writeFile("examples/masking.png")