Skip to content

Commit f8c4f2f

Browse files
committed
update and link to computational poetry tutorial
1 parent 409e08b commit f8c4f2f

2 files changed

Lines changed: 78 additions & 57 deletions

File tree

docs/tutorials/computational-poetry.md

Lines changed: 77 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In this tutorial, you'll learn how to create generative visual poetry using L5,
1010

1111
## Learning Objectives
1212

13-
By the end of this tutorial, students will be able to:
13+
By the end of this tutorial, students should be able to:
1414

1515
- Understand the basics of L5 and how it relates to p5.js/Processing
1616
- Draw text and shapes to the screen using code
@@ -19,59 +19,87 @@ By the end of this tutorial, students will be able to:
1919
- Build a grid-based layout system
2020
- Combine text, randomness, and interaction to create computational poetry
2121

22-
## Setup
22+
## What is L5?
23+
24+
L5 is a creative coding library that brings the simplicity and approachability of p5.js and Processing to the Lua programming language. If you've used p5.js or Processing before, you'll find L5 familiar - it uses the same basic structure with `setup()` and `draw()` functions, and similar function names for drawing shapes, working with color, and handling interaction.
25+
26+
L5 uses Lua syntax, which is known for being clean and beginner-friendly. Lua uses simple keywords like `function`, `end`, and `for` that make code easy to read.
27+
28+
L5 is heavily inspired by [permacomputing](https://permacomputing.net/), a growing movement responding to environmental and social conditions in computing. L5 is designed to be able to work on a wide variety of computers, to help prevent issues like needing to constantly upgrade, to work against "planned obsolescence", to consider constraints on consumption. The goal is for L5 to be a convivial tool that you can continue to use for years, with programs continuing to work long into the future.
29+
30+
While this is the goal, L5 is *alpha* software. The first version was released in December 2025. It has bugs, and does not fully implement all of Processing/p5. A number of people are working on the language to improve it.
31+
32+
## Installation
2333

2434
To get started with L5, you'll need to set it up on your computer:
2535

2636
- **Mac users:** [L5 Setup for Mac](https://l5lua.org/download/install-mac)
2737
- **Windows users:** [L5 Setup for Windows](https://l5lua.org/download/install-windows)
2838

29-
Once you have L5 installed, you're ready to begin.
39+
Next you need a code editor to write your code. If you already use a code editor, use the one you're familiar with. If you have never used a code editor on your own computer, you can pick one like Visual Studio Code, SublimeText, or a dedicated Lua IDE like ZeroBrane Studio.
40+
If you don't have any IDE installed on your computer you can even use your built-in plaintext editor TextEdit on macOS in plain text mode, or Notepad on Windows. But keep in mind they are barebones environments without additional features like syntax highlighting that make it easier to write code.
3041

31-
## What is L5?
42+
Once you have 1) Love2d installed 2) L5-Starter downloaded and unzipped 3) and you've tested launching Love2d and making sure you've given your computer approval to launch it, then you're ready to go.
3243

33-
L5 is a creative coding library that brings the simplicity and approachability of p5.js and Processing to the Lua programming language. If you've used p5.js or Processing before, you'll find L5 familiar - it uses the same basic structure with `setup()` and `draw()` functions, and similar function names for drawing shapes, working with color, and handling interaction.
34-
35-
The main difference is that L5 uses Lua syntax, which is known for being clean and beginner-friendly. Lua uses simple keywords like `function`, `end`, and `for` that make code easy to read.
44+
To test it all out: Try dragging **the folder** L5-Starter on top of the Love2d application file. It should launch and you should see a gold window appear. If it doesn't launch, you either didn't drag the folder or you need to give your computer permission to run an *un-signed application*, meaning that the developer didn't pay Apple to pre-approve this software (on macOS), or that you're giving Windows permission to run this downloaded program.
3645

3746
## Getting Started: Your First L5 Sketch
3847

39-
Every L5 sketch starts with requiring the library. Create a new file and type:
48+
Every L5 sketch starts with requiring the L5 library file, which you'll see in the first line. We can start by looking at the L5-Starter sketch. Inside the folder, open up the *main.lua* file.
49+
50+
You can open it in your favorite code editor like Visual Studio Code or SublimeText, or use the built-in Notepad on Windows or TextEdit on macOS.
4051

4152
```lua
42-
require 'L5'
53+
require("L5")
4354

4455
function setup()
45-
-- Your setup code goes here
56+
size(400, 400)
57+
58+
-- Set the program title
59+
windowTitle("Basic sketch")
60+
61+
describe('Draws a yellow background')
62+
end
63+
64+
function draw()
65+
-- Fills the background with the color yellow
66+
background(255, 215, 0)
4667
end
4768
```
4869

49-
The `setup()` function runs once when your program starts. This is where we'll put code that only needs to happen at the beginning.
70+
The `setup()` function runs once when your program starts. This is where we'll put code that only needs to happen at the beginning. `windowTitle()` specifies the nae for the title bar. `describe()` is an optional function for a text description of your program.
5071

51-
## Step 1: Drawing a Background
72+
The lines beginning with `--` are comments: notes to yourself or anyone reading your code, but they will be ignored by the compiler when you ask it to run your program.
5273

53-
Let's start by setting a background color. Add this inside your `setup()` function:
74+
## Step 1: Changing the Background
5475

55-
```lua
56-
require 'L5'
76+
Run your sketch by dragging and dropping the L5-starter folder on top of the Love application. You should see a window open and a golden yellow background.
77+
78+
Now let's go back to our code. Let's start by changing the background color. Modify the background inside your `draw()` function. You can use RGB values:
79+
Try changing `'gold'` to other colors like `'lightblue'`, `'pink'`, or `'lavender'`. You can use any of the [HTML Color Names](https://www.w3schools.com/colors/colors_names.asp), or RGB numbers like `background(255, 0, 255)` or hexadecimal: `background('#7FFFD4')`.
5780

58-
function setup()
59-
background('white')
60-
end
61-
```
6281

63-
Run your sketch. You should see a white canvas. Try changing `'white'` to other colors like `'lightblue'`, `'pink'`, or `'lavender'`. You can use any of the [HTML Color Names](https://www.w3schools.com/colors/colors_names.asp), or RGB numbers like `background(255, 0, 255)` or hexadecimal: `background('#7FFFD4')`.
82+
```lua
83+
background('purple')
84+
```
6485

6586
## Step 2: Drawing Basic Shapes
6687

6788
L5 can draw shapes just like p5.js. Let's add a circle:
6889

90+
Add this code inside your draw:
91+
6992
```lua
70-
require 'L5'
93+
fill('gold')
94+
circle(100, 100, 50)
95+
```
7196

72-
function setup()
73-
background('white')
74-
fill('black')
97+
So your draw() function should now look like:
98+
99+
```lua
100+
function draw()
101+
-- Fills the background with the color yellow
102+
fill('gold')
75103
circle(100, 100, 50)
76104
end
77105
```
@@ -83,16 +111,20 @@ Try drawing other shapes:
83111
- `ellipse(x, y, width, height)` - draws an ellipse
84112
- `line(x1, y1, x2, y2)` - draws a line
85113

114+
If you have any previous experience wih Processing or p5.js you should feel right at home.
115+
86116
## Step 3: Drawing Text on Screen
87117

88-
Now let's draw some text instead of shapes:
118+
**Let's remove our older code and replace it with this small program, where everything is written inside just the setup() function:**
119+
120+
We'll draw some text instead of shapes:
89121

90122
```lua
91-
require 'L5'
123+
require('L5')
92124

93125
function setup()
94-
background('white')
95-
fill('black')
126+
background('mintcream')
127+
fill('lawngreen')
96128
textSize(32)
97129
text('hello', 100, 100)
98130
end
@@ -111,7 +143,7 @@ Try changing:
111143
Instead of just one word, let's create a collection of words we can choose from. In Lua, we use curly braces `{}` to create arrays (called "tables" in Lua):
112144

113145
```lua
114-
require 'L5'
146+
require('L5')
115147

116148
words = {"eye", "nose", "mouth", "ear", "brain"}
117149

@@ -132,7 +164,7 @@ Try displaying different words by changing `words[1]` to `words[2]`, `words[3]`,
132164
Instead of always showing the same word, let's pick one randomly:
133165

134166
```lua
135-
require 'L5'
167+
require('L5')
136168

137169
words = {"eye", "nose", "mouth", "ear", "brain"}
138170

@@ -146,12 +178,14 @@ end
146178

147179
The `random()` function can pick a random item from an array when you pass it an array. Run your sketch multiple times - you should see different words!
148180

181+
Question: What would happen if this code was inside *draw()* instead of *setup()*, and how could you fix it?
182+
149183
## Step 6: Creating a Grid
150184

151185
Now we'll use loops to create a grid of positions where words could appear. We'll use two variables to control the grid spacing:
152186

153187
```lua
154-
require 'L5'
188+
require('L5')
155189

156190
words = {"eye", "nose", "mouth", "ear", "brain"}
157191

@@ -184,7 +218,7 @@ This creates a grid of words across your entire canvas.
184218
Right now we're showing a word at every grid position. Let's make it more interesting by only sometimes showing a word:
185219

186220
```lua
187-
require 'L5'
221+
require('L5')
188222

189223
words = {"eye", "nose", "mouth", "ear", "brain", "arm", "leg", "head", "foot"}
190224

@@ -219,7 +253,7 @@ Try changing `0.9` to different values:
219253
Let's make it so clicking the mouse regenerates the composition:
220254

221255
```lua
222-
require 'L5'
256+
require('L5')
223257

224258
words = {"eye", "nose", "mouth", "ear", "brain", "arm", "leg", "head", "foot"}
225259

@@ -265,29 +299,22 @@ Now that you have the basic structure, try customizing it:
265299

266300
5. **Add color:** Try `fill('red')` or use RGB values like `fill(255, 0, 0)`
267301

268-
## Extension Ideas
269-
270-
Ready to go further? Try these challenges:
302+
## Ways to extend
271303

272-
### Adding Animation
273-
274-
Instead of only drawing in `setup()`, you can use the `draw()` function to create continuous animation:
304+
* Incorporate animation in `draw()` to change your sketch over time
275305

276306
```lua
277307
function draw()
278-
background('white')
279-
-- your grid code here
308+
x = millis() / 5
309+
text(specialName, x, 200) -- Text will move to the right
280310
end
281311
```
282312

283-
This will create a constantly changing composition!
284-
285-
### Using Mouse Interaction
286-
287-
Make your composition respond to the mouse position:
313+
* Make your composition respond to the mouse position
288314

289315
```lua
290-
textSize(mouseX / 10) -- Text size changes with mouse X position
316+
-- Text size changes with mouse X position
317+
--textSize(mouseX / 10) -- Don't run this yet!
291318
```
292319

293320
This can cause freezing if mouseX is 0 at the beginning of the sketch, so we can constrain it to have a minimum value.
@@ -342,21 +369,14 @@ pop()
342369

343370
- **Generative:** Art or designs created by following a set of rules or algorithms, often involving randomness
344371
- **Computational Poetry:** Using code and algorithms to create, arrange, or manipulate text as a form of poetic expression
345-
- **Array/Table:** A collection of values stored together (in Lua, called a "table")
346-
- **Algorithm:** A set of step-by-step instructions to solve a problem or create something
372+
- **Array/Table:** A collection of values stored together. In most languages this is called an array. In Lua, we say it is an *ordered* table. Each item in the table has a number (an order), starting at 1.
347373
- **Parameter:** A value you pass into a function to customize how it works
348374
- **Random:** Unpredictable; choosing something without a pattern
349-
- **Grid:** A layout system based on evenly-spaced rows and columns
350375
- **Iteration:** Repeating a process multiple times (like in a loop)
351376

352377
## Going Further
353378

354-
Computational poetry is a rich field with many approaches. Research these artists and techniques:
355-
356-
- **Concrete poetry:** Poetry where the visual arrangement is as important as the words
357-
- **Blackout poetry:** Creating new poems by selectively revealing words from existing text
358-
- **Erasure poetry:** Similar to blackout poetry, removing words to create new meaning
359-
- **Artists to explore:** Allison Parrish, Nick Montfort, Lillian-Yvonne Bertram
379+
- **Artists to explore:** [Allison Parrish](https://www.decontextualize.com/), [Nick Montfort](https://nickm.com/), [Lillian-Yvonne Bertram](https://www.lillianyvonnebertram.com/)
360380
- **Online computational poetry:** [Taper](https://taper.badquar.to/), [The HTML Review](https://thehtml.review), [Random Walk](https://randomwalk.club/)
361381

362382
## Resources
@@ -367,7 +387,7 @@ Computational poetry is a rich field with many approaches. Research these artist
367387

368388
## Share Your Work!
369389

370-
Created something interesting? Share it with the [L5 category](https://discourse.processing.org/c/l5/29) on the Processing Discourse forum or with #L5 on social media. We'd love to see what you make.
390+
Created something interesting? Need help polishing your code? Check out the new [L5 category](https://discourse.processing.org/c/l5/29) on the Processing Discourse forum.
371391

372392
---
373393

docs/tutorials/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
## More tutorials
1919

20+
* [Computational Poetry with L5](computational-poetry.md) - A workshop tutorial created for [CCFest 2026](https://ccfest.rocks)
2021
* [Data Structure Garden](data-structure-garden.md) - Another tutorial on how to use objects and arrays
2122
* [Video](video.md) - An intro to video formats, and loading and playing videos with L5
2223

0 commit comments

Comments
 (0)