Week 4 - Generative Daily Project


This week, we were tasked with creating a sketch that will generate random daily content using seeds. John and I began working together before we saw the “…meaningful and compelling” portion of the assignment, HOWEVER, that is not to say that I am not pleased with what we’ve created here. The idea was to make something akin to one of those Buzzfeed personality quizzes with arbitrary character prescriptions and justifications for why you were assigned said character. This project in particular is designed to be as dumb as possible, as we were keen on making something that we would ultimately find even funnier a few years down the line. We’ve broken the stroke on our impact font, found ridiculous random images, and made up phrases that make no sense whatsoever. Though none of it is particularly impressive, I am very fond of making things like this–I do one of those nose exhalation laughs each time I open it.

STEP 1 - Where do we begin?

Our first class build consisted of us blitzing together a pretty dysfunctional build of our idea. We took code from the class examples and modified it to begin shaping up to what we envisioned. As you can see, it is not doing much of anything at all. Despite that, though, it was very helpful in providing the foundation for us to build our idea off of.

STEP 2 - FIX DAYSEED!

We were initially cycling through seed changes using a mouseClicked() function. While useful, it certainly wasn’t what was required of us. Thus, we tweaked our daySeed function to become this:

  daySeed = day() + month() * 31 + year() * 372;

month() * 31 - ensures that the months will not overlap with the day values.

year() * 372 - multiplies the current year by an arbitrary number (372) to create a gap between different years since 372 is larger than any day + month combination.

STEP 3 - Rookie Numbers

Ok. So our daySeed function works at this stage in the project. We just needed to pull those values. To accomplish this, we created the variables ‘selectedImage’ and ‘selectedQuote’ and wrote the following in setup:

function setup() {
  createCanvas(600, 600);
  daySeed = day() + month() * 31 + year() * 372;
  randomSeed(daySeed);
  selectedImage = gallery[floor(random(gallery.length))];
  selectedQuote = quotes[floor(random(quotes.length))];
  bgColor = color(random(255), random(255), random(255));
}

Let’s dissect how one of these assignments works. We’ll use selectedImage as an example.

gallery.length

This grabs the number of images in our gallery.

random(gallery.length)

This gives us a random decimal between 0 and gallery.length.

floor

This just rounds that number to the nearest whole number.

After all of that is calculated, that random number is then assigned to selectedImage and then later generated in draw(). This all works because we set randomSeed to daySeed–our random values will always remain the same for the current day.

STEP 4 - Cleanup Our code was performing nicely apart from some issues we had with text wrapping and repetitive generations. We spent quite some time troubleshooting but ultimately were able to create a final build absent of such issues. Here is a link to our completed sketch: https://editor.p5js.org/flemin/sketches/MIsdWEUpf

Thanks for reading!

Get Drawing, Moving and Seeing with Code - Spring 2025

Comments

Log in with itch.io to leave a comment.

Hey! just a suggestion from our work in class today, to try this out for the random seed generation. See if this produces more varied output!

daySeed = int(day()+""+year()+""+month());

Just wanted to give credit to rafi.pdf for the idea.