Fix tests.

This commit is contained in:
treeform 2020-11-20 10:00:58 -08:00
parent 305d65187c
commit 724b2f30da
4 changed files with 16 additions and 5 deletions

View file

@ -9,3 +9,4 @@ requires "nim >= 1.2.6"
requires "vmath >= 0.3.2"
requires "chroma >= 0.1.5"
requires "zippy >= 0.3.5"
requires "flatty >= 0.1.1"

View file

@ -1,4 +1,4 @@
import ../images, flatty/binny, flatty/hexPrint, chroma, sequtils, print
import ../images, flatty/binny, chroma
# See: https://en.wikipedia.org/wiki/BMP_file_format

View file

@ -228,6 +228,16 @@ proc getRgbaSmooth*(image: Image, x, y: float64): ColorRGBA
return finalMix.rgba()
proc hasEffect*(blendMode: BlendMode, rgba: ColorRGBA): bool =
## Returns true if applying rgba with current blend mode has effect.
case blendMode
of Mask:
rgba.a != 255
of COPY:
true
else:
rgba.a > 0
proc draw*(destImage: Image, srcImage: Image, mat: Mat4, blendMode = Normal) =
## Draws one image onto another using matrix with color blending.
var srcImage = srcImage

View file

@ -13,7 +13,7 @@ block:
image[2, 1] = rgba(255, 0, 0, 127)
image[3, 1] = rgba(255, 255, 255, 127)
writeFile("images/bmp/test4x2.bmp", encodeBmp(image))
writeFile("tests/images/bmp/test4x2.bmp", encodeBmp(image))
var image2 = decodeBmp(encodeBmp(image))
doAssert image2.width == image.width
@ -23,7 +23,7 @@ block:
block:
var image = newImage(16, 16)
image.fill(rgba(255, 0, 0, 127))
writeFile("images/bmp/test16x16.bmp", encodeBmp(image))
writeFile("tests/images/bmp/test16x16.bmp", encodeBmp(image))
var image2 = decodeBmp(encodeBmp(image))
doAssert image2.width == image.width
@ -32,5 +32,5 @@ block:
block:
for bits in [32, 24]:
var image = decodeBmp(readFile("images/bmp/knight." & $bits & ".master.bmp"))
writeFile("images/bmp/knight." & $bits & ".bmp", encodeBmp(image))
var image = decodeBmp(readFile("tests/images/bmp/knight." & $bits & ".master.bmp"))
writeFile("tests/images/bmp/knight." & $bits & ".bmp", encodeBmp(image))