pix : 2D graphics library

Whatpix
Wherehttps://github.com/nico-robert/pix
DescriptionTcl/Tk wrapper around Pixie , a full-featured 2D graphics library written in Nim .
LicenseMIT License

https://wsrv.nl/?url=raw.githubusercontent.com/nico-robert/pix/master/docs/assets/pix.png&w=650

Compatibility :

  • Tcl/Tk 8.6 or higher.

Platforms :

  • MacOS (x64 / arm64)
  • Windows x64
  • Linux x64

Source distributions and binary packages can be downloaded here for the platforms mentioned above.

Note: I have mainly tested this package on Windows and MacOs x64 with version 8.6.16 and 9.0.3 of Tcl/Tk, it should work on Linux and MacOS arm (I hope so!)

Example :

package require pix

# Init 'context' with size + color.
set ctx [pix::ctx::new {200 200} "white"]

# Style first rectangle.
pix::ctx::fillStyle $ctx "rgb(0, 0, 255)"       ;# blue color
pix::ctx::fillRect $ctx {10 10} {100 100}

# Style second rectangle.
pix::ctx::fillStyle $ctx "rgba(255, 0, 0, 0.5)" ;# red color with alpha 50%
pix::ctx::fillRect $ctx {50 50} {100 100}

# Save context in a image file (*.png|*.bmp|*.qoi|*.ppm)
pix::ctx::writeFile $ctx rectangle.png

# Or display in label by example :
set p [image create photo]
pix::drawSurface $ctx $p
label .l -image $p
pack .l

See documentation examples for more demos.

Documentation :

A large part of the pix documentation comes from the Pixie API and source files.


Currently API tested and supported are :

API
contextThis namespace provides a 2D API commonly used on the web.
fontThis namespace allows you to write text, load fonts.
imageCrop, resize, blur image and much more.
paintThis namespace plays with colors.
pathsVector paths.
svgParse, render SVG (namespace pretty limited)

Note : Since version 0.8, if available, resvg is used to render SVG files in the pix::svg namespace.

Acknowledgments :

Changes :