pixie/examples/gradient.nim

30 lines
544 B
Nim
Raw Normal View History

import pixie
2021-02-25 18:05:46 +00:00
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
2021-02-25 18:05:46 +00:00
2021-08-06 23:08:21 +00:00
let paint = newPaint(pkGradientRadial)
paint.gradientHandlePositions = @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
]
paint.gradientStops = @[
2021-08-12 03:54:55 +00:00
ColorStop(color: color(1, 0, 0, 1), position: 0),
ColorStop(color: color(1, 0, 0, 0.15625), position: 1.0),
2021-08-06 23:08:21 +00:00
]
2021-02-25 18:05:46 +00:00
image.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
""",
2021-02-25 18:05:46 +00:00
paint
)
2021-02-26 00:26:55 +00:00
image.writeFile("examples/gradient.png")