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
Procscan is a quick and dirty python script used to look for potentially dangerous api call patterns in a Procmon PML file.

PROCSCAN Procscan is a quick and dirty python script used to look for potentially dangerous api call patterns in a Procmon PML file. Installation git

Daniel Santos 9 Sep 02, 2022
Powerful Assistant

Delta-Assistant Hi I'm Phoenix This project is a smart assistant This is the 1.0 version of this project I am currently working on the third version o

1 Nov 17, 2021
Un Assistente Vocale scritto in Python e altamente personalizzabile

Un Assistente Vocale scritto in Python e altamente personalizzabile

Marco 2 May 06, 2022
Simple Kahoot Botter.

Kahoot A simple Botter made in Python 3 for Kahoot.com. Also sorry for the shitty code lol. How to Run You need Python 3 installed on your device. Aft

7 Jun 29, 2022
Minitel 5 somewhat reverse-engineered

Minitel 5 The Minitel was a french dumb terminal with an embedded modem which had its Golden Age before the rise of Internet. Typically cubic, with an

cLx 10 Dec 28, 2022
1cak - An Indonesian web that provide lot of fun.

An unofficial API of 1cak.com 1cak - An Indonesian web that provide lot of fun. Endpoint Lol - 10 Recent stored posts on database Example: https://on

Dicky Mulia Fiqri 5 Sep 27, 2022
A Python program for calculating the 95%CI for GNSS-derived site velocities

GNSS_Vel_95%CI A Python program for calculating the 95%CI for GNSS-derived site velocities Function_GNSS_95CI.py is a Python function for calculating

<a href=[email protected]"> 4 Dec 16, 2022
With Christmas and New Year ahead, it is time for some festive coding. Here is a Christmas Card for you all!

Christmas Card With Christmas and New Year ahead, it is time for some festive coding! Here is a Christmas Card for you all! NOTE: I have not made this

CodeMaster7000 1 Dec 25, 2021
Slimbook Battery 4 is the new version with new features that improves battery control and increases battery duration in laptops.

Slimbookbattery Slimbook Battery 4 is the new version with new features that improves battery control and increases battery duration in laptops. This

SLIMBOOK TEAM 128 Dec 28, 2022
A web app for presenting my research in BEM(building energy model) simulation

BEM(building energy model)-SIM-APP The is a web app presenting my research in BEM(building energy model) calibration. You can play around with some pa

8 Sep 03, 2021
Object-oriented programming exercise session held in Petnica.

OOP vežba ⚠️ The code in this repo is used for a OOP practice session held in Petnica. All instructions in the README file are written in Serbian. Ops

Pavle Ćirić 1 Jan 30, 2022
Fork of pathlib aiming to support the full stdlib Python API.

pathlib2 Fork of pathlib aiming to support the full stdlib Python API. The old pathlib module on bitbucket is in bugfix-only mode. The goal of pathlib

Jazzband 73 Dec 23, 2022
Snack Rice - A Rice University servery finder, customized for your needs!

Snack Rice - A Rice University servery finder, customized for your needs!

Aidan Gerber 3 Sep 25, 2022
MinimalGearDisplay, Assetto Corsa app

MinimalGearDisplay MinimalGearDisplay, Assetto Corsa app. Just displays the current gear you are on. Download and Install To use this app, clone or do

1 Jan 10, 2022
北大选课网2021年春季验证码识别

北大选课网验证码识别 2021 年春季学期 Powered by Elector Quartet (@Rabbit, @xmcp, @SpiritedAwayCN, @gzz) 数据集描述 最初的数据集为 5130 张人工标记的验证码,之后利用早期训练好的模型在选课网上进行自动验证 (自举),又收集

Rabbit 27 Sep 17, 2022
This alerts you when the avalanche score a goal

This alerts you when the avalanche score a goal

Davis Burrill 1 Jan 15, 2022
ROS Foxy + Raspi + Adafruit BNO055

ROS Foxy + Raspi + Adafruit BNO055

Ar-Ray 3 Nov 04, 2022
Neogex is a human readable parser standard, being implemented in Python

Neogex (New Expressions) Parsing Standard Much like Regex, Neogex allows for string parsing and validation based on a set of requirements. Unlike Rege

Seamus Donnellan 1 Dec 17, 2021
Simple plug-and-play installer for users who want to LineageOS from stock firmware, or from another custom ROM.

LineageOS for the Teracube 2e Simple plug-and-play installer for users who want to LineageOS from stock firmware, or from another custom ROM. Dependen

Gagan Malvi 5 Mar 31, 2022
Class XII computer science project.

Computer Science Project — Class XII Kshitij Srivastava (XI – A) Introduction The aim of this project is to create a fully operational system for a me

Kshitij Srivastava 2 Jul 21, 2022