All Posts

Assignment 2 – Creative Piece

Concept

Initially, I thought of making something with lines and creating some sort of an illusion. Then I remembered something I saw in Brooklyn’s Botanic Garden during my study away. It was a series of lights in lines converging into one single point. It looked amazing in the dark and I was really inspired by its pattern, so I thought of recreating it.

I feel like the pattern came out exactly as I wanted it to be, maybe even better because it changes color based on the position of the mouse. Once I was done with the lines, I made triangles to give a 3D effect so it seems like the pattern is inside a cube.

Implementation

I had to think quite a lot about where to place the lines and where to converge them to give the illusion effect. Especially since we had to implement the pattern using for loops, I had to think about where I had to place the “i” to change the position of the lines in the way I wanted.

The two main sections of my code are where I implemented the for loops for the changing-color lines and for the top and bottom triangle patterns.

The first one for the changing-color lines is below:

// creating a for loop for the changing line patterns on the left and right
// loops till the width in steps of 5, the steps define the spacing between the lines
for (let i = 0; i < width; i = i + 5) {
  
  // changing color patterns, increase mouseX for more red and increase mouseY for more green
  stroke(mouseX - random(255), mouseY - random(255), random(255));
  
  // dividing pattern into two halves (left side and right side) and making separate lines for each
  
  // left half
  line(0, i, mouseX, mouseY);
  
  // right half
  line(width, height - i, mouseX, mouseY);
}

I played around with the color-changing part until I was satisfied with the color combinations I achieved. The lines were made in two parts, the left half and the right half. This gave a triangle effect (two triangles on the left and right changing colors) without actually creating triangles. The starting points for the lines were changed using the for loop and the ending points were always the mouse position.

The second one for the top and bottom triangle patterns was done using the following for loop:

// making a for loop for white triangle patterns on top and bottom
for (let i = 0; i < width / 2; i = i + 10) {
  noFill()
  stroke(100)
  
  // one point on the top left half of the canvas, one point on the mouse position, and another one
  // on the top right half of the canvas
  triangle(i, 0, mouseX, mouseY, width - i, 0)
  
  // repeating procedure for triangles on the bottom half
  triangle(i, height, mouseX, mouseY, width - i, height)
}

I achieved this pattern by dividing the width into two halves (left and right sections) and then looping to make triangles from left to right. The converse was done from the right-to-left half as well. This gave me the white triangles that move based on the mouse position.
 

Reflection

I feel like I achieved exactly what I was going for in this assignment and the pattern turned out to look quite visually pleasing. I had the chance of showing it to my friends as well and getting their feedback and I subsequently added the triangle patterns on the top and bottom right after. Next time, I would like to use the mouseClicked() and keyPressed() functions to add even more user interactions.

 

Creative Art

Concept:

For this assignment, I started by exploring different types of computer graphics art that are possible to create, and I was fascinated by how much we could create and design by coding. From the book “Computer Graphics and Art,” I found the following pieces interesting and went on exploring different methods along this line.

 

 

 

Code and thought process:

To recreate this, I explored many functions which include, the noice(), translation(), and rotate() functions. Well, it took me a time to understand how to use the noice function worked in 1d, 2d, and 3d, and how to add proper resolution scale to smoothen it, but I believe it is one of the best functions that could be used. Following are some of the arts that I created.

 

 

 

 

After exploring different methods I could use I wanted to create something interactive but at the same time aesthethic so finally I created the following. I am part of that code that allows the mouse interaction.

Reflection& Ideas for improvements :

I would exploring and learning so much in this assignment, although one of the main obstruction for me in completing the assignmnet was that I lost my code when I completed most of it and thus had to start over. But over all was an amazing process. I could definitely could improve this by adding 3D rendering or to give an aesthethic look, by adding more shapes and a gradient background.

Assignment 2

Concept

For this assignment I wanted to include a couple of new elements such as adding sound and user interactivity, all of which I could not incorporate into the previous assignment.

I was interested in the artwork of an anonymous artist called “Banksy” who was known for his street art. He shredded one of his own art pieces in front of an auction house full of people right after it was bought and I have based my artwork on this.  This is his artwork after he had shredded it:

I did not have any particular art concept in mind but I knew I wanted to experiment with iridescent colors and add some sort of shredding effect as he did with his work. So I started off by creating an abstract iridescent element by using moving and color changing shapes. While experimenting with different color effects for the shapes, I came across the blendMode() which alters the colors displayed on the screen by either making them darker or lighter. By passing the argument “BURN” through this function, I was able to achieve this effect of fading/burning of the different colors and shapes into all black as the function increases contrast and makes the darker colors more prominent. I also added the sound of a paper shredder to add that effect of burning/fading, similar to what Banksy did.

 

Reflection

I think I learnt a lot of new features of p5.js through this assignment as I experimented with loops and color features as well as sound. I am happy with the fact that I was able to make the sound and burning effect work. For future projects, I would like to make use of “rotate()” and “translate()” because I tried using them in this assignment but I was not able to make it work. 

 

Homework 2: Work of Art

For this assignment, our task was to create a simple artwork using for loops and our knowledge from previous classes.

Initially I filled the canvas with a grid of rectangles and circles in a static manner. To make this pattern, I used a double for loop to draw the shapes over the y-axis and then the x-axis.

Then to increase interactivity, I changed the width of the squares and the circles to change dynamically based on the position of my mouse. To do this. I used the dist function to compute the distance from the position of the mouse. I had to spend a lot of time on how should the function be linked to the shapes. I realized the solution was actually much simpler that what I was trying to do initially.

My solution in the start was only plain white shapes so the most challenging part of the pattern was adding color. I had to do a lot of research and trial and error to understand how could I change the color of where I am hovering on the canvas. For this purpose, I eventually reached at the solution of using a map function within the fill function to change the color of where I am hovering only.

I further wanted the canvas to change color continuously on its own as well alongside the hover, for which I added the hue variable after setting the colorMode from RGB to HSB. Integrating this feature, was a challenge to achieve because I was not working with the ‘mod %’ function in the start so kept running into errors.

Below is the canvas for my artwork:

Reflections:

The assignment was an exciting one to work with. I really wanted to work with interactivity and in particular the draw function after my assignment 1. I got to work very creatively to create this piece using different functions within the draw function which allowed me to add dynamically changing shapes and colors. As I had never before used some of these functions, most of my time was spent on understanding their use correctly and debugging them. In the future, I think it would be interesting to try changing the number of shapes on the screen dynamically as well.

Week-2_Aibar

 

In this assignment we had to use our previous knowledge gained in class along with for() and while() loops to create a simple work of art. I decided to go with the for() loop and create some type of symmetrical work of art with some additional features as ability to change the background color by clicking the mouse and moving animation. This artwork is composed of a grid of black dots connected by white lines, which move with an oscillating animation and are framed by a changing background color.

Concept

This artwork explores the concept of symmetry and movement. The grid of black dots represents order and stability, while the moving white lines create an element of motion and energy. The constantly changing background color further emphasizes the sense of dynamism and highlights the symmetry of the artwork.

My initial in-class work was static and did not contain any kind of additional features as background change and movement of lines.

Draft 1

Highlight of some code

To create the basis if the artwork I first used for loop to create some symmetrical grid using small rectangles. The below code depicts the code:

for (x = m; x <= width - m; x += m) {
    for (y = m; y <= height - m; y += m) {
      noStroke();
      rect(x - 1, y - 1, 3, 3);
      stroke(255, 100);

After creating the basis, I started to draw the lines connecting the rectangles from different coordinates. The lines move in a circular, oscillating pattern around the grid of black dots, creating an interesting visual effect. A highlight of some code that I am particularly proud of is this circular movement of lines in oscillating pattern utilizing  sin(frameCount / 20) * 20 and  cos(frameCount / 20) * 20.

// Symmetrical lines with animation
   line(x, y, width / 2 + sin(frameCount / 20) * 20, height / 2 + cos(frameCount / 20) * 20);
   line(x, y, width / 2 + sin(frameCount / 20) * 20, 0 + cos(frameCount / 20) * 20);
   line(x, y, 0 + sin(frameCount / 20) * 20, height / 2 + cos(frameCount / 20) * 20);
   line(x, y, width / 2 + sin(frameCount / 20) * 20, height + cos(frameCount / 20) * 20);
   line(x, y, width + sin(frameCount / 20) * 20, height / 2 + cos(frameCount / 20) * 20);

Reflection

After some reflection on my project I identified couple of ideas for future improvement. Future improvements to this artwork could involve adding more elements to the grid of black dots, such as circles and other shapes, as well as introducing more colors to the background and adjusting the speed and intensity of the lines animation. Additionally, it could be interesting to experiment with different musical styles and incorporate sound into the artwork to further emphasize the sense of motion.

Assignment 2 – Artwork

Concept:

For this assignment, I did some research on generative artworks in p5js. After browsing some of the published work on the blogs found here, I got inspired to create an artwork which will pay homage to old computers, or, more specifically the green letters on black background found in retro devices. This way I was able to connect two different levels of the computer evolution which itself is evidence of our progress.

Code and realization: 

As a person with little experience in coding, this assignment was a great challenge, especially trying to avoid getting stuck into infinite loops as in my case I used an if loop inside of the for loop. The past classes on loops and basic shapes helped me create the grid of lines which are then altered as the mouse cursor moves over them.

Here’s a segment of the code I am especially proud of as it took me several trials and a lot of debugging to get it working:

for (let y = spacing/2; y < height; y += spacing) {
    let offset = map(mouseY, 0, height, -spacing/4, spacing/4);
    if (abs(y - mouseY) < spacing/2) {
      offset = offset * 2;
    }

This part of my program controls how the lines react to the mouse movement, especially if the y coordinate of the line is less than the y coordinate of the mouse.

Final Product: 

Reflection: 

This assignment was a great way to express our creativity and thought process. While I managed to get the program to work and be interactive, I feel like I can improve its interactivity and add more elements in the future.

Assignment 2: Creative Piece!

Concept

As part of the second assignment, for which the task was to produce a creative piece, something that caught my attention was the following image from COMPUTER GRAPHICS AND ART Aug1977.

Therefore, I decided to replicate that, but not only replicate a single instance, but make it interactive such that I can essentially see every single one of the types of squares. Starting off with a basic Mouse Movement in the in-class exercise, I built upon it to make it move periodically over a speed as an automated animation. When that was done, I moved forward with adding more colors and making it playful! If you press the RIGHT ARROW, LEFT ARROW, or the ‘a’ key, you can add specific colors!

The reason I made the animation squares move automatically in the manner seen below was to replicate the old ‘DVD’ behavior in Screen Savers of Old Televisions!

Embedded Canvas

The final production for my assignment is as follows:

Code

While the entire code is well commented, and very concise (linked below), one specific segment of it that I would like to share is the use of a single for loop with a map function to change the x and y directions of the animations. I started the usage of the map function to make the animation follow the mouse movement, however I later adapted it to be an automated sequence.

  // A loop to draw the different squares
  for (let i = 0; i<230; i=i+20)
  {   
      // Fill with the dark backgrounds in the pyramid style
      fill(i,i,i);
    
      // To add the different colors with the key presses, such that they are added in an incremental way
      // For the Red Color
      if (i==redColorCounter){
        fill(255,160,122)
      }
      // For the Blue Color
      if(i == blueColorCounter){
        fill(0, 0, 255);
      }
      // For the Yellow Color
      if(i == yellowColorCounter){
        fill(255, 255, 0);
      }
      
      // Changing xPosition and the yPosition of the squares
      xPos = i*(map(xInc, 250, 500, 1.0, 1.9))
      yPos = i*(map(yInc, 250, 500, 1.0, 1.9))
      rect(xPos,yPos, 500-(i*2))
  }
  // Make the colors 'climb' the different squares in the animation
  redColorCounter+=20;
  blueColorCounter+=20;
  yellowColorCounter+=20;
}

 

Improvements

As a future step, I really want to use a modular approach with functions and eliminate any and all duplications or repetitions of similar code pieces. One example would be the movement in the x & y directions by adding a function (which I tried but was not working the way I wanted it to!).

The full canvas is linked here.

Assignment 2: Art and Programming

Concept:

Upon watching the video: Casey Rears – Chance Operations, I was quite inspired by the idea of programming fractals. The idea of fractal art has always piqued my interest as it always jelled in between states of chaos and order and it just always looked so mesmerizing. Hence, I decided to go along my assignment by creating a fractal piece of art.

Code and Thought Processes:

When I thought of fractals, my mind instantly went towards shapes such as diamonds, stars and multi-polygon shapes. Hence, after several testing, I decided to create some star like shapes. Upon exploring, p5js does not have a shape for stars, hence, I created a function that would generate a star for me:

function star(x, y, radius1, radius2, npoints) {
  let angle = TWO_PI / npoints;
  let halfAngle = angle / 2.0;
  
  beginShape();
  for (let a = 0; a < TWO_PI; a += angle) {
    let sx = x + cos(a) * radius2;
    let sy = y + sin(a) * radius2;
    vertex(sx, sy);
    
    sx = x + cos(a + halfAngle) * radius1;
    sy = y + sin(a + halfAngle) * radius1;
    vertex(sx, sy);
  }
  endShape(CLOSE);
}

I used this function from https://p5js.org/examples/form-star.html, where it essentially constructs a star shape. The arguments are the x and y coordinates of the shape (which is at the center), and I would have two radius, one for the horizontal shape of the star and one for the vertical shape of the star. I would also have the number of points the star can be. I essentially map the points together to create a star using the unit circle from trigonometry and connecting them together using the vector function.

I knew I was going to overlap my crystals over each other, however I wanted them to have some movement, hence I made them rotate at different speeds. This way it gives this really cool effect where they each sometimes align or sometimes are completely chaotic. It fits well with that chaos/order theme I was going for so it was a great addition. To do this, I created another function called drawCrystals(spin) which would draw a bunch of crystals over each other where spin is just the number of crystals spinning.

function drawCrystal(spin) {  
  for(let i=0; i<spin; i++) {
    rotate(frameCount/-1000);
    
    if (fade<0) fadeAmount=0.005;
    if (fade>255) fadeAmount=-0.005; 
    fade += fadeAmount; 
    fill(0, 0, blue_shades[i], fade);
    
    star(0, 0, ((10*spin + 70) - 10 *i)/2.333, ((10*spin + 70) - 10*i), 4);
  }
}

The size of the shape (determined by the radii) is simply calculated through a series of incremented sizes so that they all look congruent rather than weird shapes and sizes.

I decided to also add a cool fade effect. It’s really awesome because the background is black so it looks like they disappear momentarily and then appear back to life. This fade effect was inspired from another sketch which is linked here: https://editor.p5js.org/remarkability/sketches/rtM08miUD however I tweaked the values so it would fit with my code.

I also filled them with different shades of blue to fill that diamond-ish colouring, plus blue looks cool and is one of my favourite colours.

Finally, in the draw function, I simply just pushed, translated to a random coordinate on the canvas and drew the fractal shape with a random number of fractals and then popped. I repeated this process several times until all the fractals kind of covered the screen. With this, I was happy with my finished product.

Final Sketch:

Overall Thoughts and Improvements:

Overall, I think i’m happy with how it turned out, it was essence I was looking for when I wanted to create my artwork. Although some improvements I could have added are:

  • Perhaps some sort of glistening effect on the fractals.
  • Perhaps a 3D rendering of the fractals.
  • A cool idea would be where the fractals could grow and shrink at random sizes and intervals.
  • Maybe it would be cool is the fractals could move about the canvas to give it some nice lively effect to the art.

Week 2 – Art

Using For loops and some back and forth with shapes and values, I was able to produce this piece of art:

Below is the code for this project:

function setup() {
  createCanvas(600, 600);
}

function draw() {
   
      if (mouseIsPressed) {
        background(0);
        for(i=0;i<600;i+=10+mouseX/20){
          for(j=0;j<600;j+=10+mouseY/20) {
          fill(i/2,j/2,50)
          rect(i,j,15)
      
          stroke(i,mouseX,j)
          line(i,j,mouseX,mouseY)
          }
        }
      }
      else {
        background(0);
        for(i=0;i<600;i+=10+mouseX/20){
          for(j=0;j<600;j+=10+mouseY/20) {
          fill(i/2,mouseY,mouseX)
          rect(i,j,15)
      
      }
    }
  }
}

I decided to start with the For loop as that is the fundamental concept around which we were to build our program. After which, I decided on squares as my shapes due to their uniformity just being pleasant to look at for me. Once I had my rows and columns of squares, I started messing around with my values and variables, essentially experimenting what different effects I can achieve. I wanted to incorporate some sort of interactivity and decided to utilize the mouseIsPressed function in order to create some effect by clicking and holding the mouse. This led to me adding lines point to the cursor to give a sort of background light rays effect.

 

I am specifically impressed by how little lines of code it took me to create such a piece. I would initially think such an artwork would require many more lines of code but with some experimenting and utilization of functions, it took only around 30 lines.

There is definitely a lot more that can be done in order to improve this piece. I can definitely utilize different kinds of shapes and add more forms of interactivity. I look forward to seeing how I improve with time and what more I’ll be able to add in the future.

HW2: Generative Loop Art

Motivation

The motivation behind this project was to create a simple generative artwork using the p5.js library. The goal was to combine elements of randomization, user interaction, and geometric shapes to create a unique and visually interesting piece.

Concept

The concept behind the artwork is a grid pattern of randomly colored rectangles and ellipses. The user can interact with the artwork by moving the mouse, causing the size of the shapes and the stroke weight of the outlines to change dynamically. This adds a layer of unpredictability to the artwork, making each viewing experience unique. Moving the mouse across the x axis changes the size of the shapes, while moving the mouse across the y axis, changes the strokewidth.

Process of Implementation

The process of implementing the generative art can be broken down into two primary steps:

Generating the grid pattern of shapes in the draw() function:

function draw() {
  // nested for loops to create a grid pattern
  for (let i = 0; i < width; i += s) { 
    for (let j = 0; j < height; j += s) {
      // randomize the color and shape of each square
      fill(random(255), random(255), random(255)); // randomly generate a color for each shape
      if (random(1) > 0.5) { // randomly choose between a rectangle or an ellipse
        rect(i, j, s, s); // draw a rectangle
      } else {
        ellipse(i + s / 2, j + s / 2, s, s); // draw an ellipse
      }
    }
  }
}

Implement the mouseMoved() function to add user interaction:

// function to change the size and stroke weight of the squares on mouse movement
function mouseMoved() {
  s = map(mouseX, 0, width, 10, 50); // map the size of the shapes to the x position of the mouse
  strokeW = map(mouseY, 0, height, 1, 10); // map the stroke weight to the y position of the mouse
  strokeWeight(strokeW); // update the stroke weight with the new mapped value
}

Challenges

One challenge in this project was understanding the map() function and how it works to map one range of values to another. It was important to understand the arguments passed to the map() function and how it affected the output.

Another challenge was getting the grid pattern of shapes to line up correctly, as the size of each shape needed to be adjusted to create a seamless grid.

Reflections

This project was a great opportunity to learn about generative art and how p5.js can be used to create unique and visually interesting pieces by using loops. By implementing randomization, user interaction, and geometric shapes, I was able to create a simple but impactful generative art piece.

Link to p5 sketch: https://editor.p5js.org/swostikpati/full/3W7yvJ3yo