2021-02-18 19:29:40 +00:00
|
|
|
import pixie
|
2021-02-11 20:56:47 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
a = newImage(1000, 1000)
|
|
|
|
b = newImage(500, 500)
|
|
|
|
a.fill(rgba(255, 0, 0, 255))
|
|
|
|
b.fill(rgba(0, 255, 0, 255))
|
|
|
|
|
|
|
|
a.draw(b, translate(vec2(250, 250)))
|
|
|
|
a.writeFile("tests/images/rotate0.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
a = newImage(1000, 1000)
|
|
|
|
b = newImage(500, 500)
|
|
|
|
a.fill(rgba(255, 0, 0, 255))
|
|
|
|
b.fill(rgba(0, 255, 0, 255))
|
|
|
|
|
2021-03-26 21:10:11 +00:00
|
|
|
a.draw(b, translate(vec2(250, 250)) * rotate(90 * PI.float32 / 180))
|
2021-02-11 20:56:47 +00:00
|
|
|
a.writeFile("tests/images/rotate90.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
a = newImage(1000, 1000)
|
|
|
|
b = newImage(500, 500)
|
|
|
|
a.fill(rgba(255, 0, 0, 255))
|
|
|
|
b.fill(rgba(0, 255, 0, 255))
|
|
|
|
|
2021-03-26 21:10:11 +00:00
|
|
|
a.draw(b, translate(vec2(250, 250)) * rotate(180 * PI.float32 / 180))
|
2021-02-11 20:56:47 +00:00
|
|
|
a.writeFile("tests/images/rotate180.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
a = newImage(1000, 1000)
|
|
|
|
b = newImage(500, 500)
|
|
|
|
a.fill(rgba(255, 0, 0, 255))
|
|
|
|
b.fill(rgba(0, 255, 0, 255))
|
|
|
|
|
2021-03-26 21:10:11 +00:00
|
|
|
a.draw(b, translate(vec2(250, 250)) * rotate(270 * PI.float32 / 180))
|
2021-02-11 20:56:47 +00:00
|
|
|
a.writeFile("tests/images/rotate270.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
a = newImage(1000, 1000)
|
|
|
|
b = newImage(500, 500)
|
|
|
|
a.fill(rgba(255, 0, 0, 255))
|
|
|
|
b.fill(rgba(0, 255, 0, 255))
|
|
|
|
|
2021-03-26 21:10:11 +00:00
|
|
|
a.draw(b, translate(vec2(250, 250)) * rotate(360 * PI.float32 / 180))
|
2021-02-11 20:56:47 +00:00
|
|
|
a.writeFile("tests/images/rotate360.png")
|
2021-02-18 19:29:40 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
2021-02-19 18:04:27 +00:00
|
|
|
image.fillRect(rect(vec2(10, 10), vec2(30, 30)), rgba(255, 255, 0, 255))
|
2021-02-18 19:29:40 +00:00
|
|
|
image.writeFile("tests/images/drawRect.png")
|
2021-02-18 19:55:26 +00:00
|
|
|
|
2021-02-18 22:23:54 +00:00
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
2021-02-19 18:04:27 +00:00
|
|
|
image.strokeRect(rect(vec2(10, 10), vec2(30, 30)), rgba(255, 255, 0, 255), 10)
|
|
|
|
image.writeFile("tests/images/strokeRect.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
|
|
|
image.fillRoundedRect(
|
2021-02-18 22:23:54 +00:00
|
|
|
rect(vec2(10, 10), vec2(30, 30)),
|
|
|
|
10,
|
|
|
|
rgba(255, 255, 0, 255)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/drawRoundedRect.png")
|
|
|
|
|
2021-02-18 19:55:26 +00:00
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
2021-02-19 18:04:27 +00:00
|
|
|
image.strokeRoundedRect(
|
|
|
|
rect(vec2(10, 10), vec2(30, 30)),
|
|
|
|
10,
|
|
|
|
rgba(255, 255, 0, 255),
|
|
|
|
10
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/strokeRoundedRect.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
|
|
|
image.strokeSegment(
|
2021-02-18 19:55:26 +00:00
|
|
|
segment(vec2(10, 10), vec2(90, 90)),
|
|
|
|
rgba(255, 255, 0, 255),
|
|
|
|
strokeWidth = 10
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/drawSegment.png")
|
2021-02-18 22:30:47 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
2021-02-19 18:04:27 +00:00
|
|
|
image.fillEllipse(
|
2021-02-18 22:30:47 +00:00
|
|
|
vec2(50, 50),
|
|
|
|
25,
|
|
|
|
25,
|
|
|
|
rgba(255, 255, 0, 255)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/drawEllipse.png")
|
2021-02-18 22:40:35 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
2021-02-19 18:04:27 +00:00
|
|
|
image.strokeEllipse(
|
|
|
|
vec2(50, 50),
|
|
|
|
25,
|
|
|
|
25,
|
|
|
|
rgba(255, 255, 0, 255),
|
|
|
|
10
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/strokeEllipse.png")
|
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
|
|
|
image.fillPolygon(
|
2021-02-18 22:40:35 +00:00
|
|
|
vec2(50, 50),
|
|
|
|
30,
|
|
|
|
6,
|
|
|
|
rgba(255, 255, 0, 255)
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/drawPolygon.png")
|
2021-02-19 18:04:27 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let image = newImage(100, 100)
|
|
|
|
image.fill(rgba(0, 255, 255, 255))
|
|
|
|
image.strokePolygon(
|
|
|
|
vec2(50, 50),
|
|
|
|
30,
|
|
|
|
6,
|
|
|
|
rgba(255, 255, 0, 255),
|
|
|
|
10
|
|
|
|
)
|
|
|
|
image.writeFile("tests/images/strokePolygon.png")
|