Skip to content

Commit 6d47166

Browse files
authored
Merge pull request #568 from treeform/vmath_v3c
Use the new vmath v3 with CCW angles.
2 parents 984cf50 + 7973f61 commit 6d47166

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

pixie.nimble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
version = "5.1.0"
1+
version = "6.0.0"
22
author = "Andre von Houck and Ryan Oldenburg"
33
description = "Full-featured 2d graphics library for Nim."
44
license = "MIT"
55

66
srcDir = "src"
77

88
requires "nim >= 1.4.8"
9-
requires "vmath >= 1.1.4"
9+
requires "vmath >= 3.0.0"
1010
requires "chroma >= 0.2.6"
1111
requires "zippy >= 0.10.3"
1212
requires "flatty >= 0.3.4"

src/pixie/contexts.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ proc scale*(ctx: Context, x, y: float32) {.inline, raises: [].} =
551551

552552
proc rotate*(ctx: Context, angle: float32) {.inline, raises: [].} =
553553
## Adds a rotation to the transformation matrix.
554-
ctx.mat = ctx.mat * rotate(-angle)
554+
ctx.mat = ctx.mat * rotate(angle)
555555

556556
proc resetTransform*(ctx: Context) {.inline, raises: [].} =
557557
## Resets the current transform to the identity matrix.

src/pixie/fileformats/svg.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ proc parseSvgProperties(node: XmlNode, inherited: SvgProperties): SvgProperties
277277
elif f.startsWith("rotate("):
278278
let
279279
values = splitArgs(f[7 .. ^2])
280-
angle: float32 = parseFloat(values[0]) * -PI / 180
280+
angle: float32 = parseFloat(values[0]) * PI / 180
281281
var cx, cy: float32
282282
if values.len > 1:
283283
cx = parseFloat(values[1])

src/pixie/paints.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ proc fillGradientRadial(image: Image, paint: Paint) =
198198
gradientAngle = normalize(center - edge).angle().fixAngle()
199199
mat = (
200200
translate(center) *
201-
rotate(-gradientAngle) *
201+
rotate(gradientAngle) *
202202
scale(vec2(distanceX, distanceY))
203203
).inverse()
204204
for y in 0 ..< image.height:

src/pixie/paths.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ proc commandsToShapes(
839839

840840
ArcParams(
841841
radii: radii,
842-
rotMat: rotate(-radians),
842+
rotMat: rotate(radians),
843843
center: center,
844844
theta: theta,
845845
delta: delta

tests/test_images_draw.nim

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ block:
1717
a.fill(rgba(255, 0, 0, 255))
1818
b.fill(rgba(0, 255, 0, 255))
1919

20-
a.draw(b, translate(vec2(250, 250)) * rotate(90 * PI.float32 / 180))
20+
a.draw(b, translate(vec2(250, 250)) * rotate(-90 * PI.float32 / 180))
2121
a.xray("tests/images/rotate90.png")
2222

2323
block:
@@ -27,7 +27,7 @@ block:
2727
a.fill(rgba(255, 0, 0, 255))
2828
b.fill(rgba(0, 255, 0, 255))
2929

30-
a.draw(b, translate(vec2(250, 250)) * rotate(180 * PI.float32 / 180))
30+
a.draw(b, translate(vec2(250, 250)) * rotate(-180 * PI.float32 / 180))
3131
a.xray("tests/images/rotate180.png")
3232

3333
block:
@@ -37,7 +37,7 @@ block:
3737
a.fill(rgba(255, 0, 0, 255))
3838
b.fill(rgba(0, 255, 0, 255))
3939

40-
a.draw(b, translate(vec2(250, 250)) * rotate(270 * PI.float32 / 180))
40+
a.draw(b, translate(vec2(250, 250)) * rotate(-270 * PI.float32 / 180))
4141
a.xray("tests/images/rotate270.png")
4242

4343
block:
@@ -47,7 +47,7 @@ block:
4747
a.fill(rgba(255, 0, 0, 255))
4848
b.fill(rgba(0, 255, 0, 255))
4949

50-
a.draw(b, translate(vec2(250, 250)) * rotate(360 * PI.float32 / 180))
50+
a.draw(b, translate(vec2(250, 250)) * rotate(-360 * PI.float32 / 180))
5151
a.xray("tests/images/rotate360.png")
5252

5353
block:
@@ -143,7 +143,7 @@ block:
143143
b = newImage(50, 50)
144144
a.fill(rgba(255, 255, 255, 255))
145145
b.fill(rgbx(0, 0, 0, 255))
146-
a.draw(b, translate(vec2(0, 50)) * rotate(45.toRadians))
146+
a.draw(b, translate(vec2(0, 50)) * rotate(-45.toRadians))
147147
a.xray("tests/images/masters/smooth2.png")
148148

149149
block:
@@ -170,7 +170,7 @@ block:
170170
b = newImage(10, 10)
171171
a.fill(rgba(255, 255, 255, 255))
172172
b.fill(rgbx(255, 0, 0, 255))
173-
let m = translate(vec2(50, 50)) * rotate(30.toRadians)
173+
let m = translate(vec2(50, 50)) * rotate(-30.toRadians)
174174
a.draw(b, m)
175175
a.xray("tests/images/masters/smooth5.png")
176176

@@ -179,7 +179,7 @@ block:
179179
a = newImage(100, 100)
180180
b = readImage(&"tests/images/turtle.png")
181181
a.fill(rgba(255, 255, 255, 255))
182-
let m = translate(vec2(50, 50)) * rotate(30.toRadians)
182+
let m = translate(vec2(50, 50)) * rotate(-30.toRadians)
183183
a.draw(b, m)
184184
a.xray("tests/images/masters/smooth6.png")
185185

@@ -188,7 +188,7 @@ block:
188188
a = newImage(100, 100)
189189
b = readImage(&"tests/images/turtle@10x.png")
190190
a.fill(rgba(255, 255, 255, 255))
191-
let m = translate(vec2(50, 50)) * rotate(30.toRadians) * scale(vec2(0.1, 0.1))
191+
let m = translate(vec2(50, 50)) * rotate(-30.toRadians) * scale(vec2(0.1, 0.1))
192192
a.draw(b, m)
193193
a.xray("tests/images/masters/smooth7.png")
194194

@@ -225,7 +225,7 @@ block:
225225
b = readImage(&"tests/images/turtle.png")
226226
a.fill(rgba(255, 255, 255, 255))
227227
let m = translate(vec2(-43.29, -103.87)) *
228-
rotate(-15.toRadians) *
228+
rotate(15.toRadians) *
229229
scale(vec2(263.86/40, 263.86/40))
230230
a.draw(b, m)
231231
a.xray("tests/images/masters/smooth11.png")
@@ -235,7 +235,7 @@ block:
235235
a = newImage(100, 100)
236236
b = readImage(&"tests/images/turtle.png")
237237
a.fill(rgba(255, 255, 255, 255))
238-
let m = translate(vec2(50, 50)) * rotate(-5.toRadians)
238+
let m = translate(vec2(50, 50)) * rotate(5.toRadians)
239239
a.draw(b, m * translate(vec2(0, 0)))
240240
a.draw(b, m * translate(vec2(-40, 0)))
241241
a.draw(b, m * translate(vec2(-40, -40)))

0 commit comments

Comments
 (0)