For this homework, I chose to work with generative text and produce a simple program that will output a poem of my choice in some chaotic fashion. The poem I chose ‘The night, the pharmacy, the street’ is one of quite famous poems in Russian by Alexander Blok, and it is one of very few I can fully recite in Russian. Personally, while this poem has a meaning, it always comes to my mind first when I think of something quite random in literature.
To select which words are going to be displayed in canvas, I use the following function. It first filters poem from double spaces and then randomly selects the first word to display as well as the last word.
function drawWords(x, y) { let corpus = poem.split(' ').filter(y => y!=""); let first_word = floor(random(corpus.length)); let last_word = first_word + random(2, 8); fill(255,233,0); text(corpus.slice(first_word, last_word).join(' ').trim(), x, y); }
The sketch of my final program is shown below:
I chose yellow and black to better match with the scene described: the street in the night with the bright lamppost. For future improvement, I would like to add more complexity to implementation and to make it more random. It feels chaotic as of now, but with addition of randomness in the position and more controlled randomness in the selection of words it should be more accurate in my vision. Also, I wanted to work on graphics a bit and add a lamp with options to turn on and off to match the theme. Overall, this was a fun experience with generative text and I hope future projects are going to be fun as well =)
Link: https://editor.p5js.org/ds6058/sketches/GHtAW9-XW
References:
https://sites.google.com/site/poetryandtranslations/alexander-blok/-the-night-the-pharmacy-the-street-a-blok
https://p5js.org/examples/typography-words.html