Skip to content

Commit 5344d5f

Browse files
committed
only write examples when we need them
1 parent 666d420 commit 5344d5f

File tree

14 files changed

+36
-24
lines changed

14 files changed

+36
-24
lines changed

examples/blur.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let
44
trees = readImage("examples/data/trees.png")
@@ -19,4 +19,4 @@ blur.draw(mask, blendMode = MaskBlend)
1919
image.draw(trees)
2020
image.draw(blur)
2121

22-
image.writeFile("examples/blur.png")
22+
image.writeFile(outputPath("blur.png"))

examples/common.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
3+
proc outputPath*(fileName: string): string =
4+
if paramCount() >= 1:
5+
result =
6+
if paramStr(1) == "--" and paramCount() >= 2:
7+
paramStr(2)
8+
else:
9+
paramStr(1)
10+
createDir(parentDir(result))
11+
else:
12+
result = "examples" / fileName

examples/gradient.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -26,4 +26,4 @@ image.fillPath(
2626
paint
2727
)
2828

29-
image.writeFile("examples/gradient.png")
29+
image.writeFile(outputPath("gradient.png"))

examples/heart.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -15,4 +15,4 @@ image.fillPath(
1515
parseHtmlColor("#FC427B").rgba
1616
)
1717

18-
image.writeFile("examples/heart.png")
18+
image.writeFile(outputPath("heart.png"))

examples/image_tiled.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -15,4 +15,4 @@ paint.image = readImage("examples/data/mandrill.png")
1515
paint.imageMat = scale(vec2(0.08, 0.08))
1616

1717
image.fillPath(path, paint)
18-
image.writeFile("examples/image_tiled.png")
18+
image.writeFile(outputPath("image_tiled.png"))

examples/line.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -13,4 +13,4 @@ let
1313

1414
ctx.strokeSegment(segment(start, stop))
1515

16-
image.writeFile("examples/line.png")
16+
image.writeFile(outputPath("line.png"))

examples/masking.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let
44
image = newImage(200, 200)
@@ -29,4 +29,4 @@ mask.fillPath(
2929
lines.draw(mask, blendMode = MaskBlend)
3030
image.draw(lines)
3131

32-
image.writeFile("examples/masking.png")
32+
image.writeFile(outputPath("masking.png"))

examples/rounded_rectangle.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -13,4 +13,4 @@ let
1313

1414
ctx.fillRoundedRect(rect(pos, wh), r)
1515

16-
image.writeFile("examples/rounded_rectangle.png")
16+
image.writeFile(outputPath("rounded_rectangle.png"))

examples/shadow.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -19,4 +19,4 @@ let shadow = polygonImage.shadow(
1919
image.draw(shadow)
2020
image.draw(polygonImage)
2121

22-
image.writeFile("examples/shadow.png")
22+
image.writeFile(outputPath("shadow.png"))

examples/square.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pixie
1+
import pixie, common
22

33
let image = newImage(200, 200)
44
image.fill(rgba(255, 255, 255, 255))
@@ -12,4 +12,4 @@ let
1212

1313
ctx.fillRect(rect(pos, wh))
1414

15-
image.writeFile("examples/square.png")
15+
image.writeFile(outputPath("square.png"))

0 commit comments

Comments
 (0)