Home For Fiction – Blog

for thinking people


Programming

Book Worming Party: When Literature Meets Drawing

February 20, 2020

For the past couple of months I’ve been working on a rather ambitious project. Ambition is often misunderstood, but the way I choose to approach it, it’s about doing something “just because”. It was in this “fuck it” framework that Book Worming Party, my latest programming project came to being.

Book Worming Party – even the name should tell you how mad this project is – combines three of my interests: literature, visuality, and programming. What can I say, I’m a talented man (and above all, modest).

Book Worming Party is a program (written mostly in JavaScript) that takes a work of fiction and, based on calculations and interpretations it makes about its nature, turns it into semi-random visual art. It translates words into color, plot into shapes, genre into affect. There are no separate “kinds of art”; art is art.

book worming party
Here’s what Book Worming Party generated from Jane Austen’s Pride and Prejudice
(more…)

Making a Rhyming JavaScript Shakespearean Sonnet Mixer

January 13, 2020

My JavaScript iambic pentameter generator is among the most popular programming posts on Home for Fiction. It’s a really “alpha” piece of code which I haven’t worked on since I made that first version. But here’s a little something to compensate: let’s make a rhyming JavaScript Shakespearean sonnet mixer!

Unlike the iambic pentameter generator, this JavaScript Shakespearean sonnet mixer returns much more coherent results. After all, the code doesn’t need to generate any random text. It simply shuffles the Bard’s own production.

For a relevant project, also take a look at my poem shuffler.

To keep things simple, I decided to have it generate only two rhyming lines. The more the lines, the slower it would get – and the more likely it would not find any rhyming pairs.

JavaScript Shakespearean sonnet
To code or not to code?
(more…)

How to Make a JavaScript “Horoscope” Generator

November 10, 2019

Relax, I haven’t gone crazy. If you thought someone like me suddenly started believing in horoscopes, you’re wrong. Yes, in this post I’ll show you how to make a JavaScript horoscope generator. But the post is about linguistics, programming, and maybe psychology; not astrology.

If anything, my goal making this JavaScript horoscope generator was to show how ridiculously easy it is to produce accurate-seeming phrases that appear to apply to everyone’s individual situation. Simple answers to complex questions, really.

There’s actually a bit of literary background in this, believe it or not. There is a scene in my book The Other Side of Dreams, where the protagonist makes fun of a Tarot card reader:

Indeed, Ahmed thought, he could tell Anna pretty much everything the woman had said, without using any cards. “You are coming up a difficult fork in the road of your life, considering your options. Part of you would like to be more daring, but you are aware of the importance of being cautious. You are inspired by strong feelings, and you will be rewarded in love thanks to your tenacity. Remember to be true to yourself, although you should also be diplomatic, especially considering matters related to business, money, or agreements.” There, it can’t get any easier than that.

And so, I decided to combine my background in languages and my interest in programming. This JavaScript horoscope generator was the result!

JavaScript horoscope generator
I promise you, this JavaScript horoscope generator will not tell your fortune – because there is no such thing. Parenthetically, the code you see on the image is part of the actual code used in the program.
(more…)