-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgenerateRepoImages.nim
68 lines (53 loc) · 1.93 KB
/
generateRepoImages.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This file just generates images used in the README and logo
import
"."/[QRgen, QRgen/renderer],
std/[os],
pkg/[pixie]
let qrL = newQR("https://github.com/aruZeta/QRgen")
let qrH = newQR("https://github.com/aruZeta/QRgen", ecLevel = qrECH)
func sharePath(p: string): string = "share" / "img" / p
func testsPath(p: string): string = "tests" / p
proc saveSvg(p: string, svg: string) = writeFile(sharePath p, svg)
proc savePng(p: string, img: Image) = writeFile(img, sharePath p)
## # Readme
## ## Svgs
saveSvg "svg-example.svg",qrL.printSvg()
saveSvg "svg-colors-example.svg",qrL.printSvg("#1d2021","#98971a")
saveSvg "svg-rounded-example.svg",qrL.printSvg("#1d2021","#98971a",60)
saveSvg "svg-very-rounded-example.svg",qrL.printSvg("#1d2021","#98971a",100,100)
saveSvg "svg-separation-example.svg",qrL.printSvg("#1d2021","#98971a",100,100,25)
saveSvg "svg-embed-example.svg",qrH.printSvg(
"#1d2021","#fabd2f",100,100,25,
svgImg=readFile(testsPath "testSvgInsert.svg")
)
## ## Pngs
savePng "png-example.png",qrL.renderImg()
savePng "png-colors-example.png",qrL.renderImg("#1d2021","#98971a")
savePng "png-rounded-example.png",qrL.renderImg("#1d2021","#98971a",60)
savePng "png-very-rounded-example.png",qrL.renderImg("#1d2021","#98971a",100,100)
savePng "png-separation-example.png",qrL.renderImg("#1d2021","#98971a",100,100,25)
savePng "png-embed-example.png",qrH.renderImg(
"#1d2021","#fabd2f",100,100,25,
img=readImage(testsPath "testPngInsert.png")
)
## # Logo
saveSvg "logo.svg", qrH.printSvg(
"#1d2021","#fabd2f",100,100,25,
svgImg=readFile(sharePath "logo-embed.svg")
)
let logoPng = qrH.renderImg(
"#1d2021","#fabd2f",100,100,25,
pixels=3840,
img=readImage(sharePath "logo-embed.png")
)
savePng "logo.png", logoPng
var logoPngExtended = newImage(1280, 640)
logoPngExtended.fill("#1d2021")
logoPngExtended.newContext.drawImage(
logoPng,
640f32 / 2,
0f32,
640f32,
640f32
)
savePng "logo-extended.png", logoPngExtended