simplepng

high level simple way to write PNGs

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License MIT
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Tags

Installation

nimble install simplepng
choosenim install simplepng
git clone https://github.com/jrenner/nim-simplepng

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
simplepng - - - - - - -

Source

Repository https://github.com/jrenner/nim-simplepng
Homepage https://github.com/jrenner/nim-simplepng
Documentation View Documentation
Registry Source nimble_official

README

nim-simplepng

Wrapper around nimpng for simple writing of PNG files

example

# create 600 width, 600 height image
var p = initPixels(600, 600)
# set it to all white, full alpha
p.fill(255, 255, 255, 255)
var n = 0
# use sin and cos to create a pattern for writing to the image
for pixel in p.mitems:
    n += 1
    let n1 = sin(n.float / 100.0)
    let r = (n1*100).uint8
    let n2 = cos(n.float / 50.0)
    let g = 0'u8
    let b = (n2*50).uint8
    let a = 255'u8
    # set RGBA values for this pixel
    pixel.setColor(r, g, b, a)



#for i, item in p.datatoString():
#echo "i: {i:>4}, item: {item.uint8:>3}".fmt
# save file to disk
simplePNG("/tmp/what.png", p)