Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Nov 22, 2024
1 parent 22af59a commit 5fe9a4d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ testresults/
/tests/*
!/tests/*.nim
!/tests/*.nims
/src/blend2d-core/
/src/blend2d/bindings/*_impl
!/tests/out
/tests/out/*
6 changes: 6 additions & 0 deletions tests/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
switch("path", "$projectDir/../src")
# --passC:"-I/home/runner/work/blend2d-nim/blend2d-nim/blend2d/src"
# --passL:"-L/home/runner/work/blend2d-nim/blend2d-nim/blend2d/build -lblend2d"

--passC:"-I/Users/georgelemon/Development/otherpackages/blend2dnim/src/blend2d-core/src/"
--passL: "-L$HOME/.nimble/lib -lblend2d"
38 changes: 38 additions & 0 deletions tests/test1.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import unittest
import std/os

import blend2d

test "filled background":
group main, 200, 200:
this.fillStyle(colSalmon)
main.exportAs("tests" / "out" / "filled.png")

test "draw circle + stroke":
group mainImage, 200, 200:
let sun = circle(100, 100, 50)
sun.stroke(50, rgba(242,224,171,255))
this.add(sun.addr, rgba(230,197,115,255))
mainImage.exportAs("tests" / "out" / "circle.png")

test "draw gradient":
group img, 480, 480:
let
blRoundRect = roundRect(180, 180, 120, 120, 25, 25)
linearGradient = linearGradient(0, 0, 0, 480)
linearGradient.add(0.0, ColorHex(0xFFFFFFFF))
linearGradient.add(0.5, ColorHex(0xFF5FAFDF))
linearGradient.add(1.0, ColorHex(0xFF2F5FDF))

this.fill(colWhitesmoke)
this.add(blRoundRect.addr, linearGradient)
this.add(img)

img.exportAs("tests" / "out" / "gradient.png")

test "draw profile":
group main, 700, 700:
this.fill(colSalmon)
let area = rect(190, 140, 320, 400, 25, 25)
this.add(area.addr, colWhite)
main.exportAs("tests" / "out" / "ui.png")

0 comments on commit 5fe9a4d

Please sign in to comment.