Week 8 – Reading response

Attractive things work better

This reading talked about how people tend to ignore some usability flaws if the design of the object is visually appealing. I found this very interesting as I have never though of design to be such a powerful tool. And the craziest part about this reading was that it made me realize we all do it without thinking about it. For example, me personally, and I believe many of people reading this tend to grab an article which packaging looks better when buying stuff. For some reason, better looking packaging and elegant design is either associated with good quality or we just tend to look past quality flaws because of the nice design.  This opened my eyes on the world of design and made me realize its importance, in the future I will try to give more importance to good design into my projects.

Her code got humans on the moon

Reading about Margaret Hamilton’s contributions to the Apollo missions really opened my eyes to how fundamental her work was, not just for the success of the Moon landing, but for the very concept of software engineering as we know it today. I had heard her name before, but I didn’t realize the extent of her leadership or how groundbreaking her work was in an era when software development wasn’t even taken seriously as an engineering field. What especially struck me was how she was thinking ahead, not just about what the computer should do, but about how humans might make mistakes and how the system should respond. When the exact scenario she predicted actually happened, it was her forward-thinking code that saved the mission. That moment really highlighted how her ideas were undervalued, not because they were wrong, but because of assumptions about who gets to be “right” in technical spaces.

Week 8 – Creative Switch

Concept

I was thinking about how I could create an unusual and creative switch and also make it fun to use. The one thing that came to mind was the game “Just Dance” in which the user has to step on the correct tile that they see on the screen to simulate dance moves and make the in-game character dance. Due to the time constraint I wasn’t able to create a fully working game, but this is a good start with the hardware part of it mostly done.

How it works and demo

Instead of using the classic button switch, I connected jumper cables to aluminum foils and put sponges between the foils so when they are pressed or in this case stepped on they will detect a signal and light the LEDs.

Here is a short demo of the project:

As for the code, it wasn’t too hard to work on. I found the Serial.println very useful in debugging and testing in general. The hardest part for this project was making all the connections with the wires as the breadboard is small and the cables kept getting into the way of one another so I think I will need to work on my cable management more in the future.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// read the input pin:
int buttonState1 = digitalRead(pushButton1);
int buttonState2 = digitalRead(pushButton2);
int buttonState3 = digitalRead(pushButton3);
int buttonState4 = digitalRead(pushButton4);
// print out the state of the connection:
Serial.println(buttonState1);
Serial.println(buttonState2);
Serial.println(buttonState3);
Serial.println(buttonState4);
// read the input pin: int buttonState1 = digitalRead(pushButton1); int buttonState2 = digitalRead(pushButton2); int buttonState3 = digitalRead(pushButton3); int buttonState4 = digitalRead(pushButton4); // print out the state of the connection: Serial.println(buttonState1); Serial.println(buttonState2); Serial.println(buttonState3); Serial.println(buttonState4);
// read the input pin:
int buttonState1 = digitalRead(pushButton1);
int buttonState2 = digitalRead(pushButton2);
int buttonState3 = digitalRead(pushButton3);
int buttonState4 = digitalRead(pushButton4);

// print out the state of the connection:
Serial.println(buttonState1);
Serial.println(buttonState2);
Serial.println(buttonState3);
Serial.println(buttonState4);

I am particularly proud of how the code was clean and well readable in the end even with so many different pins and commands.

Future improvements

In the future I plan to make a full game out of this project and to make a homemade “Just Dance” video game. I also hope to work on cable management a bit more so the board looks a bit more presentable and maybe also switch the sponges for some other material as they haven’t proven to be the most reliable. Overall this was an amazing learning opportunity as well as a very fun project to work on!

Midterm Project – Traffic Dash

Concept

The main idea was to create a fun, fast paced game which would be very fun and challenging at the same time. The game is in the “endless runner” genre of games (if you can avoid traffic for that long) where the main objective is to survive as long as possible and collect as many coins as you can therefor raising your score.

The game was inspired by other popular endless runner games such as “Subway Surfers” but with a progressive difficulty curve to make the game more difficult. The game also has some strategizing as sometimes the coins can lead you into a trap with no way out and a quick game over!

What are you waiting for, click here and try to dash through the traffic!

How the game works and code parts I am proud of

The game, of course, starts with an instructions screen where the player is asked to press enter to begin the game. As the game starts the player can see that the left and the right arrows control the movement of the car on the bottom of the screen. After a bit cars start spawning on top of the screen, randomly, but on carefully selected coordinates to ensure they don’t spawn off the screen or off the road (some traffic laws can’t be broken).

The player then sees coins appearing also randomly, but moving slower than the cars to ensure the user can pick them up safely. The user needs to decide if it is safe enough to move left or right to collect the coin and be sure to have enough time to move away from oncoming traffic.

Even though the goal is to collect as many coins as possible, as the game progresses, and the player is collecting coins and making their score higher, the speed of the oncoming traffic increases making the game much more difficult, but also making the distance values move faster which can make the survival more rewarding for the high score. The speed of the traffic is maxed at 25 so the game doesn’t become unplayable.

When the user eventually hits the oncoming traffic, they are met with a game over screen displaying the score they achieved in the last run with the text asking the user to press enter if they want to retry and beat the last score.

I am very proud with the collision detection system, which in the beginning did face some challenges (will talk more about it later in the documentation) but now works perfectly!

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Handling collision detection
function checkCollisions() {
for (let t of trafficCars) {
if (
car.x < t.x + t.w &&
car.x + car.w > t.x &&
car.y < t.y + t.h &&
car.y + car.h > t.y
) {
// print("Collision with traffic!");
crash.play();
game_over = true;
displayGameOverScreen();
noLoop();
}
}
if (
car.x < coin.x + coin.w &&
car.x + car.w > coin.x &&
car.y < coin.y + coin.h &&
car.y + car.h > coin.y
) {
// print("Coin collected!");
coin_collect.setVolume(0.3);
coin_collect.play();
score += 1;
coin.y = random(-300, 0);
coin.x = random(coin_spawn_points);
}
}
//Handling collision detection function checkCollisions() { for (let t of trafficCars) { if ( car.x < t.x + t.w && car.x + car.w > t.x && car.y < t.y + t.h && car.y + car.h > t.y ) { // print("Collision with traffic!"); crash.play(); game_over = true; displayGameOverScreen(); noLoop(); } } if ( car.x < coin.x + coin.w && car.x + car.w > coin.x && car.y < coin.y + coin.h && car.y + car.h > coin.y ) { // print("Coin collected!"); coin_collect.setVolume(0.3); coin_collect.play(); score += 1; coin.y = random(-300, 0); coin.x = random(coin_spawn_points); } }
//Handling collision detection
function checkCollisions() {
  for (let t of trafficCars) {
    if (
      car.x < t.x + t.w &&
      car.x + car.w > t.x &&
      car.y < t.y + t.h &&
      car.y + car.h > t.y
    ) {
      // print("Collision with traffic!");
      crash.play();
      game_over = true;
      displayGameOverScreen();
      noLoop();
    }
  }

  if (
    car.x < coin.x + coin.w &&
    car.x + car.w > coin.x &&
    car.y < coin.y + coin.h &&
    car.y + car.h > coin.y
  ) {
    // print("Coin collected!");
    coin_collect.setVolume(0.3);
    coin_collect.play();
    score += 1;
    coin.y = random(-300, 0);
    coin.x = random(coin_spawn_points);
  }
}

I am also very proud of the speed increase with the score increase which also makes the distance value rise faster.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Making the game faster as the score goes up
function increaseDifficulty() {
let speedIncrease = min(20, 7 + score * 0.5);
for (let t of trafficCars) {
t.vy = speedIncrease;
}
coin.vy = speedIncrease - 0.5;
// Adjust distance increase interval based on speed
distanceUpdateInterval = max(50, 100 - speedIncrease * 50);
// print(speedIncrease);
}
//Making the game faster as the score goes up function increaseDifficulty() { let speedIncrease = min(20, 7 + score * 0.5); for (let t of trafficCars) { t.vy = speedIncrease; } coin.vy = speedIncrease - 0.5; // Adjust distance increase interval based on speed distanceUpdateInterval = max(50, 100 - speedIncrease * 50); // print(speedIncrease); }
//Making the game faster as the score goes up
function increaseDifficulty() {
  let speedIncrease = min(20, 7 + score * 0.5);
  for (let t of trafficCars) {
    t.vy = speedIncrease;
  }
  coin.vy = speedIncrease - 0.5;

  // Adjust distance increase interval based on speed
  distanceUpdateInterval = max(50, 100 - speedIncrease * 50);
  // print(speedIncrease); 
}

This part took some testing, that is why I left the print statement there to show how I tested the code and the logic of the game.

Problems faced along the way

Unfortunately, like every code ever written, it didn’t come without hardship. The beginning was smooth sailing as I started with simple shapes and just implementing simple game logic.

This was a great start and I was happy with the progress I was making.

The first problem, though, arose when I started uploading photos to use for objects in the game.

This is the image that I used for the player object. I used a PNG file to have the transparent background so it only looks like the car is on the screen. Now, at first I thought this would work perfectly and that I wouldn’t have any issues to deal with, but would quickly learn otherwise. The issue was the collision detection which happened even if in theory there was enough distance between cars.

Why is this? Well even though we don’t see the transparent background of the PNG, it is still there and the collision detection algorithm detects it as a part of the car object. To fix this I used a built in image function which cropped the unnecessary parts of the image.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
car = new Car(160, 300, 50, 100);
for (let i = 0; i < traffic_number; i++) {
trafficCars.push(
new Traffic(random(traffic_spawn_points), random(-500, 0), 65, 115)
);
}
car = new Car(160, 300, 50, 100); for (let i = 0; i < traffic_number; i++) { trafficCars.push( new Traffic(random(traffic_spawn_points), random(-500, 0), 65, 115) ); }
car = new Car(160, 300, 50, 100);

for (let i = 0; i < traffic_number; i++) {
  trafficCars.push(
    new Traffic(random(traffic_spawn_points), random(-500, 0), 65, 115)
  );
}

(The 3rd and 4th values of the functions)

Other issue I faced was with the file loading system, or specifically, writing in the csv file to make the game keep track of the highest score of a player.

My vision was to collect  all the scores of all the players who have every played and display the best, but I later learned that due to security reasons the p5js editor does not allow writing in files and has a read-only access to all the files uploaded. I decided to still keep the file and just display some high score to encourage players to try to beat it. Maybe in the future I could use google docs with their API to help me write in them, but due to the time constraint this will have to do for now.

There is also an issue with the objects sometimes spawning in one another. Fixing this would require changing the whole spawning logic and is unfortunately not possible in the short time span, but is definitely something that can be fixed in the future.

Future improvements and final thoughts

In the future I would love to work on this game even more and polish it to make it perfect. I would like to add some animations for crashes and maybe driving and would love to add power ups to spice up the gameplay. Unfortunately due to time constraints these implementations were not possible for this submission, but I think would be a fun addition to have in the future.

Overall I am happy with how the game turned out. In the beginning the game seemed like a big workload and a heavy task I set upon myself, but as I got to work on it more I got to work with everything we were taught in class and I really started to love the game and the experience of coding it.

This project has not been just a great learning opportunity, but has also inspired me to work on more different projects and become better at creating games. I will definitely be working on this project more and refining it to perfection.

Thank you for reading the documentation!

 

Week 5 – Reading Response

Computer vision differs from human vision in many ways. One of the key differences would be that human vision is naturally adaptive to differences in lighting and can naturally understand objects, track motion and use context to recognize different emotions and patterns. On the other hand computer vision heavily relies on mathematical algorithms do detect objects and track movement. Difference in lighting usually causes computer vision to break or not work properly and it is generally impossible for computers to understand context without the use of advanced ai.

There are several ways with which we can help the computer “see” and track what we want it to track. One of the ways is frame comparing, where we tell the computer to compare consecutive frames and with that detect changes which indicate movement. To further improve this concept we could also use background extraction techniques which help us isolate the objects we want to track or see and ignore everything that is in the background.

Computer vision has a wide potential use in interactive media. Many artists have used it to create amazing interactive art which in my opinion feels more interactive then just clicking buttons. Artist use computer vision to create playful interactive experiences which fully immerse the user who feels in complete control of the movement of the object. I believe in the future in combination with ai, computer vision will completely take over in the interactive media industry.

Week 5 – Midterm Progress

Concept

I was thinking for a while of a good midterm project that would combine everything we have been taught so far and would be also fun to make and even more fun to play/experience. I came up with an arcade style game that combines the fast paced racing games I used to play as a kid to the fun and popular endless runners like “Subway Surfers”. I am making a game where the player controls car movement left and right to avoid oncoming traffic and collect coins. The more the game progresses and the more coins the user collects, the game becomes faster and therefor harder making it a fun challenge for everyone.

User interactions
  • Arrow keys to move the car left and right, allowing for quick and responsive controls
  • Randomly positioned traffic that appears on the screen, requiring strategic movement to avoid collision
  • Randomly appearing coins that the player collects to increase their score, encouraging risk-taking and precise movement
  • A progressively challenging difficulty curve where traffic increases in speed and density over time
  • Game over state when the player collides with traffic, prompting a restart option to try again and improve their score
Code design

I have structured my code using object oriented programming with the following classes:

Car – Represents the player’s car and handles movement

Traffic – Represents the incoming traffic and resets to random position when it moves off screen

Coins – Represents collectable coins that appear at random positions when collected

Additionally the game includes:

Score system

Collision detection system

Car class:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Car {
constructor(x, y, w, h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
display() {
fill(0, 0, 255);
rect(this.x, this.y, this.w, this.h);
}
move() {
if (keyCode === LEFT_ARROW && this.x > 100) {
this.x -= 50;
} else if (keyCode === RIGHT_ARROW && this.x < 400) {
this.x += 50;
}
}
}
class Car { constructor(x, y, w, h) { this.x = x; this.y = y; this.w = w; this.h = h; } display() { fill(0, 0, 255); rect(this.x, this.y, this.w, this.h); } move() { if (keyCode === LEFT_ARROW && this.x > 100) { this.x -= 50; } else if (keyCode === RIGHT_ARROW && this.x < 400) { this.x += 50; } } }
class Car {
    constructor(x, y, w, h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }
    display() {
        fill(0, 0, 255);
        rect(this.x, this.y, this.w, this.h);
    }
    move() {
        if (keyCode === LEFT_ARROW && this.x > 100) {
            this.x -= 50;
        } else if (keyCode === RIGHT_ARROW && this.x < 400) {
            this.x += 50;
        }
    }
}

Collision detection:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
if (car.x < traffic.x + traffic.w &&
car.x + car.w > traffic.x &&
car.y < traffic.y + traffic.h &&
car.y + car.h > traffic.y) {
console.log("Collision with traffic!");
noLoop();
}
if (car.x < traffic.x + traffic.w && car.x + car.w > traffic.x && car.y < traffic.y + traffic.h && car.y + car.h > traffic.y) { console.log("Collision with traffic!"); noLoop(); }
if (car.x < traffic.x + traffic.w &&
    car.x + car.w > traffic.x &&
    car.y < traffic.y + traffic.h &&
    car.y + car.h > traffic.y) {
    console.log("Collision with traffic!");
    noLoop();
}

Currently I have the car and the traffic as simple p5 box objects while I set everything up, but will change them to images as I work on the project.

Challenges and Risks

The most complex part of the project so far was implementing collision detection and ensuring objects reset properly. This was essential for making the game playable and preventing unfair conditions where the player could not avoid obstacles. I have dealt with this challenge already, but I am thinking of implementing a power up system into the game which might bring a completely new set of challenges with it.

Next steps

While the core mechanics have already been implemented there is still work to be done such as:

Add game sound

Improve the visuals

Add high score tracking

Possible implementation of power up system

 

So far this project has been a great learning experience, I am looking forward to work on it even more and refine it further!

Reading Reflection – Week 4

One of the things that frustrates me a lot and is not mentioned in the reading are the air blowers found in public bathrooms. As you might now some of the malls or other public bathrooms for some reason decide to put air blowers instead of paper towels for drying hands. In most cases these blowers can’t detect when we place our hands under and we are left there standing next to to the machine going forwards and backwards with our hands like we are doing some stupid dance choreography. Not to mention how some bathrooms have very strong blowers which will dry my hands faster, but I will go out with a wet shirt. Papers are towels are easier to use, straight forward and do the job much quicker and better than the blowing machines.

In order to avoid my design being hard or unpleasant to use I will apply the following principals to my design. I will make the buttons look clickable and the links underlined or colored differently so it is obvious to the user that button or link is intended for clicking. I will make sure that the user gets immediate response to their interaction of any part of the design and I will place buttons and other interactive objects in places where it makes sense. No hidden menus or buttons which are weirdly colored or hidden so they are barely visible. Some websites don’t do the color matching correctly so the links look like every other word in the sentence and is hard to determine on what to click, I will make sure I don’t do such thing.

Week 4: Data Visualization

Concept

I was going through Kaggle, looking at interesting datasets that I could use to visualize some data. I stumbled upon a dataset about “IMDB Top 250 Movies Dataset” and decided to give it a look. After looking through the dataset I became interested to how the budget the movie had initially gotten corelates to the Box-office revenue it received so I decided to make a graph using that data and present it using p5js.

The project might have a simple look, but I believe the data that it shows and the results are quite interesting.

Process

For the process I first looked at the dataset on my computer, trying to find interesting data that I could present visually. After finding the budget and the box office values I then loaded them into the p5js and first printed a few values just to see if the dataset works. Then came the process of actually pulling all the data and plotting it on the preview. This process was a bit tricky as I had to play around with the map function to understand it completely and make the graph look how it should. I am proud of the way I found mins and maxes and the way I mapped them.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Getting the minimums and maximums, by pulling only the budget or only the boxOffice data
let minBudget = min(movieData.map((m) => m.budget));
let maxBudget = max(movieData.map((m) => m.budget));
let minBoxOffice = min(movieData.map((m) => m.boxOffice));
let maxBoxOffice = max(movieData.map((m) => m.boxOffice));
//Maping and placing the data
for (let movie of movieData) {
let x = map(movie.budget, minBudget, maxBudget, 50, width - 50);
let y = map(movie.boxOffice, minBoxOffice, maxBoxOffice, height - 50, 50);
fill(0, 255, 0);
ellipse(x, y, 5, 5);
}
// Getting the minimums and maximums, by pulling only the budget or only the boxOffice data let minBudget = min(movieData.map((m) => m.budget)); let maxBudget = max(movieData.map((m) => m.budget)); let minBoxOffice = min(movieData.map((m) => m.boxOffice)); let maxBoxOffice = max(movieData.map((m) => m.boxOffice)); //Maping and placing the data for (let movie of movieData) { let x = map(movie.budget, minBudget, maxBudget, 50, width - 50); let y = map(movie.boxOffice, minBoxOffice, maxBoxOffice, height - 50, 50); fill(0, 255, 0); ellipse(x, y, 5, 5); }
// Getting the minimums and maximums, by pulling only the budget or only the boxOffice data
let minBudget = min(movieData.map((m) => m.budget));
let maxBudget = max(movieData.map((m) => m.budget));
let minBoxOffice = min(movieData.map((m) => m.boxOffice));
let maxBoxOffice = max(movieData.map((m) => m.boxOffice));

//Maping and placing the data
for (let movie of movieData) {
  let x = map(movie.budget, minBudget, maxBudget, 50, width - 50);
  let y = map(movie.boxOffice, minBoxOffice, maxBoxOffice, height - 50, 50);
  fill(0, 255, 0);
  ellipse(x, y, 5, 5);
}
Reflection and Future improvements

For the future improvements I would maybe want to find a bigger dataset and try to plot more movies into the existing one and see what the difference it makes. Maybe I could also incorporate allowing user to tweak what other “filters” are present to see what maybe affects the budget to box office revenue difference in movies. Overall I found this project very interesting and challenging, but at the same time tons of fun!

Reading Reflection – Week 3

What do you consider to be the characteristics of a strongly interactive system?

A strongly interactive system, as suggested from the reading, would be one that would be actively involved in communication with us. I agree with the authors suggestions about certain forms of media thought to be interactive are not. The author presented a good example about movies which seem to be interactive to some people, but in reality whatever we do, we can not change the outcome or decisions of the actions in the movie. Same would go for something like videogames which we would think is the most interactive media. I believe that in games, even if they allow us to make decisions and even if our decision change certain outcomes, we will still end up with one of the selected endings which have been previously scripted. I think right now the strongest interactivity could be our conversations with chatbot ais, like ChatGPT which is capable of not only having an active conversation with us, but also thinking about its answers.

What ideas do you have for improving the degree of user interaction in your p5 sketches?

It would be really hard to implement complete interactivity such as one I mentioned in the previous text. But one way I could improve the interactivity is by making the program in such way that users decision will lead to some outcome which is random and not predictable even by me. I don’t think complete interactivity can be achieved, but I believe there can be made an illusion of complete interactivity with some randomness put into the outcome of users decisions.

Week 3: Generative Art

Concept

For the concept I was inspired by jellyfish and their movement in the wild. I tried to recreate their look with glowing circles to make the piece more aesthetic. Their movement is random, yet smooth, simulating real life movement but they also leave marks behind their movement for the overall look of the project.

Process

I started by just creating a class for the “creatures”, this included their initial positioning and their size. I then started implementing the movement, which was not that hard with the use of object oriented programming. For the movement, I wanted it to be random and smooth also so I used the noise function of p5js to achieve this. I then created a glowing feel to the creatures and also wanted to make them change colors smoothly and randomly similar to the movement. This proved to be a little bit difficult as noise function only returns 0 and 1 and I kept getting just the black color. To overcome this I had to use sin and cos functions which would keep the values between -1 and 1 and with some math achieve the wanted effect.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//useing the sin and cos which only return 1 or -1 to keep the values under 255
let r = 100 + 155 * sin(frameCount * 0.01 + this.noiseOffset);
let g = 50 + 150 * cos(frameCount * 0.01 + this.noiseOffset);
let b = 150 + 105 * sin(frameCount * 0.02 + this.noiseOffset);
//create a glowing effect
noStroke();
fill(r, g, b, 30);
ellipse(0, 0, this.size * 1.5, this.size * 1.5);
//useing the sin and cos which only return 1 or -1 to keep the values under 255 let r = 100 + 155 * sin(frameCount * 0.01 + this.noiseOffset); let g = 50 + 150 * cos(frameCount * 0.01 + this.noiseOffset); let b = 150 + 105 * sin(frameCount * 0.02 + this.noiseOffset); //create a glowing effect noStroke(); fill(r, g, b, 30); ellipse(0, 0, this.size * 1.5, this.size * 1.5);
//useing the sin and cos which only return 1 or -1 to keep the values under 255
let r = 100 + 155 * sin(frameCount * 0.01 + this.noiseOffset);
let g = 50 + 150 * cos(frameCount * 0.01 + this.noiseOffset);
let b = 150 + 105 * sin(frameCount * 0.02 + this.noiseOffset);

//create a glowing effect
noStroke();
fill(r, g, b, 30);
ellipse(0, 0, this.size * 1.5, this.size * 1.5);
Reflection and future improvements

It was fun to use object oriented programming in p5js. It proved to not be that difficult and made the overall project making experience easier. After some time the creatures leave the screen which could be interpreted as a feature and not a bug as they are being scared away from us looking at them. In the future I would maybe like to implement some interaction with the mouse, maybe they either group around the mouse or stay away from it. Overall a great learning experience!

Week 2 – Graphic Art

Concept

Inspired by the “Computer Graphics and Art” magazine which was linked in the assignment, I wanted to create an art piece which  used shapes of random sizes and colors to create an abstract, seemingly chaotic art. Given that the magazine was written in 1977 it was all in black an white, so I decided to modernize it a bit by adding different random colors to the design therefor making it even more aesthetically pleasing.

Process

When I started this project I wanted to place shapes with random attributes in random positions to create artwork. My plan was for the user to run the program and each time get a completely different result which represents a whole new piece of art. I also didn’t want to stick to just one object so I decided to add lines alongside ellipses for a better visual effect. It was a bit challenging at first putting the lines somewhat correct positions as I also wanted to introduce randomness. But with some tweaking and work I managed to create something that I find satisfying.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let numLines = random(3, 10);
for (let j = 0; j < numLines; j++) {
let x2 = x + random(-s, s);
let y2 = y + random(-s, s);
stroke(r, g, b);
line(x, y, x2, y2);
}
let numLines = random(3, 10); for (let j = 0; j < numLines; j++) { let x2 = x + random(-s, s); let y2 = y + random(-s, s); stroke(r, g, b); line(x, y, x2, y2); }
let numLines = random(3, 10);

for (let j = 0; j < numLines; j++) {
  let x2 = x + random(-s, s);
  let y2 = y + random(-s, s);
  stroke(r, g, b);
  line(x, y, x2, y2);
}
Reflection and future improvements

Overall creating art from something random and chaotic proved to be a fun task. I enjoyed seeing how just a little change in the code made a huge difference in the artwork. Although I did implement the code stopping in the end to allow the user to see what they’ve created, in the future I’d like to make it possible to reset the canvas and create a new piece with just a click.