An open API service indexing awesome lists of open source software.

https://github.com/adamspannbauer/quinep5js

A program that writes itself... artistically ✨🎨✨
https://github.com/adamspannbauer/quinep5js

generative-art p5js quine

Last synced: 7 months ago
JSON representation

A program that writes itself... artistically ✨🎨✨

Awesome Lists containing this project

README

          

# A Quine Design in p5js



From [Wikipedia]():

> A quine is a computer program which takes no input and produces a copy of its own source code as its only output. The standard terms for these programs in the computability theory and computer science literature are "self-replicating programs", "self-reproducing programs", and "self-copying programs".

This project's goal was to have a `sketch.js` file output itself to an html canvas. And as someone who uses the #generativeart tag on Instagram, I couldn't resist adding in some `noise()` to the output characters.

## How it works

To be upfront, I'm a javascript hobbyist ([my resume](https://docs.google.com/document/d/1Io4LEHVON8k9PaJNFVVoO_5M0CFdDCosaM-xzAp5MEQ/edit?usp=sharing) if you're hiring 👀), so I'm lacking some formal training. I'm not sure if I built the best way to do this, or if I jumped through some extra hoops. Regardless, I had fun and was able to learn about a very useful VSCode extension.

### Run on Save VSCode extension

The main workhorse of the whole process is found in [.vscode/settings.json](.vscode/settings.json). The [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) extension does the rest.

With the below configuration, everytime the file `sketch.js` is saved, a python script is run. This python script copys the contents of `sketch.js` to a string variable. This string is then read by `sketch.js` (i.e. it's reading itself).

```json
{
"emeraldwalk.runonsave": {
"commands": [
{
"match": "sketch.js",
"cmd": "./copyFileToVar.py"
}
]
}
}
```

### The p5js sketch

I won't comment too much on the sketch itself. The workhorse functions are all fairly documented (esp by side project standards).

Note some of the coding decisions in `sketch.js` were made for design reasons rather than best practices.