Pdraw - Generate Deterministic, Procedural Artwork from Arbitrary Text

Overview

pdraw.py: Generate Deterministic, Procedural Artwork from Arbitrary Text

pdraw allows users to generate line art from arbitrary text. It has no dependencies other than the Python standard library, and works with Python 3.10+ (3.7+ should work but are untested).

Demo

Thanks to Numberphile for the idea for this script.

Installation

Either copy the pdraw.py file or git clone the repository.

$ git clone [email protected]:Sonictherocketman/pdraw.git

Then simply run the script.

$ python3 pdraw.py -i a-file.txt [-e for arbitrary text]

IMPORTANT NOTICE: I have not confirmed this, but it looks like versions of Python installed via Homebrew are not suitable for this script as they do not come with the necessary tkinter libraries bundled in. I had to install Python direct from python.org

Testing

There are no tests. ¯_(ツ)_/¯

Usage Notes

Encoding Text as Base 10 Numbers

pdraw natively supports drawing strings of base 10 digits. However, pdraw can also sketch arbitrary text. To enable the drawing of arbitrary text, add the --encode flag to your command. This will instruct pdraw to first convert each character into its base 10 form (using a silly conversion that could probably be a lot more efficient).

Faster Drawing

pdraw is meant to be interactive, and so it renders its output fairly frequently. To speed up the drawing process, add the -r/--refresh-rate flag with a larger cycle count.

Changing Draw Distance & Angles

pdraw can also draw with arbitrary draw distances and angles to suit your needs. The -d/--distance flag allows you to set a distance multiplier for each line, and the -a/--angle flag allows you to set the rotation angle between each line. The default is 90 which draws squares. Use -a 60 for hexagons, -a 120 for triangles, and -a 160 for cool sharp ridges.

Saving Drawings

pdraw can save drawings as .eps files (which can be opened in Preview.app for macOS as well as other PDF viewers). Those files can then be converted to PNG/JPG/etc. Simply supply the -o/--output flag with a path to the desired file.

Optionally, you can close pdraw when your drawing is complete and saved by supplying the -c/--close flag.

Example Usage

Below are some quick recipes to get you started.

Drawing Digits of Pi (in hexagons)

You can download the first billion digits of Pi here and start plotting them. Make sure to give pdraw an iteration count though, otherwise it will attempt to draw the entirety of those billion digits, which would probably not work and take forever.

$ ./pdraw -i digits-of-pi.txt

pdraw

Note: pdraw also accepts an --offset parameter that tells pdraw how many bytes into the file to start reading. Use this to plot various sections of Pi (or other longer files)!

Drawing pdraw Itself!

Yup. pdraw can of course draw itself. Code is just text after all.

$ ./pdraw -i pdraw.py --encode

pdraw

Visualizing Song Lyrics

One thing I've been having fun with is graphing arbitrary song lyrics. I even printed some for family members of their favorite songs.

$ ./pdraw -i peaceful-easy-feeling.txt --encode -a 120

Peaceful Easy Feeling

Visualizing Randomness

pdraw can draw any digital data, and it can read from stdout! It cannot however deal with binary data, so you'll need to convert your random bytes into a string. Thankfully, we can do that easily on the command-line.

$ cat /dev/urandom | base64 | ./pdraw -n 5000 --encode

Note: Make sure to give pdraw an iteration count or it will draw forever!

About this Script

This script is based on a Numberphile Video about using procedural techniques to sketch the digits of Pi. Originally, I aimed to simply reproduce their work and play with the artwork I could generate from it. Eventually, that evolved into building a fully-fledged command-line application that could graph arbitrary digits, and since all data on a computer can be converted to numbers, I had effectively built a way to draw anything!

Thanks to Numberphile for putting out amazing videos and for inspiring me to write this script.

License

This script is available under the terms of the MIT License. See license.txt for more information.

Copyright © 2022 Brian Schrader

Owner
Brian Schrader
independent software developer, writer, musician, space enthusiast, hiker, coffee drinker, mac user
Brian Schrader
The presented desktop application was made to solve 1d schrodinger eqation

schrodinger_equation_1d_solver The presented desktop application was made to solve 1d schrodinger eqation. It implements Numerov's algorithm (step by

Artem Kashapov 2 Dec 29, 2021
Python package for handling and analyzing PSRFITS files

PyPulse A pure-Python package for handling and analyzing PSRFITS files. Read the documentation here. This is an alternate code base from PSRCHIVE. Req

Michael Lam 15 Nov 30, 2022
Python package that mirrors the original Nodejs ReplAPI-It.

Python-ReplAPI-It Python package that mirrors the original Nodejs ReplAPI-It. Contributing First fork the repo: $ git clone https://github.com/ReplAPI

The ReplAPI.it Project 10 Jun 05, 2022
Contain the customization I made for my Linux rice.

dotfiles Contain the customization I made for my Linux rice. Credit and Respect Polybar Autohide Fulltime Rofi by adi1090x (only include my personal r

sora 3 Apr 04, 2022
Python Osmium Examples

Python Osmium Examples This is a set (currently of size 1) of examples showing practical usage of PyOsmium, a thin wrapper around the osmium library.

Martijn van Exel 1 Jan 26, 2022
About Python's multithreading and GIL

About Python's multithreading and GIL

Souvik Ghosh 3 Mar 01, 2022
Serverless demo showing users how they can capture (and obfuscate) their Lambda payloads in Datadog APM

Serverless-capture-lambda-payload-demo Serverless demo showing users how they can capture (and obfuscate) their Lambda payloads in Datadog APM This wi

Datadog, Inc. 1 Nov 02, 2021
An end-to-end Python-based Infrastructure as Code framework for network automation and orchestration.

Nectl An end-to-end Python-based Infrastructure as Code framework for network automation and orchestration. Features Data modelling and validation. Da

Adam Kirchberger 15 Oct 14, 2022
WMIC Serial Checker For Python

WMIC Serial Checker Follow me here: Discord | Github FR: A but éducatif seulement. EN: For educational purposes only. ❓ Informations FR: WMIC Serial C

AkaTool's 0 Apr 25, 2022
Program Input Data Mahasiswa Oop

PROGRAM INPUT NILAI MAHASISWA MENGGUNAKAN OOP PENGERTIAN OOP object-oriented-programing/OOP adalah paradigma pemrograman berdasarkan konsep "objek", y

Maulana Reza Badrudin 1 Jan 05, 2022
Imitate Moulinette written in Python

Imitate Moulinette written in Python

Pumidol Leelerdsakulvong 2 Jul 26, 2022
This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator

Late-Bound Arguments This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator. Usage Mention the names of the argumen

Shakya Majumdar 0 Feb 06, 2022
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 1k Dec 16, 2022
Generate Gaussian 09 input files for the rotamers of an input compound.

Rotapy Purpose Generate Gaussian 09 input files for the rotamers of an input compound. Distance to the axis of rotation remains constant throughout th

1 Jul 16, 2021
Inacap - Programa para pasar las notas de inacap a una hoja de cálculo rápidamente.

Inacap Programa en python para obtener varios datos académicos desde inacap y subirlos directamente a una hoja de cálculo. Cómo funciona Primero que n

Gabriel Barrientos 0 Jul 28, 2022
ViberExport - Export messages from Viber messenger using viber.db file

📲 ViberExport Export messages from Viber messenger using viber.db file ⚡ Usage:

7 Nov 23, 2022
《practical python programming》的中文翻译

欢迎光临 大约 25 年前,当我第一次学习 Python 时,发现 Python 竟然可以被高效地应用到各种混乱的工作项目上,我立即被震惊了。15 年前,我自己也将这种乐趣教授给别人。教学的结果就是本课程——一门实用的学习 Python的课程。

编程人 125 Dec 17, 2022
Tethered downgrade 64-bit iDevices vulnerable to checkm8

ra1nstorm Tethered downgrade 64-bit iDevices vulnerable to checkm8 Since the purpose of this tool is to tethered downgrade a device, after restoring p

mini_exploit 65 Nov 08, 2022
OntoSeer is a tool to help users build better quality ontologies

Ontoseer This document provides documentation for the first version of OntoSeer.OntoSeer is a tool that monitors the ontology development process andp

Knowledgeable Computing and Reasoning Lab 9 Aug 15, 2022
App to get data from popular polish pages with job offers

Job board parser I written simple app to get me data from popular pages with job offers, because I wanted to knew immidietly if there is some new offe

0 Jan 04, 2022