2020-12-04 17:25:46 +00:00
|
|
|
import pixie, chroma, strutils, os
|
2020-11-21 18:34:57 +00:00
|
|
|
|
|
|
|
proc writeAndCheck(image: Image, fileName: string) =
|
|
|
|
image.writeFile(fileName)
|
2020-11-23 03:29:29 +00:00
|
|
|
let masterFileName = fileName.replace("tests/images/", "tests/images/masters/")
|
2020-11-27 21:51:40 +00:00
|
|
|
if not fileExists(masterFileName):
|
2020-11-22 00:51:29 +00:00
|
|
|
echo "Master file: " & masterFileName & " not found!"
|
2020-11-23 03:29:29 +00:00
|
|
|
quit(-1)
|
2020-11-21 18:34:57 +00:00
|
|
|
var master = readImage(fileName)
|
|
|
|
assert image.width == master.width
|
|
|
|
assert image.height == master.height
|
|
|
|
assert image.data == master.data
|
2020-11-20 06:12:44 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(0, 0, 0, 0))
|
|
|
|
# var b = newImage(50, 50)
|
|
|
|
# b.fill(rgba(255, 92, 0, 255))
|
|
|
|
# var c = a.drawBlendSmooth(
|
|
|
|
# b,
|
|
|
|
# translate(vec2(50, 50)) * rotationMat3(0.2789281382) * translate(vec2(-25, -25)),
|
|
|
|
# bmNormal
|
|
|
|
# )
|
|
|
|
# c.writeAndCheck("tests/images/centerRotation.png")
|
2020-11-22 20:12:53 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(255, 255, 255, 255))
|
|
|
|
# var b = newImage(50, 50)
|
|
|
|
# b.fill(rgba(255, 92, 0, 255))
|
|
|
|
# var c = a.drawBlendSmooth(
|
|
|
|
# b,
|
|
|
|
# translate(vec2(50, 50)) * rotationMat3(0.2789281382) * translate(vec2(-25, -25)),
|
|
|
|
# bmNormal
|
|
|
|
# )
|
|
|
|
# c.writeAndCheck("tests/images/centerRotationWhite.png")
|
2020-11-22 20:12:53 +00:00
|
|
|
|
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(0, 0, 0, 0))
|
|
|
|
# var b = newImage(50, 50)
|
|
|
|
# b.fill(rgba(255, 92, 0, 255))
|
|
|
|
# var c = a.drawBlendSmooth(
|
|
|
|
# b,
|
|
|
|
# translate(vec2(50, 50)) * rotationMat3(0.2789281382) * translate(vec2(-25, -25)),
|
|
|
|
# bmNormal
|
|
|
|
# )
|
|
|
|
# c.writeAndCheck("tests/images/transCompose.c.png")
|
|
|
|
# var d = newImage(100, 100)
|
|
|
|
# d = d.fill(rgba(255, 255, 255, 255))
|
|
|
|
# var e = d.draw(c)
|
|
|
|
# e.writeAndCheck("tests/images/transCompose.png")
|
2020-11-22 20:12:53 +00:00
|
|
|
|
2020-11-20 06:12:44 +00:00
|
|
|
block:
|
|
|
|
var image = newImage(10, 10)
|
|
|
|
image[0, 0] = rgba(255, 255, 255, 255)
|
|
|
|
doAssert image[0, 0] == rgba(255, 255, 255, 255)
|
|
|
|
|
|
|
|
block:
|
|
|
|
var image = newImage(10, 10)
|
2020-11-28 00:54:10 +00:00
|
|
|
image.fill(rgba(255, 0, 0, 255))
|
2020-11-20 06:12:44 +00:00
|
|
|
doAssert image[0, 0] == rgba(255, 0, 0, 255)
|
2020-11-21 18:34:57 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(255, 0, 0, 255))
|
|
|
|
# var b = newImage(100, 100)
|
|
|
|
# b.fill(rgba(0, 255, 0, 255))
|
|
|
|
# var c = a.drawOverwrite(b, translate(vec2(25, 25)))
|
|
|
|
# c.writeAndCheck("tests/images/drawOverwrite.png")
|
2020-11-21 18:34:57 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(255, 0, 0, 255))
|
|
|
|
# var b = newImage(100, 100)
|
|
|
|
# b.fill(rgba(0, 255, 0, 255))
|
|
|
|
# var c = a.draw(b, translate(vec2(25, 25)), bmOverwrite)
|
|
|
|
# c.writeAndCheck("tests/images/drawBlend.png")
|
2020-11-21 18:34:57 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(255, 0, 0, 255))
|
|
|
|
# var b = newImage(100, 100)
|
|
|
|
# b.fill(rgba(0, 255, 0, 255))
|
|
|
|
# var c = a.draw(b, translate(vec2(25.15, 25.15)), bmOverwrite)
|
|
|
|
# c.writeAndCheck("tests/images/drawBlendSmooth.png")
|
2020-11-22 00:51:29 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# block:
|
|
|
|
# var a = newImage(100, 100)
|
|
|
|
# a.fill(rgba(255, 0, 0, 255))
|
|
|
|
# var b = newImage(100, 100)
|
|
|
|
# b.fill(rgba(0, 255, 0, 255))
|
2020-11-22 00:51:29 +00:00
|
|
|
|
2020-11-28 00:54:10 +00:00
|
|
|
# var c = a.draw(b, translate(vec2(25, 25)) * rotationMat3(PI/2))
|
|
|
|
# c.writeAndCheck("tests/images/drawOverwriteRot.png")
|