Week 4 Assignment – Khalifa Alshamsi

For this assignment, I drew my inspiration from the YouTube channel called “Short Coding Skills MoCCAモカ,” where he created a nice generative art style, but I could not understand the code he had.

A=97;
ATOZ=122-A+1;q=99;
draw=_=>{frameRate(10);
background(0,10);fill(200,0,0);
textSize(random(45));j=frameCount;
text(String.fromCharCode(j%30+A),noise(j)*q,noise(j+1)*q);         
         j= frameCount;text("*".repeat(ATOZ).split("").map((c,i)=>String.fromCharCode(i+A))[j%(ATOZ)],noise(j)*q,noise(j+1)*q)
}

So I took a shot at creating a similar feel to the one he made but instead it would say “STONKS,” because why not…

Sketch:

Description:

Randomized order of “STONKS”and random positioning where each selected letter is randomly displayed in different positions on the canvas.

Script:

let letters = "STONKS"; // Letters to be displayed
let displayDuration = 50; // How long to display each letter (in frames)
let nextChangeTime = 0; // When to change to the next letter

function setup() {
  createCanvas(640, 684);
  textSize(64);
  fill("grey"); // Set letter color to blue
  frameRate(60); // Set the frame rate
}

function draw() {
  if (frameCount >= nextChangeTime) {
    // Clear the background each time before displaying a new letter
    background(0);

    // Select a random letter from the string
    let letter = random(letters.split(""));
    
    // Pick a random position for the letter
    let x = random(width);
    let y = random(height);
    
    // Display the letter
    text(letter, x, y);
    
    // Set the time for the next change
    nextChangeTime = frameCount + displayDuration;
  }
}

Leave a Reply