2021-02-25 05:49:21 +00:00
|
|
|
import chroma, pixie, pixie/fileformats/png, vmath
|
|
|
|
|
|
|
|
const heartShape = """
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkSolid,
|
|
|
|
color: rgba(255, 0, 0, 255)
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/paths/paintSolid.png")
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkImage,
|
|
|
|
image: decodePng(readFile("tests/images/png/baboon.png")),
|
|
|
|
imageMat: scale(vec2(0.2, 0.2))
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/paths/paintImage.png")
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkImageTiled,
|
|
|
|
image: decodePng(readFile("tests/images/png/baboon.png")),
|
|
|
|
imageMat: scale(vec2(0.02, 0.02))
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/paths/paintImageTiled.png")
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkGradientLinear,
|
2021-02-25 05:49:21 +00:00
|
|
|
gradientHandlePositions: @[
|
|
|
|
vec2(0, 50),
|
|
|
|
vec2(100, 50),
|
2021-02-25 17:43:09 +00:00
|
|
|
],
|
|
|
|
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 17:43:09 +00:00
|
|
|
]
|
|
|
|
)
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
image.writeFile("tests/images/paths/gradientLinear.png")
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkGradientRadial,
|
2021-02-25 05:49:21 +00:00
|
|
|
gradientHandlePositions: @[
|
|
|
|
vec2(50, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
vec2(50, 100)
|
2021-02-25 17:43:09 +00:00
|
|
|
],
|
|
|
|
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 17:43:09 +00:00
|
|
|
]
|
|
|
|
)
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
image.writeFile("tests/images/paths/gradientRadial.png")
|
|
|
|
|
|
|
|
block:
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-02-25 05:49:21 +00:00
|
|
|
image.fillPath(
|
|
|
|
heartShape,
|
|
|
|
Paint(
|
2021-02-25 17:43:09 +00:00
|
|
|
kind: pkGradientAngular,
|
2021-02-25 05:49:21 +00:00
|
|
|
gradientHandlePositions: @[
|
|
|
|
vec2(50, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
vec2(50, 100)
|
2021-02-25 17:43:09 +00:00
|
|
|
],
|
|
|
|
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 17:43:09 +00:00
|
|
|
]
|
|
|
|
)
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
image.writeFile("tests/images/paths/gradientAngular.png")
|