Week 2: Using loops

Concept:

Here are my rough drawings that I used for ideation and inspiration:

The scene captures a quiet and melancholic night, showing the contrast between the outside world and the inside of the room. The rain falling against the window, adding to the somber mood. The city landscape outside is cold and distant with the buildings seen as dark silhouettes against the misty night sky. The outside world feels vast and modern, filled with artificial lights and towering structures, yet it lacks warmth and comfort.

Inside the room, the atmosphere is different. There is a longing for simplicity, an escape from the rush of modern life. The wooden furniture, antique candle holders, and potted plants reflect a preference for an older, more primitive way of living. Inside, one feels more connected to nature and tradition. 

Overall, this scene is about introspecting on the quiet sadness of longing for a simpler life while knowing that the world outside continues to move forward.

Since this was a generative art project, my project features the following elements that were randomly generated:

  • The city landscape changes every time you refresh the code, showing how quickly the infrastructure and outdoor environment evolve.
  • The leaves of the potted plants are randomly generated each time to depict the natural growth of plants.
  • The raindrops are randomly generated within the window area, with variations in speed, position, and size.

Highlights:

I believe the highlight of the code is the dynamic raindrops, as they are the main part of the project and also the most challenging. It was difficult to make the raindrops move continuously in a way that looks realistic, like actual rain. To avoid gaps in the rainfall, I started by coding the raindrops already scattered across the scene. Additionally, they needed to fall at different speeds to create a natural, random effect. Since the rain is outside the room, the raindrops had to disappear when they reached the bottom of the window and restart from the top.

// Initializing raindrops and distributing them randomly from the very top (y=70) to bottom of the window (y=70+380). this ensured that there were drops already at various heights so rainfall looks continuous.

for (let i = 0; i < dropCount; i++) {
let rx = random(130, 130 + 540); // horizontal area of the window
let ry = random(70, 70 + 380); // vertical area of the window
let sp = random(3, 9); // speed of each drop falling
let ln = random(5, 15); // length of each raindrop
raindrops.push({ x: rx, y: ry, speed: sp, length: ln });
}
}

function draw() {
// showing the static scene (background, window frame, city, plants, etc.)
image(sceneG, 0, 0);

// updating and drawing the raindrops so they fall continuously
stroke(200, 220, 255, 120); // raindrop color
strokeWeight(2);

for (let drop of raindrops) {
// move each drop down
drop.y += drop.speed;

// if a drop falls past the bottom of the window area, reseting it to the top
if (drop.y > 70 + 340) {
drop.y = 70;
drop.x = random(130, 130 + 540);
}

// drawing the drop as a vertical line
line(drop.x, drop.y, drop.x, drop.y + drop.length);
}
}

Reflections, ideas for future work & Improvements:

  • It might not be clearly noticeable, but the raindrops overlap with the plant pots, which is something I could have improved. While they still fit into the scene, appearing to be outside the window in the rain, I could place the potted plants in front of the rain to clearly show that they are indoors.
  • I could also improve the aesthetics of the room by adding more antique elements to enhance the contrast between the outside world and the inside of the room.
  • Another improvement could be randomly generating small movements in the candle flame to make it look more realistic.

Week 2 – Loops

Concept

In this assignment, I initially created a work where random faces of different sizes and colors are displayed, as shown below.

However, after watching Casey Reas’ talk in Eyeo 2012, I challenged myself to mimic his style of digital artwork by using more simple objects to give somewhat abstract feeling to my audience.

So, I made a rotating square with circles of random coordinates. I wanted to create four different squares to rotate synchronously to make the four squares to form one large rotating square.

Demo

 

Code Highlight

let angle = 0;
let speed = 0.01;
let centerX = 200; 
let centerY = 200;  
...
//move the center of grid to (0,0) and top-left to (-200,-200) with top-right of (200,200)
  translate(centerX, centerY);
  rotate(angle); // Rotate the entire canvas
  angle += speed;

I am most proud of moving the center of grid to (0,0) to make it easier to code as I always found it hard to understand x- and y- coordinates system of p5.js. In addition, I made the objects rotate continuously for better visual aesthetics.

Reflection and Possible Improvements

I wanted to create an art as a result of some random values or outcomes of the code. Even though the circles have random coordinates, I initially wanted to create an entire artwork to be of a random result: to display a different outcome after each run. However, I could not be creative enough to make such imagination come true.

Moreover, my work would be more visually aesthetic if there are more shapes or colors; maybe, I could have made the shapes and colors to be randomly generated.

Reading Reflection – Week #2

I have had hard time really grasping what interactive media really means and what is expected in this class. Coming more from programming background, I have found myself struggling to be creative when completing assignments and working in class. As I have never challenged myself to think in realm of art, I needed to practice thinking like an artist and use my imagination in ways that are original : which is not usually the case when programming. When programming, there are very specific rules and guidelines; furthermore, there are limits to where I can be innovative. I need to use correct syntax, open brackets and close brackets in the right places for loops, and can never forget to put semi-colons after each lines of code. However, after watching Casey Reas’ speech in Eyeo 2012, I could understanding how art can be produced with the help of technology: more specifically how art can be created through coding.

Generating random numbers or patterns is one of the simplest concept in coding, and Reas discusses how such concept may create complex visual systems. It is intuitive for programmers to associate the word ‘random’ as chaos as they normally do not want random results or values to occur by their codes. However, Reas’ points on the relationship between systemic autonomy and artworks opened my eyes to a completely different perspective: persuading me to consider random outcome of code to be a form of art, in a sense. Seeing digital artworks presented by Reas during his presentation, I reflected on my programming journey and thought the amount of random outputs I got while learning how to code may have turned into an art piece!

Even though randomness in code and use of technology may be a medium to create art, I find Reas to be advocating the role of technology in art too much as he does not discuss art in forms of paintings or sculptures. He only talks about digital art forms, which might make painters or those who create more traditional forms of art uncomfortable. It occurs to me that if art can be created digitally with the help of machine learning and technological advancement, then there would be less opportunities for man-made arts as it is cost-effective and less time-consuming. Thus, I believe technological approach to art has to be made very carefully as it may not only affect the definition of art, but also have impacts on artists both socially and economically.

In addition, if art is made by random outcomes and does not show the same visualization consistently, I believe it is hard to be defined as ‘art’. Artists use specific colors, stroke their brushes in specific ways to match their needs, and pick specific apparatus to make their imagination come true, but Reas’ examples of art defies the traditional concept of art in all ways possible.

It is indeed remarkable how technology can be used to create art, but I think the creation of art cannot be relied entirely on randomness and should reflect more on the purpose of artists.

Assignment 2: Flowers in the Wind

For this week’s assignment, we were asked to create a peice of artwork utilizing loops. I struggled to think of a concept at first, but while walking around the campus, inspiration struck. I saw flowers across the campus moving in the wind. Thus, my assignment takes inspiration from that image.

In my peice, 10 flowers are randomly generated throughout the canvas, with their size and color also being randomized.

I had to watch some tutorials in order to understand the way angles worked in p5.js to get my flowers to spin. Due to this learning curve, I am especially proud of the rotation of the flowers within my peice. It took quite some time for me to get the hang of it, but it made the end result all the more satisfying to accomplish.

function draw() {
  //refreshing the background each time
  background("#9dc183");
  

  //iterating over every item in the flower array
  for (let flower of flowers) {
    push();
    //makes the drawing start at the center of the flower
    translate(flower.x, flower.y);
    //makes the flower spin from the center
    rotate(flower.angle);
    drawFlower(flower.size, flower.color);
    pop();
    flower.angle += spinSpeed;
  }

  //if statement that will call the generate flower function as long as the flower array isnt longer than 10 and will generate every second
  if (flowers.length < maxFlowers && frameCount % 60 == 0) {
    generateFlower();
  }
}

 

Initially I had wanted a more detailed background for my peice, rather than a solid color, however, I struggled with the background flickering every frame. Another thing I think that can be further improved on is the variety of flowers chosen. It would be fun to implement more kinds of flowers, rather than simply just having them in different colors.

Reading Reflection – Week 2

The first thing about Casey’s presentation that made me challenge my beliefs is that digital art is not real art. I used to think that things that are ‘generated’ are not authentic enough to be considered a unique piece of art. Yet, seeing how much thought and structure it takes to create an abstract pattern with the help of algorithms made me reevaluate my views. It’s fascinating how a series of flat geometric shapes drawn over and over again can create such a lively picture.  This idea is reflected in the quote by Michael Noll, “The computer is a unique device for the arts, since it can function solely as an obedient tool with vast capabilities for controlling complicated and involved processes. But then again, full exploitation of those unique talents for controlled randomness and detailed algorithms can result in an entirely new medium—a creative, artistic medium.” In my future works, I’d like to work more on thinking creatively within a limited range of functions I know.

I believe that uncontrolled randomness leads to complete chaos, while good digital artwork takes a little bit of randomness and a lot of decision-making. As humans, we are set to think in patters, thus it can be quite challenging to create something inherently random, something that has no beginning or end, or doesn’t follow standard rules of composition. I like how Casey uses randomness as a jumping-off point for his artworks such as rolling a dice to trigger the final composition, which is built based on a series of carefully designed algorithms.  

Looking at Casey’s journey, I admire how meticulous he is about building an algorithm and exploring it to the fullest before moving onto a new concept. It seems like he won’t leave his idea until he has tried visualizing it in all ways possible. This reminds me of how famous artists such as Picasso, who went though different ‘eras’ in his art, ended up creating a series of artworks known as The Blue Period. 

My final takeaway from this talk is that true randomness can not be generated by a computer – it has to be “borrowed” from nature, like the patters that bacteria create while reacting to sunlight, where computer serves as a tool to make randomness make sense. 

Week 2 – artwork

Concept

This artwork explores the balance between structure and unpredictability through a dynamic grid of circles. The grid itself represents order and repetition, while the interaction with the mouse introduces an element of spontaneity. As the user moves their cursor, the circles respond by changing size and color, creating a sense of movement and fluidity. This interaction turns the viewer into an active participant, making the piece feel more alive and engaging. The idea behind it is to show how external influences can transform something predictable into something unexpected.

Code Highlight

One of the most interesting aspects of the code is the way it uses a double for-loop to generate a grid of circles. This helps arrange the shapes evenly on the canvas. The interactive part is driven by the dist() function, which calculates how far each circle is from the mouse pointer. That distance then determines the size and color of each circle, making them look as if they reacted to the user’s mouse movements. The map() function helps smooth out these changes by scaling the distance values into a range that works well for the visual effect.

for (let i = 0; i < cols; i++) {
  for (let j = 0; j < rows; j++) {
    let d = dist(mouseX, mouseY, x, y);
    let circleSize = map(d, 0, width, maxSize, minSize);
    fill(map(d, 0, width, 255, 100), 100, 200);
    ellipse(x, y, circleSize);
  }
}

Reflection & Improvements for Future Work

I believe that my project does a great job of showing how loops and interaction can be used to create something visually engaging in p5.js. The grid of circles reacting to the mouse makes the piece feel dynamic, and the changes in size and color add a nice touch of unpredictability. It’s simple, but it keeps things interesting as you move the mouse around.

That being said, there’s definitely room for improvement. Right now, the transitions feel a bit abrupt, so adding some smoothing or easing effects could make the movement more natural. It would also be fun to experiment with extra elements like rotation, fading effects, or even some subtle animation when the mouse isn’t moving. Another cool idea would be giving users more control—maybe letting them change the colors or grid size with sliders or buttons. And if sound was added, it could create an even more immersive experience where the visuals react to music or voice input.

Overall, this was a fun experiment in generative art.

Week 2 – Computer Artwork

Concept :

For this computer artwork, I decided to take inspiration from a stress relieving toy called Pop It. Basically the user can pop the silicon molds as a form of stress relief. I decided to use this idea and create a grid of colours and patterns, where one clicking the mouse, the colour and pattern changes.

I tried to use all the concepts we learned in class, including for loops, arrays, functions; both built in and user defined. Trying to use these different concepts in my code taught me how to use and incorporate them.

Highlight:

One part of the code I’m particularly proud of is the switching between patterns. I used switch statements, a concept I learned from CS in highschool,  to create pattern changing from circle to strikes.

function drawPattern(x, y, patternType) {
  push();
  stroke(0);
  strokeWeight(2);
  switch (patternType) {
    case 0:
      line(x, y, x + boxSize, y + boxSize); //strike pattern
      break;
    case 1:
      ellipse(x + boxSize / 2, y + boxSize / 2, boxSize / 2); //ellipse pattern
      break;
  }
  pop();
}

Embedded sketch:

What I love the most about this artwork is the fact that its never the same, its always changing. We can create art out of the art itself, and the whole “pressing the mouse to change colours and patterns” is so satisfying. I also love the colours, which

I made using a colour palette using arrays. I like how we can create patterns with the colours themselves.

Reflections:

Overall, I felt that this assignment was such a good way to revisit all the concepts we learned in class and create something beautiful out of it. In the future, I’d like to try and make the code more precise and versatile. Maybe more patterns, colours and animations in the grids themselves.

 

Reading Response 1 – Chance Operations (Week 2)

In his talk, Casey Reas explores the theme of order and chaos in art, emphasizing the role of randomness in creative processes. He also focuses on the notion of “controlled randomness” , where artists establish specific rules and parameters within code, allowing for unexpected outcomes while maintaining the overall coherence.

First of all, I really enjoyed listening to Reas’ talk. I appreciated the way he showcased his work and explained his philosophy on creativity and art. Reflecting on his insights, I aimed to incorporate the concept of controlled randomness in my most recent p5.js sketch, which I titled randomness. The overall structure of the artwork is straightforward—featuring a 10×10 grid of circles. However, the element of controlled randomness comes into play when the user interacts with the piece. Each time the user clicks on the canvas, the circles in the grid change in shape and size, creating a dynamic balance between order and unpredictability. While users can grasp the overall structure, every interaction (mouse click) generates a unique and evolving pattern. I wouldn’t go so far as to claim that my artwork revolutionizes the concept of generative art, but I believe it is an engaging and enjoyable piece to explore.

That being said, Reas’ perspective on art and the creative process encourages me to explore the potential of chance in my work. With every new p5.js sketch I create, I will keep the notion of “controlled randomness” in mind.

Week 2 – Animation, Conditionals, Loops

Concept

In this p5.js sketch, my main objective was to practice for loops and play around with the concept of randomness a bit. It is a simple generative art piece. The idea was to generate a grid of circles, where each circle varies in size, color and level of transparency. So by clicking on the window/canvas, the user can regenerate a completely random pattern (this adds an element of interactivity and makes the artwork dynamic).

Demo (Click on canvas)

Code Highlight:

One of the parts I’m most proud of is the loop structure that efficiently places the circles while maintaining randomness in their size and color:

for (let x = 0; x < width; x += spacing) {
  for (let y = 0; y < height; y += spacing) {
    let size = random(10, spacing * 0.8);
    let r = random(100, 255);
    let g = random(100, 255);
    let b = random(100, 255);

    fill(r, g, b, 180); // Semi-transparent random color
    noStroke();
    ellipse(x + spacing / 2, y + spacing / 2, size, size);
  }
}

Reflection & Improvements for Future Work

This project reinforced my understanding of looping structures in p5.js and the power of randomness in generative art. It was interesting to see how slight variations in parameters can lead to visually engaging results.

Future Work:
Experiment with different shapes (e.g., triangles, squares, or custom polygons). Add animation so circles gradually fade in and out.  Allow users to save their favorite generated patterns.

This was a fun dive into creative coding, and I look forward to exploring more complex generative techniques!

Week 1 – Self-Portrait

Concept:
I wanted to make my self-portrait in a minimalistic style that would accurately represent my appearance while being limited to the use of simple geometric primitives. I chose to not use outlines to add to that flat, minimalist aesthetic. I also wanted to add some simple interactivity, which came in the form of the background changing colours through a day-night palette when clicked.

Embed:

Highlight:
I was proud of this snippet, where I used an array of hex codes to implement my colour cycling feature. It is perhaps more simple than I had hoped for, but I’m happy with how it turned out overall.

// // Array containing possible background colours
let bgs = ["#fff2bd", "#f4d797", "#c9ebff", "#abb5ff", "#7475b6", "#5148b2"];
let curr_bg = 0;

function mouseClicked() {
  // // Change to next bg colour on click
  curr_bg = (curr_bg + 1) % bgs.length;
}

Reflection:
I feel a bit conflicted about this assignment, since on the one hand it was an interesting change of pace to try and create art directly using code, but also very annoying. I found myself frequently trying to force coordinates or dimensions to be multiples of the canvas’ dimensions to allow it to scale, but often found it to be an exercise in frustration. Having to essentially guess-and-check all my numbers was another aspect I didn’t enjoy, since there were little quirks I wouldn’t expect such as circle’s being plotted by their center versus rectangles by their top-left corner.

In the future, I would like to try and plan things out more before starting, especially in regards to using custom variables. The built-in width and height variables made sense at first, but I quickly gave up on sticking to them and added pixel offsets instead. I think the most important thing for me is finding a way to streamline my workflow, since my struggle to put my concept on paper/screen caused me to fall short of where I wanted to be in terms of both artistic and programmatic aspects.