Week 2 – Computer Graphics and Art

1. Concept

In the beginning of this process in producing a computer graphic artwork, I was inspired by traditional patterned Indonesian batik. As I searched up some designs, my attention was kept by one particular design. I was struck by the magnitude of breathtaking blue and daring strokes of the artist here. I knew that for my artpiece, I wanted to incorporate water waves.

Batik by Tatang Wibowo, Javanese contemporary batik artist. Taken from https://www.batikguild.org.uk/batik/indonesia.

I was partly inspired by my memories of swirls I’d seen in Starry Night by Vincent Van Gogh and the almost swirly-shaped water wave Under the Wave off Kanagawa by Katsushika Hokusai. I wanted to incorporate patterns of swirls which highlight the tidal aspect of seawater, along with sine waves to depict its wavy nature.

Starry Night by Vincent Van Gogh. Taken from https://artsandculture.google.com/asset/bgEuwDxel93-Pg (Public Domain)
Under the Wave off Kanagawa (Kanagawa oki nami ura) by Katsushika Hokusai. Taken from https://www.metmuseum.org/art/collection/search/45434.

I thought of having my artwork depict a scene, so while keeping patterns as a motif in this piece, I added a sun composed of concentric circles, a sky made of turquoise and cyan waves (because I thought these colours looked cool) and rainfall. However, upon revising my plan much later, so that I would draw a night scene, I realised that a moon instead of a sun makes more sense, as well as dark blue and violet colours for the sky instead of turquoise and cyan.

Plan for Alisa’s Computer Graphic Artwork.

In order to code up this piece, I first had to study the fundamentals. To generate a spiral, I studied The Coding Train’s explanatory video on polar coordinates. It was very crucial in helping me understand why using the 2D polar coordinate system (location described in terms of radius and angle) is crucial in drawing special (and especially circular shapes) than the 2D Cartesian coordinate system (location described in terms of x- and y- coordinates).  Through this video, I got the idea to draw a spiral: I could use the formula for a circle, except I would increase the angle while decrease the radius over time. This is much preferred over using describing a multitude of precise x- and y- coordinates.

At first, my idea to generate an animated sine wave was to move an entire sine wave line to the left or to the right. However, after watching two of The Coding Train’s explanatory videos one on simple harmonic motion and one on graphing sine wave, I realized there’s another really interesting approach. Start from a dot oscillating up and down, then make an array of such dots, all oscillating up and down but with varying period and frequency.

2. Code Highlights

Firstly, generating the spirals, a complex shape is a highlight of the project, and a huge challenge as well. I faced multiple issues:

  • Incorrect loop structure: The inner loop used ‘i’ instead of ‘j’ as the variable, potentially causing a conflict with the outer loop. Additionally, the inner loop was never updated, potentially causing an infinite loop.
  • Spiral positioning: My translate() was not positioning each spiral correctly, resulting in spirals being drawn on top of each other.
  • Spiral reset: Whilst the angle and radius were reset, it was done outside the loop that drew the spiral, so this would cause just one dot of each spiral to be visible, with each point of the spiral being drawn on top of the other spiral points.

At one point, my canvas wasn’t visible, and I think it was because of an infinite loop occurring. AI was a useful resource to help me resolve this, as well as provide suggestions for my code. I learned one correct approach of drawing many spirals: by translating each spiral using i and j and incrementing by the spiral radius (in order to space out spirals evenly with some padding between them).

let angle_spiral = 2.5;
let r_spiral = 30;

function drawSpirals() {
  for (let i = 0; i < (height / 2 - 20) / (r_spiral + 20); i++) {
    for (let j = 0; j < width / (r_spiral + 20); j++) {
      push();
      translate(
        j * (r_spiral + 20) + r_spiral,
        300 + i * (r_spiral + 20) + r_spiral
      ); // spaces out spirals evenly with some padding between them
      strokeWeight(2);
      stroke(0, 191, 255);
      let tempAngle = angle_spiral;
      let tempRadius = r_spiral;
      while (tempRadius > 3) {
        let x = tempRadius * cos(tempAngle);
        let y = tempRadius * sin(tempAngle);
        point(x, y);
        tempAngle += 0.2;
        tempRadius -= 0.2;
      }
      pop();
    }
  }
}

 

Second, another highlight is the sine waves representing the sky. To implement the array of dots, we need to first find out the total number of wave dots that can fit across the entire width of the canvas. Then comes the mapping function, which becomes really important in generating the sine waves. In this case, it maps each point’s position i along the wave to an angle between 0 and 8*PI radius.

let sky_angles_wave = [];
let r_wave = 0.5;
function setup() {
  ...
  let total_wave_dots = floor(width / (r_wave * 2));
  ...
  for (let i = 0; i < total_wave_dots + 1; i++) {
    sky_angles_wave[i] = map(i, 0, total_wave_dots, 0, 8 * TWO_PI);
  }
  ...
}

In the drawing function, the x-coordinates (or angle) of the sine wave will be mapped to span the entire width of the canvas (600 px). The y-coordinates (or sine of each angle in sky_angles_wave) is mapped to a value between -15 to 15, resulting in a sine wave with an amplitude of 15.

function drawSky() {
  for (let y = 15; y <= 210; y += 30) {
    push();
    translate(300, y);
    fill(0);
    strokeWeight(6);
    stroke(81, 97, 199);
    beginShape();
    for (let i = 0; i < sky_angles_wave.length; i++) {
      let y = map(sin(sky_angles_wave[i]), -1, 1, -15, 15);
      strokeWeight(2);
      let x = map(i, 0, sky_angles_wave.length, -300, 300);
      vertex(x, y);
      sky_angles_wave[i] -= 0.001;
    }
    endShape();
    pop();
  }
  for (let y = 15; y <= 210; y += 30) {
    push();
    translate(300, y);
    noFill();
    strokeWeight(4);
    stroke(0, 104, 198);
    beginShape();
    for (let i = 0; i < sky_angles_wave.length; i++) {
      let y = map(sin(sky_angles_wave[i] + PI), -1, 1, -15, 15);
      strokeWeight(2);
      let x = map(i, 0, sky_angles_wave.length, -300, 300);
      vertex(x, y);
      sky_angles_wave[i] -= 0.001;
    }
    endShape();
    pop();
  }
}

Each point can shift down and up using: sky_angles_wave[i] -= 0.001;

Last but not least, apparently creating dotted lines (for the rainfall) is quite complicated. So I tried to think of another way. I used black sine waves to cover the grey rainfall.

All in all, this was a complex code!

3. Embedded sketch

4. Reflection and ideas for future work

I found this project to be very engaging, from the brainstorming stages to the coding process. I found the challenges a valuable opportunity to grow in learning how to graph complex shapes and animate lines (animation was something I wanted to learn from last week!). I have achieved the goal of creating a piece similar to the plan I intended, but have also exceeded that by adding in animations.

I hope the artpiece will be a calming one. An idea for the future is to animate the spirals to shift along with the deeper blue sine water waves. The moon could also be animated to grow and dim in brightness over time. Additionally, it would be cool to learn to animate rainfall (the technique used here was more of a special workaround, and I drew black lines over the moving water, the supposedly “invisible” black waves become more prominent!).

Week 2 — Graphic Art

At first, I wanted to do something that was static (e.g. putting everything in setup) since that was an option presented by the professor. However, the more I thought about incorporating randomness into my project, I thought that having some animation or movement would be the best way to do that. I still wanted to keep the artwork simple and focused on making use of a clear, structured pattern while allowing for unexpected variations.

I decided to create a looping animation that generates geometric designs at five key positions on the canvas: center, top-left, top-right, bottom-left, and bottom-right.

let positions = [
  [width / 2, height / 2], // cent
  [0, 0],                  // tl
  [width, 0],              // tr
  [0, height],             // bl
  [width, height]          // br
];

Each of these positions contains a series of concentric shapes that shift over time, creating a dynamic, evolving effect. The rotation is driven by angleOffset * j, which ensures that each circle is slightly different in position based on frameCount, adding to the sense of movement. The shapes themselves are defined using beginShape() and endShape(CLOSE), which connect the calculated points to form a jagged circular pattern.

let angleOffset = frameCount * 0.1;

for (let i = 0; i < positions.length; i++) {
  push();
  translate(positions[i][0], positions[i][1]);
  stroke(colors[i]); 

  for (let j = 0; j < numCircles; j++) {
    let radius = map(j, 0, numCircles, 20, maxRadius);

    beginShape();
    for (let angle = 0; angle < TWO_PI; angle += PI / 6) {
      let x = radius * cos(angle + angleOffset * j);
      let y = radius * sin(angle + angleOffset * j);
      vertex(x, y);
    }
    endShape(CLOSE);
  }

  pop();
}

I wanted to do a bit more and add an interactive element on top of the randomness. So, I added a function that shuffles the colors whenever you click on the canvas. This makes sure that while keeping the overall structure of the artwork the same, each interaction with the piece introduces a fresh, randomized arrangement of colors, keeping it visually engaging.

function mousePressed() {
  shuffle(colors, true);
}

This project helped me appreciate the balance between structure and randomness in p5.js/computational art. By keeping certain elements predictable (such as placement and form) while allowing colors and movement to shift dynamically, I was able to create an interactive piece that feels both intentional and surprising. Well…at least I hope! Check it out:

Assignment 1, Self Portait

Concept

My concept originated from a visa picture I took when I was applying for my J-term.

Struggles

I made this sketch when I enrolled in the class before attending a single session, so it was pretty hard for me to be familiarized with p5 despite me having prior coding experience, so making elements like the body and hair was very tough.

Reflection and future improvements

I need to be more familiar with p5, especially with making more complex shapes like hair and body. For the next assignment I will watch tutorials and spend exponentially more time on practicing and playing around with the sketch.

Reading Reflection – Week 2

Are order and randomness truly mutually exclusive? I found it very fascinating when the speaker spoke about the process behind the commission for a building incorporating chance and randomness, the actual procedure of preparing and creating the art was so orderly. Seen in this way, order can lead to, or support the creation of, chaos. On the other hand, there are plenty of examples from nature that shows randomness can lead to order, including in bird swarms and ant colonies. The relationship between order and randomness, therefore, seem to not be so simple.

As much as it is mesmerizing to observe the “creation”  of chance and randomness, I do think randomness should be utilized consciously. It may be easy to leave everything to chance, whether in art or elsewhere, and let it dictate the meaning of the final output; however, incorporating randomness to any work should not take time away from the ideation and meaningful reflection process that needs to happen throughout. Now that I have been introduced to great examples of how randomness can be utilized in art, I hope to explore (the presence or absence of) the boundary between order and chaos, while at the same time ensuring that, unless the main intention of the work is to observe randomness, randomness is not forced and incorporated just for the sake of having it in.

Assignment 2: For Art

This is my for-loop art piece: taking part of my love for geometric art and combining it with the coding techniques we were taught in class. I chose to be more abstract because my last piece was very portrait-like/ realistic and I wanted to experiment.

📋Assignment Brief

  • Use for() loops or while () loops
  • Use past learned coding techniques
  •  Make a simple work of art, inspired by old computer art magazines

💭Conceptualisation

The goal was to create dynamic geometric art, featuring rotating shapes that interact visually. The core concept revolved around three elements:

  • Rotating circles to create orbital motion
  • A radial pattern of triangles spinning collectively
  • A rotating grid of rectangles to add depth and complexity

The vision was to layer these elements while maintaining visual harmony. Early iterations included a spiral, but it was later removed to reduce clutter. The final design focused on symmetry, contrasting colors, and opposing rotational directions to create a hypnotic effect.

💻Process

I initialised the canvas, centered the coordinate system to the centre of the page, and set the angle mode to degrees for rotation control. I then created an off-axis rotating circle, positioned away from the centre. I used a for loop to distribute 10 triangles radially. Each triangle’s rotation used a fixed offset for simultaneous orbiting.

Next, I added a second circle rotating counterclockwise to create visual tension. I then implemented nested for loops to place rectangles in a grid. Each rectangle rotated with an angle for a shimmering backdrop. I used a translucent background to make a continuous motion trails.

I was the most proud of how I was able to make the grid of squares rotate and spin around. It took a lot of iteration but I was glad that I finally figured out how to make it rotate, and leave a trace.

// Additional Element: Rotating Grid of Rectangles 
  push();
    rotate(angle * 0.2);
    for (let x = -width / 2; x < width / 2; x += 80) 
    {
      for (let y = -height / 2; y < height / 2; y += 80) 
      {
        push();
          translate(x, y);
          rotate(angle);
          fill(255, 255, 0, 100);
          noStroke();
          rect(0, 0, 40, 40);
        pop();
      }
    }
  pop();

 

🚩Challenges

One significant challenge stemmed from managing coordinate transformations. Early versions of the code caused shapes to orbit erratically or appear static because rotations and translations were applied in the wrong order or without proper isolation. For instance, the triangles initially refused to spin because an outer rotate(-angle) transformation, intended to create a dynamic counter-rotation, inadvertently canceled out the individual rotations applied inside the loop.

Another challenge involved implementing opposing rotations for the two circles. Initially, both circles spun in the same direction, which diluted the intended visual contrast. Fixing this required applying rotate(-angle) to the second circle, but this also inverted its positional translation. By maintaining consistent translation distances (90 pixels) for both circles while inverting only the rotation, the symmetrical yet opposing motion was achieved.

📶Potential Improvements

We could enhance the artwork’s interactivity and visual appeal in several ways. Adding user-controlled parameters, like sliders to adjust rotation speeds or grid density, would allow viewers to interact with the piece directly. This could make the experience more engaging and personalized. Color dynamics present another exciting avenue for exploration. We might implement gradual transitions between different color schemes or incorporate noise-based gradients, creating more organic and fluid color shifts throughout the animation. These changes could significantly alter the mood and feel of the artwork.

For a more dramatic upgrade, we could venture into 3D space using p5.js’s WEBGL mode. This would add a new dimension to our geometric shapes, enabling them to orbit in layered planes or respond to perspective changes. It would transform the flat, 2D experience into a more immersive, depth-filled visual journey.

</>Source Code

GitHub Link: https://github.com/theSumeed/Assignment-2-For-Art/tree/main

Week 2: Creating Art

Concept

I was intrigued by one particular artwork in the computer graphics magazine and wanted to similarly create a sketch using a single type of shape:

Computer Graphics and Art, May 1976

I was walking along the highline thinking of potential ideas for my sketch when I saw the A3 building and quite liked how the windows were of different widths and colors so I decided to use the building as my inspiration:


Process

I incorporated randomness into my art in multiple ways — in the position and width of the windows, the weight of the strokes, as well as in the choice of colors. I wanted to add interactivity to my sketch this time and after thinking of different ways of incorporating action, I decided to embrace the original inspiration of the A3 building. On a mouse click, if it lands on a window, the corresponding window (home) lights up to give a warm ambience, and if it lands outside of any window, the background changes color to represent the shift from day to night, and vice versa.

Writing the logic for the mouse click action was harder than I expected. I needed to differentiate between a click outside and inside a window (rectangle) to toggle the background, while also checking if the current window being clicked is the same as before to turn the light off.

function mouseClicked() {
  let insideWindow = false;

  for (let r of rectangles) {
    // check if mouse click falls inside a window
    if (mouseX >= r.x && mouseX <= r.x + r.w && mouseY >= r.y && mouseY <= r.y + length) {
      insideWindow = true;
      let newLightPosition = {x: r.x + r.w / 2, y: r.y + length / 6};

      if (lightPosition && lightPosition.x === newLightPosition.x && lightPosition.y === newLightPosition.y) {
        lightPosition = null;
      } else {
        lightPosition = newLightPosition;
      }
      break;
    }
  }
  
  // if mouse click falls outside a window, toggle the background
  if (!insideWindow) {
    lightsOff = !lightsOff;
  }
}

To draw the light and the illumination, I found a sunshine palette online and sketched multiple circles of varying sizes and colors. I learned that the fill function can take a 4th argument for transparency, which I found to be very useful in creating the illuminated effect.

function lightsUp(x, y) {
  noStroke();
  // light bulb light
  fill(255, 228, 169);
  circle(x, y, 10);
  fill(255, 218, 138);
  circle(x, y, 8);
  fill(255, 210, 112);
  circle(x, y, 6);
  fill(255, 201, 83);
  circle(x, y, 5);
  fill(255, 191, 62);
  circle(x, y, 4);
  
  // light bulb illumination
  fill(255, 228, 169, 30);
  circle(x, y, 200);
  fill(255, 218, 138, 30);
  circle(x, y, 300);
  fill(255, 210, 112, 30);
  circle(x, y, 400);
  fill(255, 201, 83, 30);
  circle(x, y, 500);
  fill(255, 191, 62, 30);
  circle(x, y, 850);
}

Reflections & Improvements for Future Work

I am quite happy about how the sketch turned out, especially the way the light is drawn in multiple layers. I also got to incorporate many of the concepts we learned in class into p5.js, including loops, mouse clicks, booleans, global/local variables and arrays. As this sketch is more or less a static work with simple mouse click triggers, I hope to continue exploring randomness and play with transformations to create live continuous actions on the canvas in the next assignments.

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.

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.

 

Reading Reflection – Week#2

Casey Reas’ talk at the EYEO festival 2012 gave a compelling reflection on the balance of randomness and control in the creative process. What I liked is how he showed us that even though artists use randomness in their artwork, they still have some control over it. This is something that I haven’t thought of before but now makes so much sense. The visual projects he created show exactly what he is trying to convince us. I really liked how all of his work showed randomness with some dosage of control and by combining these two he created beautiful unique structures. It is interesting how he wants to present coding as not just a technical skill, but also an art form. In the “10 PRINT” example he showed us, we had a chance to see how even a simple line of code can create beautiful, unique and diverse structures that create the digital art as we know it.

 

This talk did get me thinking though. Is it even possible to create something that is completely random? Because Reas makes an argument that artists and coders still do have some control over the artwork they are creating, does that mean that in order to create something truly random would mean that we need to bash our keyboard in order to type random letters in hopes some will combine into a sentence that is readable by the programming language? Maybe even the code alone, with its chaos, would be some sort of an art form? That is something Reas didn’t talk about but I think might be important. Can a chaotic code which is used to create randomness be used as art?

 

In my code I want to implement total chaos and randomness. I want the user to not understand what’s happening before they click to “freeze” the motion. This chaos and randomness when stopped will create a beautiful artwork which will of course every time be unique. But I am also keeping some control as from Reas example, I will be limiting some parameters of the random objects therefore making it somewhat controlled. 

Week 2 – Reading Response to Casey Reas’ Eyeo Talk

Casey Reas’ exploration of the chance operations revealed this broad tension between order and chaos. He says artists are the ones who keep order, in the world of chaos created by nature. A world where chaos came first, before order was invented to control it. He talks about this concept of “controlled randomness”- where artists can set parameters and boundaries, while maintaining hints of chaos and randomness. He started generating code for art, where there were some shapes and lines, and some behaviours and processes which switches around and creates different pieaces – order is kept while chaos creates this little imprecision, a little flaw for aesthetic visuals. I particularly enjoyed his “Tissue Work”, I feel like it challenges plain, automatic art; art which lost its abstractness and humanity. The art code generated by Lia, when he says something along the lines of, “somewhere in those pixels is the difference between order and chaos” resonated with me the most. It was interesting to note how the dots deviated (chaos) from the grid (order), leading me to wonder- what if order exists everywhere and chaos is just its byproduct, contrary to what Casey says at the beginning of the talk? Casey Reas’ chance operations shift the narrative of an artist as a “keeper of order” to someone who controls the flow of chaos, and is always pleasantly surprised by its outcome. Even minor deviations in coding can lead to the creation of something inextricably beautiful, subtly suggesting that maybe chaos is not an opponent to creativity, rather a collaborator in the process. 

Week 2: Reading Reflection

One of the interesting ideas mentioned in the video was how order eventually arises from randomness. This was a concept that I played around with in my work, where the longer my program runs, the more perfect a grid is formed. In other words, the more randomness or entropy that is introduced, the more order arises (see images below).

My work incorporates randomness by using a random value to determine where the line will draw next: move straight, turn left, or turn right. It does this random check at every frame. As the user interacts with the work, it speeds up the frame rate, increasing the amount of randomness experienced per unit of time. As the work is left alone by the user, the randomness slows down back to its base speed.

The balance that I attempted to achieve between total randomness and complete control is one of harmony and complementing. By that, I chose to make that the randomness controlled, but the randomness controls the piece. This idea is also calls to a similar one shown in the video at 33 minutes and 33 seconds, where the probability selected completely changes the piece of art that is formed.