pixie/examples/gradient.nim

32 lines
556 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
let paint = Paint(
kind: pkGradientRadial,
gradientHandlePositions: @[
vec2(100, 100),
vec2(200, 100),
vec2(100, 200)
],
gradientStops: @[
2021-02-26 00:26:55 +00:00
ColorStop(color: rgba(255, 0, 0, 255), position: 0),
ColorStop(color: rgba(255, 0, 0, 40), position: 1.0),
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")