Week 2: Loop

Concept

I drew inspiration from the movie Coraline, where there was a little door that lead to another world through a mysterious tunnel and I wanted to use that tunnel as my loop. So in my sketch, there’s a little door and when clicked, it reveals a mesmerizing tunnel of concentric circles that pulse and animate.

My Final Portrait!

Code that I’m Proud of

let animatedSize = d - t;
if (animatedSize > 0) {
  ellipse(0, 0, animatedSize);
}

d -= random(15, 35);

I wanted a “magical tunnel” effect so I used d – t to make all circles pulse inward together and random(15, 35) to give each circle irregular spacing. I think it was successful in capturing the mysterious portal feeling and as if you’re being pulled into another dimension.

How this was made

The draw() function has two states controlled by mouse interaction. When the mouse is not pressed, it shows a door: for the door, I wanted to create something simple yet mysterious, so I just used a rectangle with a small circle on the side as the handle and a plain black background. When the mouse is pressed, it shows a tunnel: for the tunnel effect, I initially tried using a for() loop but switched to a while() loop to get that random, organic effect. I was inspired by a p5.js example that used a while loop to create concentric circles with random spacing. The example code showed how while (d > minSize) could draw circles that decrease by random amounts using d -= random (5, 15), which created this uneven pattern instead of perfectly uniform circles. I thought this technique would be perfect for creating a mysterious tunnel effect and I heavily implemented that in my sketch. I used translate() to move origin point to the center, which made drawing the circles so much easier since I could just use ellipse() instead of calculating positions every time. I was also experimenting with the minSize value to control how much blank space shows in the center and settled with 100. I learned modulo operato % to make the animation loop endlessly.

Reflection and Future Improvements

I used the p5.js reference page for examples of for() and while() loops and The Coding Train’s playlist on YouTube about loops to understand the logic and process of creating a loop. These sources were helpful in making me understand loops better as I missed the class discussion about this. In the future, I’d like to learn adding color gradients for the circles and a spiral motion to add more depth and make it more whimsical-looking.

Week 2 – Generative ArtWork

For this assignment I wanted to create a small interactive starfield like looking at a moving night sky. Recently I have been very interested in space and how I can implement it in my works, so I used this sketch as a chance to try a simple space scene. My idea was to have many tiny stars drifting down the screen at different speeds, but also to make the scene respond to the viewer. When the mouse moves near a star, it reacts by changing color and size, so it feels like the user is activating and touching the star. I also added a speed mode that you can activate with the space bar, so that the whole field accelerates. The focus of the sketch is on motion and interaction.

Code highlight I am proud of

The part of the code I am most proud of is how I created multiple stars with random properties and then updated them in a loop. Instead of coding circles, I wrote a helper function that builds a star object with random position, size, brightness and speed, this is one of the ways I implemented randomness:

// randomness used, create a new star with random properties
function createStar() {
  let x = random(width);
  let y = random(-100, height);
  let size = random(1, 4);
  let brightness = random(150, 255);

  let xSpeed = random(-0.1, 0.1);
  let ySpeed = random(0.5, 1.2);

  return {
    x: x,
    y: y,
    size: size,
    brightness: brightness,
    xSpeed: xSpeed,
    ySpeed: ySpeed
  };
}

I like this part because I am generating many small data objects and storing them in an array. Each star gets slightly different random values, which makes the starfield look less repetitive. The cretestar() function also lets me recycle stars easily. When a star goes off‑screen, I just replace it with createstar() again, so there is a constant flow of new stars without writing another drawing code.

Another small piece I am happy with is the interaction that changes color and size when the mouse is close:

let distance = dist(mouseX, mouseY, star.x, star.y);

if (distance < 50) {
  // color and size change when mouse is close
  fill("magenta");
  ellipse(star.x, star.y, star.size * 2, star.size * 2);
} else {
  fill(255, star.brightness);
  ellipse(star.x, star.y, star.size, star.size);
}
}

Using dist() was also a new thing I learned in this sketch. In p5.js, dist( x1, y1; x2, y2) calculates the distance between two points, so I can easily measure how far the mouse is from each star. By checking if that distance is less than a certain value, I can define an interaction radius around every star. I think it makes the sketch feel more alive, because the stars react as soon as the cursor approaches them.

Embedded sketch:

I am happy with how this sketch turned out, especially because it let me bring a recent interest of mine, space, into my code. It is nice to see that something I am interested about visually can be translated into an artwork which is also interactive using programming. It boosts my confidence in connecting my personal themes and aesthetics with what I am learning in p5.js. In the future, I would like to move toward more advanced drawings and interactions. I want to explore new functions and techniques in the p5.js reference so I can build richer scenes, maybe with planets and nebulas. I am also interested in opening new things in code for myself as using voice and classes for my ease in code and so that each new sketch becomes a little step toward more expressive interactive artworks.

Week 2 – Generative Art

My concept:

Initially I had lots of images saved from different types of designs, forms, and artists until I realized that I kept going back to page 19 in ProgrammInformation21_PI21. When it comes to art, I have drawn many zentangle-style pieces, which rely heavily on repetition and pattern, which is why I felt drawn to this specific art piece. I then decided to take inspiration from the piece and try to create movement similar to what I see. When I first looked at the image the shapes I saw were: triangles, squares, and circles. When I first looked at the image, the shapes I noticed were triangles, squares, and circles. Although circles are not clearly visible when zooming in, I decided to include them in my final piece to represent my initial visual interpretation of the artwork, hence why I called the piece Captured.

Inspiration from old computer art magazines: My project is inspired by early computer-generated art found in old programming and computer art magazines, where artists worked with limited tools leading to their reliance on shapes, repetition, and randomness.

Embedded Sketch:

How this was made:

This project took me around 4 hours to create. Much of the time was spent on searching and finding idea because I was just introduced to generative art and was still learning how randomness and loops affect visual outcomes. After finding the “perfect” inspiration I was then able to start brainstorming how I wanted my piece to look like.

At first I started off by creating just squares and triangles that were evenly spaced out but the results felt too structured compared to the chaotic image from the magazine. I then began experimenting with the [random] function:

let x = random (width); 
let y = random (height);

I combined this with rect() for squares and ellipse() for circles. Initially, I used a single square size [rect(x,y,10,10);] but unfortunately again, did not create the layered visual effect I wanted. To address this issue, I added more than one rect and played around with the width and height until I was able to layer three squares on top of each other with the small ellipse size. After I created the three different points for the triangles:

if (random(1) <0.8) { //80% chance to draw 3 rects and 1 ellips 
    rect(x,y,10,10); //x,y being random and 10,10 the W,H \|/ the same
    rect(x,y,7,7);
    rect(x,y,6,6);
    ellipse(x,y,5,5);
  } else { //the rest -> 20% will be triangles
    triangle(x, y-5, x-5, y+2, x+2, y+2);

I was also able to play around with the amount of shapes appearing on each frame (5) [for (let m = 0; m < 400; m++)]. Like everything else, starting is the hardest part so once I get used to the numbers and codes I used the rest of my time experimenting until I was satisfied with the results.

One code I am proud of:

for (let m = 0; m < 400; m++) { //drawing 400 shapes for every frame -> x5. Using m for my name

This was my favorite part of the code. I kept changing the number between 100 and 600 and experimenting with how the shapes changed and how the final piece turned out. In the end, I decided to keep it at 400 because it felt the closest to how I first saw the image. When I looked at everyone else’s self-portrait, I noticed that some people used this function, and at first I honestly didn’t understand how it worked. After looking into this source (JavaScript Loops Explained), I was finally able to create a similar effect and actually understand what the code can be used for instead of just copying it.

Resources: I of course wasn’t able to open p5.Js and create this project, so I kept referring back to the Week 2 lecture notes from both Professor Mang and Professor Aya’s weekly slides along with the website JavaScript Loops Explained Helped me create my code for the 400 shapes for each frame, I was able to make the loop but instead of using ‘i’ I just decided to use m for my name, adding a personal twist.

Full code:

function setup() {
  createCanvas(400, 400);
  frameRate(5); //to control the speed, or like I call this "the sets" I put 5 to make it slow but fast.
  noFill(); //black outline for the shapes
  stroke(0);
}

function draw() {
  background(255); //making the background white to match inspo

  for (let m = 0; m < 400; m++) { //drawing 400 shapes for every frame -> x5. Using m for my name
    
    //local variables created, so inside the loop each shape gets a new random position
    let x = random (width); 
    let y = random (height);
 
    if (random(1) <0.8) { //80% chance to draw 3 rects and 1 ellips 
      rect(x,y,10,10); //x,y being random and 10,10 the W,H \|/ the same
      rect(x,y,7,7);
      rect(x,y,6,6);
      ellipse(x,y,5,5);
    } else { //the rest -> 20% will be triangles
      triangle(x, y-5, x-5, y+2, x+2, y+2); //creating 3 different points for the triangle. Point 1: x, y-5 moving up. Point 2: x-5 moving left, y+2 moving down. Point 3: x+2 right, y+2 down
    }
  }
}

 

Reflection:

For future assignments, I think I’ll try to come up with ideas faster so I don’t spend so much time looking for the “perfect” inspiration before starting. Instead, I want to just start coding and see where it takes me. This feels like a fun challenge because the code can change so much depending on small adjustments. At the same time, having a general idea and then adjusting it as I go also works. I also want to experiment with more types of code. I know it’s not realistic to use every single thing we learn in one project, but it would be interesting to try combining more of them and seeing what comes out of it.

Week 2 – Zere – Creative Reading Response

  Casey Reas’s talk made me look at the concept of randomness differently. In my prior opinion, randomness was something that took away the “magic” of art, as it took away the artist’s control over what their piece will look like. Yet, Reas’s speech gave a new perspective of randomness, as in, that it can be used with intentionality, utilizing logical rules given and created by the artist, therefore giving them a sense of control over their work. Generative art is exactly that in my opinion. I think that the “magic” of art in this case is the artist designing the structure, giving the rules, setting the limits on variations etc. Artists in this case, I think, showcase that code can be used as an art medium much like chalk, acrylic paint, colored pencils and various other types of mediums. If looked from the perspective that computers and generative tools were created by humans for humans, the same as paint and canvas, generative art is art. An artist can control the limits of the “random” decision made by the computer, and it can be exciting. Art is meant to be exciting, at least in my perspective of it. I am not saying it is meant to reach a deep part of your soul every time, but one of the reasons many people create art is for that sense of excitement it brings you. 

       Generative art is unique because of its randomness. One of the things that kept appearing in my head is chance operations in dance. I have taken Intro to Modern Dance last semester, and our professor introduced us to Merce Cunnigham’s work. His idea was to have a set of moves, number each of them, then randomly select the numbers and therefore build a unique dance each time. I feel like this is one of the examples of how I would like to utilize random elements in my work – having a set of elements that I adhere particular meaning to, then randomizing their order to see how many new and unique combinations I can get. In my opinion this is also an example of balancing randomness and control – you give an algorithm/ a machine a set of elements/variables that matter to you as an artist, but leave the combinational part up to the machine.

Week 2 – Reading Reflection – Kamila Dautkhan

This video really put into words something I’ve been figuring out with my own work. It’s not “randomness” itself that I find interesting, but what happens when you give a system a little bit of freedom to play with the code itself. I really like when my work starts with something simple and then escalates into something complex and interesting ! Also, I really liked the idea of the artist as a gardener, not a painter.

At the same time, the video’s question about “true randomness” and convergence really caught my attention. If you let systems run long enough, they tend to eventually form some sort of patterns. And it is exactly the kind of thing I enjoy the most: you start very broadly and then some kind of order appears.  And that is exactly what I want to see in my own generative pieces. I don’t want pure static, and I don’t want something completely predictable. I want that middle ground where you can still recognize my own aesthetic in the codes I wrote. This video helped me realize that I’m not just making art with controlled chaos, I’m actually designing a system’s tendencies and then letting the computer show me just how far they can be pushed.

 

Week 2 – Creative Reading Response

Initally, I expected Casey Reas’ video to be more of a lecture-like talk about randomness and control, however, it was nice to see that his video consisted of a lot of examples as I prefer actually getting to watch, rather than just hearing about the ideas.  My favorite part of the examples was when he showed himself coding this maze-like images at the end. This is kind of where I started to find an answer to the balance between total randomness and complete control. He is in control of the shapes being drawn, but it’s up to the computer which shape is being drawn and when. However, it still created beautiful, unique pieces everytime. I’m excited to incorporate randomness into my work by kind of allowing the computer to ‘make the decisions’ for me when it’s minor things like where each box goes or what color each box is, but controlling the limits of these decisions. I also think another way of intrepreting randomness and control can be about controlling your own narratives for your work rather than following what the current trends are or what the preferred styles are. You insert randomness by being unexpected and doing what you prefer rather than what people might expect, and you gain control because you control the narrative.

While watching the video, I was just doodling on my iPad, and I feel like it’s a nice example of randomness (with a bit of control). 

Week 2 – Generative Artwork

Your concept

I was scrolling through the provided old computer art magazines for inspiration, and  I ended up liking the work Random Squares by Bill Kolomyjec from COMPUTER_GRAPHICS_AND_ART_Aug1977. I wanted to add my own touch to it, so I had two main goals, adding color and adding some kind of interaction with the cursor.

A highlight of some code that you’re particularly proud of
// this function makes a box dissapear when the cursor hovers over it.
function squareDissapear(xPos, yPos, size, offset) {
  
  let cellX = xPos - offset;
  let cellY = yPos - offset;
  
  // only active when mouse is within the canvas
  let mouseInside = (mouseX >= 0 && mouseX < width && mouseY >= 0 && mouseY < height)
  
  // true / false
  let hover = mouseInside && mouseX > cellX && mouseX < cellX + squareSize && mouseY > cellY && mouseY < cellY + squareSize;
  
  if (!hover) {
    square (xPos, yPos, size);
    return;
  }
  
  push();
  
  fill (220);
  noStroke();
  square(xPos, yPos, size)
  
  pop(); 
}

This is the interaction I ended up adding. When the cursor moves over a box, the box dissapears! I initally wanted to do some type of rotation but I wasn’t able to really understand how to use the functions correctly so as a comprimise, I landed on just doing dissapearing boxes as it was a bit simpler. Due to the way I did the loops to draw the boxes, it was still not very straightforward, so I did have to do some mental gymnastics to get it to work. However, I’m happy I was able to add this interaction, and it looks especially cool if you move the cursor over the preview screen quickly.

I did also add another interaction with the color changing. When the user clicks the mouse, the colors of all the boxes change!

Embedded Sketch

Click your cursor to change the color!

Reflection and ideas for future work or improvements

I enjoyed getting more creative for this work and taking inspiration from the works in the magazines provided. I would love to continue exploring generative art in my work and try to add more elements of interactivity. I definitely want to work on understanding the rotations and angles on p5.js so I can add that to my code.

Week 2 Generative Art Post Zere

    • My concept of this week’s generative art task is an apartment building in a big city. Using the “random” function, I made the windows show different colors each time the mouse is clicked, reflecting that each resident has different stories happening to them every day.
    • I came about this idea when experimenting with functions and watching YouTube tutorials for gen. art.  . YouTuber Patt Vira created a tutorial on random smiley faces generative art, and the changing colors reminded me of lights reflected in people’s windows at night. I chose Starry Night by Vincent Van Gogh as the background. I saw the original painting at MoMA in NYC, and I was reminded of New York when creating this piece of work, which is why I chose this painting as the background.
    • Piece of code that I am proud of: the changing of the window’s colors. There’s a dynamic change in art, as well as loops used, that prevented me from creating each rectangle manually.
    • Embedded sketch:

  • let bg;
    
    function preload() {
      bg = loadImage("starrynight.jpg");
    }
    
    function setup() {
      createCanvas(400, 400);
      noLoop();
    }
    
    function draw() {
      // Starry Night background
      image(bg, 0, 0, width, height);
    
      // Building
      fill(51, 0, 0);
      noStroke();
      rect(10, 20, 300, 390);
    
      // Door
      fill(255);
      rect(135, 300, 60, 90);
      //Doorknob
     stroke(0);
      strokeWeight(2);
      circle(190,345,10)
      // Windows
      stroke(0);
      strokeWeight(2);
    
      for (let y = 40; y < 260; y += 60) {
        for (let x = 40; x < 280; x += 60) {
          fill(random(200), random(200), random(200));
          rect(x, y, 40, 40);
        }
      }
    }
    
    function mousePressed() {
      redraw();
    }
    
    

     

  • Reflection and ideas for future work or improvements: I’m proud of this sketch because it creates a colorful grid of windows that changes every time you click, making it interactive and fun. In the future, I’d like to make the colors change gradually or add more shapes to make it even more dynamic.

Week 2 – Reading Response | Casey Reas @ Eyeo2012

There is often a debate about how the universe works. Are we really in control of what decisions we make, or has some otherworldly being already written them for us? Is destiny real? Are the things we deem unpredictable actually predictable, and when people say they’re unpredictable… are they really? 

These same questions can be made about artwork. Older (“traditional”)  artwork was very methodical; we could fit artwork into different “eras,” find commonalities within artworks in certain eras, understand a very specific technique that artists would follow during a certain period of time or in a certain geographical area. However, now with our unlimited access to the internet and the rise of globalization, art has branched out significantly. We have shifted from order to chaos – we have people raising questions about which artwork is better (the usual digital versus traditional artwork battle), who decides what art is, and whether that shovel in the corner can actually even be considered artwork! (For this one, we’ll have to ask Duchamp himself.)

I found this talk interesting and I found that many arguments linked to my conversations in other classes. In Understanding Interactive Media, we discussed procedural art; art that is more focused on the process, and not the end product itself. One example I want to discuss in relation to this video is Sol Lewitt’s “Wall Painting”. In this artwork, the same set of instructions are given to everyone – draw 50 points anywhere on a continuous stretch of wall, and then draw lines connecting these dots. Yet, every artwork that comes from these instructions come out differently – super random! The reason I bring this up is because I feel that in this video, we discuss whether there is true randomness in artwork. Randomness allows you to remove your own egos and “preconceived notions” from creative processes (or at least, that’s what artists like John Cage and Marcel Duchamp believe). Randomness is a jumping-off point to get outside your own ideas of correctness.

The thing with algorithms, however, is that even when you code something to be random, there may eventually be a point that the code reaches where it stops being random, especially in generative art. Depending on the complexity of the code, it may become the same earlier, or may take a very long time, but Reas discovered that it eventually will reach homogeneity. Humans cannot replicate the same drawing the exact same ever, but computers can eventually. Hence, how random really is randomness? You can add some randomness to keep a system homeostatic, to keep it consistent but also remain dynamic, but even then, this is still a confusing concept to me. Even with the example of Mondrian explaining that the grid can still be used to represent pure feeling, through his physical brushstrokes being visible, that made me wonder about the difference in human and computer artwork.

In regards to making my own generative artwork, I made it before watching the video completely. Even when making it, I knew that no two artworks would be the same at the beginning, but eventually, at some point (whether it be in a thousand runs or even millions), there will be a moment where my artwork will be the same as another iteration earlier. Thus, maybe we can also acknowledge randomness depending on scale and complexity. Maybe the art we code doesn’t have to be 100% random, because maybe we will never be able to reach that certain percentage. However, within the percentages we can reach, we can play around with them and have fun.

Week 2 – Generative Artwork – Kamila Dautkhan

Concept:

let a = 0;
let b = 0;
let c = -1;
var z = 0;
var cef = 45;

function setup() {
  createCanvas(1000, 1000);
  background(200);
}

function draw() {
  
  translate(width/2, height/2);
  rotate(b);
  
  for(let i=0; i < 500; i++){
    
    let x = b*sin(i*300 + c -(a*23));
    let y = 100*a*cos(i*100 + b * c);
    
    let xx = 15*PI*cos((cef+30)*i+z);
    let yy = (45+z%10)*PI*tan((cef-30)*i+z);
    
    stroke(0);
    point(x,y);
    point(xx,yy);
 
  
}
  
  a++;
  b+=0.1;
  c-=5;
  z+=0.01;
  if(1) {
    //cefInc = -cefInc;
  }
  if(cef > 7200) {
    cefInc = -cefInc;
  }
}

 

I personally really appreciate minimalist artworks that is why I created this generative art piece. For me, this piece is about how much mood and tension you can create with almost no visual information at all, and how something that looks quiet and minimal on the surface can still feel alive and constantly shifting underneath. I just wanted to force the focus onto rhythm, contrast, and empty space. I did not use any colors other than black and white to create a sense of sophistication. Also, I think if I added other colors it might be distracting for the audience. It’s meant to be looked at slowly. The longer you stare, the more small patterns and tensions appear between the shapes. 

Code I am particularly proud of:

  let xx = 15*PI*cos((cef+30)*i+z);

  let yy = (45+z%10)*PI*tan((cef-30)*i+z);

I am especially proud of this little detail: z % 10 because it introduces a subtle pulse in the y‑movement, so the motion doesn’t feel flat or robotic. It’s a small trick, but it adds character

 

Reflection:

This generative piece that I made showed me how much I can get out of very little. With just a few evolving variables and some trigonometric functions, I ended up with two overlapping systems of points: one smoother and orbital, the other more unstable and spiky. Their interaction creates a black and white field that feels both structured and slightly out of control, which is exactly the mood I was thinking of. For the future improvements, I would like to make it more interactive for the audience by letting the mouse directly influence the main parameters in my system. For example, the horizontal mouse position could control cef, slowly changing the structure of the tan based pattern, while the vertical position could affect a or z, changing the scale.