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,
|
2021-08-06 23:08:21 +00:00
|
|
|
rgba(255, 0, 0, 255)
|
2021-02-25 05:49:21 +00:00
|
|
|
)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/paintSolid.png")
|
2021-02-25 05:49:21 +00:00
|
|
|
|
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkImage)
|
2021-10-03 22:17:04 +00:00
|
|
|
paint.image = decodePng(readFile("tests/fileformats/png/baboon.png"))
|
2021-08-06 23:08:21 +00:00
|
|
|
paint.imageMat = scale(vec2(0.2, 0.2))
|
|
|
|
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/paintImage.png")
|
2021-02-25 05:49:21 +00:00
|
|
|
|
2021-07-18 21:49:55 +00:00
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkImage)
|
2021-10-03 22:17:04 +00:00
|
|
|
paint.image = decodePng(readFile("tests/fileformats/png/baboon.png"))
|
2021-08-06 23:08:21 +00:00
|
|
|
paint.imageMat = scale(vec2(0.2, 0.2))
|
2021-07-18 21:49:55 +00:00
|
|
|
paint.opacity = 0.5
|
|
|
|
|
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/paintImageOpacity.png")
|
2021-07-18 21:49:55 +00:00
|
|
|
|
2021-02-25 05:49:21 +00:00
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkImageTiled)
|
2021-10-03 22:17:04 +00:00
|
|
|
paint.image = decodePng(readFile("tests/fileformats/png/baboon.png"))
|
2021-08-06 23:08:21 +00:00
|
|
|
paint.imageMat = scale(vec2(0.02, 0.02))
|
|
|
|
|
2021-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/paintImageTiled.png")
|
2021-02-25 05:49:21 +00:00
|
|
|
|
2021-07-18 21:49:55 +00:00
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkImageTiled)
|
2021-10-03 22:17:04 +00:00
|
|
|
paint.image = decodePng(readFile("tests/fileformats/png/baboon.png"))
|
2021-08-06 23:08:21 +00:00
|
|
|
paint.imageMat = scale(vec2(0.02, 0.02))
|
2021-07-18 21:49:55 +00:00
|
|
|
paint.opacity = 0.5
|
|
|
|
|
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/paintImageTiledOpacity.png")
|
2021-07-18 21:49:55 +00:00
|
|
|
|
2021-02-25 05:49:21 +00:00
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkGradientLinear)
|
|
|
|
paint.gradientHandlePositions = @[
|
|
|
|
vec2(0, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
]
|
|
|
|
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-05-10 16:51:51 +00:00
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/gradientLinear.png")
|
2021-02-25 05:49:21 +00:00
|
|
|
|
2021-11-23 10:14:03 +00:00
|
|
|
block:
|
|
|
|
let paint = newPaint(pkGradientLinear)
|
|
|
|
paint.gradientHandlePositions = @[
|
|
|
|
vec2(50, 0),
|
|
|
|
vec2(50, 100),
|
|
|
|
]
|
|
|
|
paint.gradientStops = @[
|
|
|
|
ColorStop(color: color(1, 0, 0, 1), position: 0),
|
|
|
|
ColorStop(color: color(1, 0, 0, 0.15625), position: 1.0),
|
|
|
|
]
|
|
|
|
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fillPath(heartShape, paint)
|
|
|
|
image.writeFile("tests/paths/gradientLinear2.png")
|
|
|
|
|
2021-02-25 05:49:21 +00:00
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkGradientRadial)
|
|
|
|
paint.gradientHandlePositions = @[
|
|
|
|
vec2(50, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
vec2(50, 100)
|
|
|
|
]
|
|
|
|
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 05:49:21 +00:00
|
|
|
|
2021-08-06 23:08:21 +00:00
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/gradientRadial.png")
|
2021-02-25 05:49:21 +00:00
|
|
|
|
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkGradientAngular)
|
|
|
|
paint.gradientHandlePositions = @[
|
|
|
|
vec2(50, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
vec2(50, 100)
|
|
|
|
]
|
|
|
|
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 05:49:21 +00:00
|
|
|
|
2021-08-06 23:08:21 +00:00
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/gradientAngular.png")
|
2021-07-18 21:49:55 +00:00
|
|
|
|
|
|
|
block:
|
2021-08-06 23:08:21 +00:00
|
|
|
let paint = newPaint(pkGradientAngular)
|
|
|
|
paint.gradientHandlePositions = @[
|
|
|
|
vec2(50, 50),
|
|
|
|
vec2(100, 50),
|
|
|
|
vec2(50, 100)
|
|
|
|
]
|
|
|
|
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-07-18 21:49:55 +00:00
|
|
|
paint.opacity = 0.5
|
|
|
|
|
|
|
|
let image = newImage(100, 100)
|
2021-08-06 23:08:21 +00:00
|
|
|
image.fillPath(heartShape, paint)
|
2021-10-03 22:17:04 +00:00
|
|
|
image.writeFile("tests/paths/gradientAngularOpacity.png")
|