commit
e30b8b0e27
6 changed files with 13 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ nimcache
|
||||||
*.ilk
|
*.ilk
|
||||||
.*
|
.*
|
||||||
*.dll
|
*.dll
|
||||||
|
__pycache__
|
||||||
|
|
|
@ -503,20 +503,11 @@ proc setTransform*(ctx: Context, transform: Mat3) {.inline, raises: [].} =
|
||||||
## Overrides the transform matrix being applied to the context.
|
## Overrides the transform matrix being applied to the context.
|
||||||
ctx.mat = transform
|
ctx.mat = transform
|
||||||
|
|
||||||
proc setTransform*(ctx: Context, a, b, c, d, e, f: float32) {.inline, raises: [].} =
|
|
||||||
## Overrides the transform matrix being applied to the context.
|
|
||||||
ctx.mat = mat3(a, b, 0, c, d, 0, e, f, 1)
|
|
||||||
|
|
||||||
proc transform*(ctx: Context, transform: Mat3) {.inline, raises: [].} =
|
proc transform*(ctx: Context, transform: Mat3) {.inline, raises: [].} =
|
||||||
## Multiplies the current transform with the matrix described by the
|
## Multiplies the current transform with the matrix described by the
|
||||||
## arguments of this method.
|
## arguments of this method.
|
||||||
ctx.mat = ctx.mat * transform
|
ctx.mat = ctx.mat * transform
|
||||||
|
|
||||||
proc transform*(ctx: Context, a, b, c, d, e, f: float32) {.inline, raises: [].} =
|
|
||||||
## Multiplies the current transform with the matrix described by the
|
|
||||||
## arguments of this method.
|
|
||||||
ctx.transform(mat3(a, b, 0, c, d, 0, e, f, 1))
|
|
||||||
|
|
||||||
proc translate*(ctx: Context, v: Vec2) {.inline, raises: [].} =
|
proc translate*(ctx: Context, v: Vec2) {.inline, raises: [].} =
|
||||||
## Adds a translation transformation to the current matrix.
|
## Adds a translation transformation to the current matrix.
|
||||||
ctx.mat = ctx.mat * translate(v)
|
ctx.mat = ctx.mat * translate(v)
|
||||||
|
|
|
@ -441,7 +441,7 @@ proc textUber(
|
||||||
target: Image | Mask,
|
target: Image | Mask,
|
||||||
arrangement: Arrangement,
|
arrangement: Arrangement,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
lineCap = lcButt,
|
lineCap = lcButt,
|
||||||
lineJoin = ljMiter,
|
lineJoin = ljMiter,
|
||||||
miterLimit = defaultMiterLimit,
|
miterLimit = defaultMiterLimit,
|
||||||
|
@ -550,7 +550,7 @@ proc strokeText*(
|
||||||
target: Image | Mask,
|
target: Image | Mask,
|
||||||
arrangement: Arrangement,
|
arrangement: Arrangement,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
lineCap = lcButt,
|
lineCap = lcButt,
|
||||||
lineJoin = ljMiter,
|
lineJoin = ljMiter,
|
||||||
miterLimit = defaultMiterLimit,
|
miterLimit = defaultMiterLimit,
|
||||||
|
@ -574,7 +574,7 @@ proc strokeText*(
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: string,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
bounds = vec2(0, 0),
|
bounds = vec2(0, 0),
|
||||||
hAlign = haLeft,
|
hAlign = haLeft,
|
||||||
vAlign = vaTop,
|
vAlign = vaTop,
|
||||||
|
|
|
@ -47,7 +47,7 @@ proc newPaint*(paint: Paint): Paint {.raises: [].} =
|
||||||
|
|
||||||
converter parseSomePaint*(
|
converter parseSomePaint*(
|
||||||
paint: SomePaint
|
paint: SomePaint
|
||||||
): Paint {.inline, raises: [PixieError].} =
|
): Paint {.inline.} =
|
||||||
## Given SomePaint, parse it in different ways.
|
## Given SomePaint, parse it in different ways.
|
||||||
when type(paint) is string:
|
when type(paint) is string:
|
||||||
result = newPaint(pkSolid)
|
result = newPaint(pkSolid)
|
||||||
|
|
|
@ -1812,7 +1812,7 @@ proc strokePath*(
|
||||||
mask: Mask,
|
mask: Mask,
|
||||||
path: SomePath,
|
path: SomePath,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
lineCap = lcButt,
|
lineCap = lcButt,
|
||||||
lineJoin = ljMiter,
|
lineJoin = ljMiter,
|
||||||
miterLimit = defaultMiterLimit,
|
miterLimit = defaultMiterLimit,
|
||||||
|
@ -1836,7 +1836,7 @@ proc strokePath*(
|
||||||
path: SomePath,
|
path: SomePath,
|
||||||
paint: Paint,
|
paint: Paint,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
lineCap = lcButt,
|
lineCap = lcButt,
|
||||||
lineJoin = ljMiter,
|
lineJoin = ljMiter,
|
||||||
miterLimit = defaultMiterLimit,
|
miterLimit = defaultMiterLimit,
|
||||||
|
@ -1944,7 +1944,7 @@ proc strokeOverlaps*(
|
||||||
path: Path,
|
path: Path,
|
||||||
test: Vec2,
|
test: Vec2,
|
||||||
transform = mat3(), ## Applied to the path, not the test point.
|
transform = mat3(), ## Applied to the path, not the test point.
|
||||||
strokeWidth = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
lineCap = lcButt,
|
lineCap = lcButt,
|
||||||
lineJoin = ljMiter,
|
lineJoin = ljMiter,
|
||||||
miterLimit = defaultMiterLimit,
|
miterLimit = defaultMiterLimit,
|
||||||
|
|
|
@ -201,7 +201,7 @@ block:
|
||||||
block:
|
block:
|
||||||
let ctx = newContext(newImage(300, 150))
|
let ctx = newContext(newImage(300, 150))
|
||||||
|
|
||||||
ctx.setTransform(1, 0.2, 0.8, 1, 0, 0)
|
ctx.setTransform(mat3(1, 0.2, 0, 0.8, 1, 0, 0, 0, 1))
|
||||||
ctx.fillRect(0, 0, 100, 100)
|
ctx.fillRect(0, 0, 100, 100)
|
||||||
|
|
||||||
ctx.image.writeFile("tests/images/context/setTransform_1.png")
|
ctx.image.writeFile("tests/images/context/setTransform_1.png")
|
||||||
|
@ -209,7 +209,7 @@ block:
|
||||||
block:
|
block:
|
||||||
let ctx = newContext(newImage(300, 150))
|
let ctx = newContext(newImage(300, 150))
|
||||||
|
|
||||||
ctx.setTransform(1, 0.2, 0.8, 1, 0, 0)
|
ctx.setTransform(mat3(1, 0.2, 0, 0.8, 1, 0, 0, 0, 1))
|
||||||
ctx.fillRect(0, 0, 100, 100)
|
ctx.fillRect(0, 0, 100, 100)
|
||||||
|
|
||||||
ctx.image.writeFile("tests/images/context/resetTransform_1.png")
|
ctx.image.writeFile("tests/images/context/resetTransform_1.png")
|
||||||
|
@ -225,7 +225,7 @@ block:
|
||||||
block:
|
block:
|
||||||
let ctx = newContext(newImage(300, 150))
|
let ctx = newContext(newImage(300, 150))
|
||||||
|
|
||||||
ctx.transform(1, 0, 1.7, 1, 0, 0)
|
ctx.transform(mat3(1, 0, 0, 1.7, 1, 0, 0, 0, 1))
|
||||||
ctx.fillStyle = "gray"
|
ctx.fillStyle = "gray"
|
||||||
ctx.fillRect(40, 40, 50, 20)
|
ctx.fillRect(40, 40, 50, 20)
|
||||||
ctx.fillRect(40, 90, 50, 20)
|
ctx.fillRect(40, 90, 50, 20)
|
||||||
|
@ -244,7 +244,7 @@ block:
|
||||||
ctx.fillStyle = "red"
|
ctx.fillStyle = "red"
|
||||||
ctx.fillRect(0, 0, 80, 80)
|
ctx.fillRect(0, 0, 80, 80)
|
||||||
|
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
ctx.setTransform(mat3(1, 0, 0, 0, 1, 0, 0, 0, 1))
|
||||||
|
|
||||||
ctx.fillStyle = "gray"
|
ctx.fillStyle = "gray"
|
||||||
ctx.fillRect(0, 0, 80, 80)
|
ctx.fillRect(0, 0, 80, 80)
|
||||||
|
@ -258,7 +258,7 @@ block:
|
||||||
ctx.fillStyle = "red"
|
ctx.fillStyle = "red"
|
||||||
ctx.fillRect(10, 10, 8, 20)
|
ctx.fillRect(10, 10, 8, 20)
|
||||||
|
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
ctx.setTransform(mat3(1, 0, 0, 0, 1, 0, 0, 0, 1))
|
||||||
|
|
||||||
ctx.fillStyle = "gray"
|
ctx.fillStyle = "gray"
|
||||||
ctx.fillRect(10, 10, 8, 20)
|
ctx.fillRect(10, 10, 8, 20)
|
||||||
|
|
Loading…
Reference in a new issue