Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Convert source code to cross stitch patterns

Project description

pyxstitch is an application (and associated library/compenents) that takes source code files and produces syntax-highlighted patterns for cross stitching.

See examples and completed cross stitch patterns here!

install

pip

Available via pip

pip install pyxstitch

source

  • Clone the source repo and…
python setup.py install

or

pip install .

or

pip install -e .

os packaging

os link
arch linux aur

usage

to run

pyxstitch --file program.py

styling

to see actual highlight colors on the pattern use --theme light-dmc and if using a high-contrast style you may want to toggle --theme dark (or --theme dark-dmc for colors on dark backgrounds).

the coloring styles are available as part of the pygments project but can be passed like so

pyxstitch --file program.py --style monokai

output

by default a png file is created matching the source code file name (e.g. hello.py -> hello.png), to change this

pyxstitch --file program.py --output image.png

or just pass a file type and type/cat into pyxstitch

cat test.py | pyxstitch --file .py --output myimage.png

by default, pyxstitch will attempt to create multiple pages for easier reading of large patterns, this can be modified via --multipage.

syntax/lexer

by default pyxstitch will use just a text lexer (no syntax) if piped/stdin is used, that can be changed, so

cat test.py | pyxstich

produces no highlighting but

cat test.py | pyxstitch --file .py
# or
cat test.py | pyxstitch --lexer autodetect
# or tell it which pygments lexer to use
cat test.py | pyxstitch --lexer python

fonts

to select a different font (from available)

pyxstitch --font <type-charset-size>

floss colors

colors can be remapped or disabled, e.g. to disable a color, set it to map to empty

pyxstitch --file test.c --map 000000=

or to map one color to another

pyxstitch --file test.c --map 000000=ffffff

advanced

some configuration options are available via the --kv input settings. Alternatively set these in a $HOME/.pyxstitch.config file to use different defaults always (unless a --kv is passed) or pass a --config and specify a different file than the one in $HOME

vim $HOME/.pyxstitch.config
---
# comments will be ignored
page_height=400
page_width=300

height

sets the default page height (600 default)

--kv page_height=500

width

sets the default page width (1000 default)

--kv page_width=900

padding

page padding (margins) which defaults to 50

--kv page_pad=100

index

on multipage will produce an html file (by default of 0) to group images into a pattern

--kv page_no_index=1

legend

default is 0, will print the legend to console (instead of to output image) when set to 1

--kv page_legend=1

height offset

default is 0, will change legend height placement on an image

--kv legend_hoff=10

width offset

default is 0, will change legend width placement on an image

--kv legend_woff=-5

font size

to adjust the font scaling for the legend when in the output

--kv page_font_size=100

zoom

you can zoom the pattern in by specifying the vertical and/or horizontal zoom start/end

pyxstitch --hszoom 20 --hezoom 30 --vszoom 10 --vezoom 40

will zoom the output to horizontal grid position 20 to 30 and vertical grid position 10 to 40

examples

there are example source code files and corresponding output pngs in the examples folder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyxstitch-1.7.10.tar.gz (35.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page