pixie/tests/megatest.nim

35 lines
846 B
Nim
Raw Normal View History

2021-02-23 06:24:27 +00:00
import os, pixie, pixie/fileformats/svg, strformat
# Clone https://github.com/twbs/icons
# Check out commit f364cb14dfc0703b9e3ef10c8b490a71dfef1e9d
const
iconsPath = "../icons/icons/*"
width = 32
height = 32
var images: seq[(string, Image)]
for path in walkFiles(iconsPath):
let
(_, name, _) = splitFile(path)
image = decodeSvg(readFile(path), width, height)
images.add((name, image))
let
2021-02-23 06:31:55 +00:00
columns = 50
rows = (images.len + columns - 1) div columns
rendered = newImage((width + 4) * columns, (height + 4) * rows)
for i in 0 ..< rows:
for j in 0 ..< max(images.len - i * columns, 0):
let (_, icon) = images[i * columns + j]
rendered.draw(
icon,
vec2(((width + 4) * j + 2).float32, ((height + 4) * i + 2).float32),
bmOverwrite
)
rendered.writeFile(&"tests/images/svg/twbs-icons.png")