I couldn’t get very creative with my idea. It was hard trying to think of a fun pattern, I went over my class notes and played around with colors hoping I would get inspired but it was still very hard. the more I played around with the code I was able to see some sort of idea come out of it. My idea is is a colorful street. the dots in the center is supposed to represent a moving road, and the colorful squares are the top of the passing by buildings. the outcome really reminded me of a game but it can give headaches if one was to stare for to long. To be more specific it reminded me of pac man, so I decided to recreate it, or atleast attempt to recreate it.and here are my results.
int w= 30;
int x = 20;
int h = 600;
int center= h;
int paracenter = 100;
void setup(){
size( 600, 600);
background(255,20,147);
rectMode( CENTER);
//noLoop();
}
void draw(){
//circle(300,300, 400);
for (int i = 0; i<width; i+=w){
fill(random(255),random(255),random(205));
rect(random(i+ w/2), random(center-50,center+50), x, 100);
rect(random(i+ w/2), random(paracenter-50,paracenter+50), x, 100);
fill(239,255,0);
arc(25, 355, 90, 90, 0, TWO_PI - QUARTER_PI , PIE);
fill(random(0));
fill(random(255));
circle(i+w/2,350,20);
}
}
For this week’s assignment, we were asked to incorporate both types of loops, specifically for() and while(), to showcase some various animations, loops, and conditionals.
During the process of making this, I had to go back and rewatch all of the previous class videos from the past two weeks, various Youtube videos online (Dan Shiffman’s are really helpful, will definitely watch more of his videos), and also some other coding tutorial websites and practices online in order to get a better understanding.
Originally, I wanted to make it similar to this sketch of mine, but I mainly struggled with creating the floating rectangles. My original plan was to use the loops to create multiple rectangles to float in randomly generated directions as well as its colors, but I was unable to do it. However, I will make sure to learn it in my spare time.
For this particular assignment, my main personal objective was to utilize both for and while loops in my code and to be able to generate random movements and animations as well as colors. Thought it may be extremely bright to look at due to the different colors changing randomly, I hope you guys like it. Another problem I encountered was when I wanted to use a void mousePressed() function where by clicking the mouse, all the colors would change back to grey or black colors as the compiler stated “unexpected token: void”. This can be found at the bottom of my code where a huge section was disabled with the //. I was unable to figure out why it had appeared this error.
What I found particularly difficult with this assignment is coming up with an idea. Having a lot of freedom resulted in me not knowing where to start. As I was looking for inspiration, I came across a bunch of gifs for breathing and meditation exercises. Here are some examples.
I see these a lot online and have always found them relaxing. So, I decided to recreate the concept using loops.
After some brainstorming, I settled on using the arc function and a for() loop. Here is the process of how I got to my end result.
First, with the map function, I was able to draw an arc progressively from left to right. I then added the for() loop to get multiple arcs filling the space underneath the first one.
Within the for() loop, there are variables changing the size of the arc the further we are in the for() loop. The same thing happens to the speed of the moving arc so that the arcs don’t all get drawn at the same time.
Then, using the translate() and scale() functions, I recreated the same shape going from right to left instead. I made sure to put this block of code between the pushMatrix() and popMatrix() functions to not affect the rest of my code.
I then put the two together and changed them to different colors for visibility. I also shifted each piece 1 pixel to its side to slightly separate the two.
To achieve my final piece, I added slight finishing touches.
I changed the speed of the moving arcs to get a more fluid shape, and I added some colors.
I tried to mimic the colors of a sunset/sunrise with the left shape for a more relaxing feel, and I made the right shape grey to give the illusion of something filling up and then emptying out, thus mimicking the rhythm of breathing.
Here is my code!
void setup() {
size(500, 500);
}
void draw() {
background(0);
//declaring variables for the colors of the arc
float r1=51;
float g1=102;
float b1=154;
color c1 = color(r1,g1,b1);
// the speed
float speed = frameCount*1.2;
//the size of the ellipse of the arc
float x= width;
float y=height;
for(int i=1 ; i<30; i++){
float arc1 = map(sin(radians(speed)), -1, 1, 0, 180);
float arc2 = map(sin(radians(speed)+PI), -1, 1, 0, 180);
//left shape
strokeWeight(5);
noFill();
stroke(c1);
arc(width/2-1, height, x, y, PI, PI+radians(arc1), OPEN);
//right shape
pushMatrix();
translate(width/2,height/2);
scale(-1,1);
strokeWeight(5);
noFill();
stroke(50);
arc(-1, height/2, x, y, PI, PI+radians(arc2), OPEN);
popMatrix();
//changing the size of the arcs and their speed the further we go in the for loop
speed -=5;
x -= 20;
y -= 20;
r1 += 10;
g1 += 1;
b1 -= 3;
c1 = color(r1,g1,b1);
}
}
For this week’s assignment, we were asked to do an art piece with the use of loops. Personally I feel like my previous week’s assignment, the self-portrait, was a fabulous piece of art. However, I needed to implement the use of loops in my piece, so I used for-loops and nested for-loops to create an introduction for Sir. Got Milk Nathan.
One thing that I hope my code can have in the future is implementing more complicated uses of loops and other functions. This week, some of the harder codings were just figuring out nested loops and implementing a timer mechanic based on frameCount. I also like how people implemented external photos and code snippets into an art piece, I think that produces better effects and I’ll try to do that too.
For this assignment, I created an artwork where you can see a group of wheel-looking objects rotating in different sizes. Personally, this resembles the solar system because the wheels seem to have their own orbits and rotations in place. The wheels are comprised of equally sized rectangles and they create an effect that looks like pulses. Enjoy!
As I was brainstorming for this exercise, I came across a recreation of Joy Division’s Unknown Pleasures album cover that incorporates looping and the noise function to animate the same mountain-like structure.
This led me to think of the album art of one of my favorite artists, Tame Impala. I looked some of the artwork up and it felt like something I could recreate using geometric shapes, loops, and the noise function.
I recalled the lyric video for “Feels Like We Only Go Backwards”, and this particular frame inspired me. I wanted to attempt to recreate it and add an element of animation or flow.
I thought: “this shouldn’t be too hard, right?” Weeeelll, I did struggle quite a bit with recreating the exact image I had in my head, so I will take you through my various attempts and takeaway from this assignment.
Attempt 1: Using Equidistant Lines in a Triangle Form:
My approach here was going through a loop and drawing multiple vertical lines close to each other in the form of a triangle and then apply noise() to each of these lines to create a stream that’s narrow and then widens near the edge of the screen.
This didn’t work, as the noise function created a uniform movement where all the lines leaned together in one direction. Even when increasing and decreasing the input value to get more random movement, I didn’t get a smooth wave like I had imagined, the change in X was consistent for all the lines creating a beam-like movement rather than a wave.
Attempt 2: Using Points to Create a Diagonal Side
Then, inspired by this tutorial, I tried to take a different approach using Point(), where I draw the triangle sides as points and then apply the noise() function to the x value of each point. I used two variables for noise, the second one called xOffset which creates the animation.
This way, I got closer to the movement I wanted, but it was still off, because I wanted the whole shape to flow as one, and this was too random to achieve that.
Finally, I decided that the most suitable approach would be similar to the one in the tutorial I linked earlier, to create a 4-sided shape (close to a rectangle or square) by drawing vertical equidistant lines through a loop and applying a noise() function to my X-value that takes a scaled Y for the first input, and an xOffset variable as the second input. This was the closest I got to my initial goal, but I think it could still be more accurate to the inspiration image.
This exercise really challenged my understanding of the thought process required for loops and the noise function, specifically how to choose values to input into the function. I went through our code in class and then followed any tutorials I could find on YouTube which helped make the concept more understandable. However, I still think that achieving my goal with this artwork could have been possible with the first two approaches I used, but it definitely requires more confidence with the concept of Noise(), so I might go back to these approaches after more practice.
Ironically, at some points, it really did feel like the more I tried the less progress I made (very in line with the song title), so it was a bit frustrating. Nonetheless, this exercise was a great way to work on my skills in using sketches and trial to translate an image I have in my head to code and to be patient and kind to myself when things don’t work out as well as I thought.
Have a look at my code, and make sure you go listen to Feels Like We Only Go Backwards!
color bgColor = color(240,245,230);
color upperLeft = color(221, 28,26);
color upperRight = color(111,156,235 );
color lowerLeft = color(7,42,200 );
color lowerRight = color( 249,240,0);
float xOff = 0;
float yOff =0;
PImage img;
void setup(){
size(400,400);
//image from noun project, artist: Maxim Kulikov
img = loadImage("noun_Head_2053552TWO.png");
}
void draw(){
background(bgColor);
// loop 1, upper left corner
for(float y = 0; y<height/2; y++){
strokeWeight(4);
stroke(upperLeft);
//pushMatrix();
//translate(150,0);
//rotate(radians(45)); // and attempt to make it look as if it is diagonally flowing out of the head. current shape looked better in my opinion.
line(width/2*noise(y/100,xOff),y,width/2,y);
//shifting the "wave" horizontally and decreasing opacity
stroke(upperLeft,80);
line(width/2*noise(y/100,xOff) - 50,y,width/2,y);
stroke(upperLeft,60);
line(width/2*noise(y/100,xOff) - 100,y,width/2,y);
y +=1 ;
}
//loop2, upper right corner
for(float y2 = 0; y2<height/2; y2++){
stroke(upperRight);
line(width/2, y2, 200 + width/2*noise(y2/100,xOff),y2);
stroke(upperRight,80);
line(width/2, y2, 250 + width/2*noise(y2/100,xOff),y2);
stroke(upperRight,60);
line(width/2, y2, 300 + width/2*noise(y2/100,xOff),y2);
y2 += 1;
}
//loop3, lower left corner
for(float y3 = height/2; y3<height; y3++){
stroke(lowerLeft);
line(width/2*noise(y3/100,xOff),y3,width/2,y3);
stroke(lowerLeft,80);
line(width/2*noise(y3/100,xOff) -50,y3,width/2,y3);
stroke(lowerLeft,60);
line(width/2*noise(y3/100,xOff)- 100,y3,width/2,y3);
y3 +=1 ;
}
// loop 4, lower right corner
for(float y4 = height/2; y4<height; y4++){
stroke(lowerRight);
line(width/2, y4, 200 + width/2*noise(y4/100,xOff),y4);
stroke(lowerRight,80);
line(width/2, y4, 250 + width/2*noise(y4/100,xOff),y4);
stroke(lowerRight,60);
line(width/2, y4, 300 + width/2*noise(y4/100,xOff),y4);
y4 += 1;
}
//incrementing the Y val of the noise function to create movement.
xOff += 0.01;
imageMode(CENTER);
image(img, width/2, height/2);
}
At first, I couldn’t think of any ideas and I considered doing something similar to the mobile app game “Rolly Vortex”.
But then I realized this is more of a cool game rather than an interesting art piece and that I can save the idea for a later more complex project.
I didn’t go far but rather kept the idea of things spiraling and a sphere bouncing around by a cartoon-chalk-like implementation of our solar system.
I decided to use the random function heavily to create somewhat of a dynamic outer space background.
I then improved the functions to make them seem more random, made the screen bigger in size, allowed the planets to randomly change color, and made the sun orange-yellow.
I also made use of the beginShape() function to draw the asteroids (celestial objects) which fly about around the planets and I made them more than the planets since that is the case in real life with their smaller size.
I also chose a color spectrum for the planets that is somewhat possible in real-life to make them more recognizable. I decided to not really make the colors exactly like real-life nor the number of planets because that is unnecessary and would create traffic on the art piece.
I created some stars which place randomly around the plane, and which are the background that give the sense of outer space in the first place. The planets also move about randomly but at a small scale, and the asteroids move around much further than them.
int seed = 0;
int checkerWidth = 80;
int checkerHeight = 80;
float r = 0;
float g = 0;
float b = 0;
void setup() {
size(640, 550);
rectMode(CENTER);
}
void draw() {
background(#414a4c);
if (frameCount%10 == 0) {
seed = frameCount/10;
}
randomSeed(seed);
translate(width/2, height/2);
for (int k = 0; k < 720; k++) {
float x = random(-width, width);
float y = random(-height, height);
pushMatrix();
strokeWeight(1);
stroke(255);
fill(255);
ellipse(x, y, 3, 3);
popMatrix();
}
for (int i = 0; i < 360; i += 1) {
float x = random(0, 10);
float z = random(80, 125);
pushMatrix();
rotate(radians(i));
strokeWeight(3);
stroke(#FDB813);
line(x, 0, z, 0);
popMatrix();
}
for (int j = 0; j < 360; j+=60) {
float x = random(120,150);
float y = random(120, 150);
r = random(64, 253);
g = random(60, 190);
b = random(0, 40);
pushMatrix();
rotate(radians(j));
strokeWeight(2);
stroke(0);
strokeWeight(0.5);
fill(r, g, b);
ellipse(x, y, 40, 40);
popMatrix();
}
for (int j = 0; j < 360; j+=random(40,60)) {
float x = random(160,180);
float y = random(160, 180);
pushMatrix();
rotate(radians(j));
strokeWeight(2);
stroke(0);
strokeWeight(0.5);
fill(#93928c);
beginShape();
vertex(x, y);
vertex(x+random(10,20), y-random(10,20));
vertex(x+random(20, 25), y-random(5, 10));
vertex(x+random(25,35), y);
vertex(x+random(20,25), y+random(5,10));
vertex(x+random(10,15), y+random(15,20));
endShape();
popMatrix();
}
}
I feel like with the knowledge of OOP and classes furthermore in the course, I will be able to master Java much more and achieve much more complex goals I have in mind.
My inspiration came from the moving rectangles we drew in class. there was something calming about watching the rectangles move. I knew I wanted to do either an ocean or wave theme, where it would be kind of calming to watch. Although I didn’t have an initial sketch of exactly what I wanted my art to look like, I had an idea. I wanted something with moving triangles as well as overlapping objects.
After doing some reasearch on kinds of images or shapes I could use, I found a 3D sphere which I thought would be perfect. After spending sometime figuring out how to rotate it, and adjusting it to my screen, I ended up with this.
This was actually a really interesting movement of art. Because I liked it so much, I was set out to create a smaller solid sphere to insert inside, and rotate the other way, so It felt like a energy source. However, I later decided I wanted to stick with my original theme of the ocean and work with that.
When creating a custom moving gradient background failed, I decided to find an image online, and rotate it to look like the water was moving. I made sure to rotate the image in the opposite way. When adding a full image, a lot of the details and sides of the sphere go missing (as shown in the final art) because of the Z coordinates. Although this was heart breaking for me, it was almost perfect to what I had envisioned earlier. I still wish to pursue the ‘ball of energy’ art model, but hopefully that will be for another time.
For my second assignment as I was brainstorming I came across a photo of the Nokia 3310 and I remember the snake game that the phone used to have. I was reminded about how complicated the snake got as the game continued as it got longer. For the assignment I then decided to make that exact pattern but the direction and the orientation will be determined by the computer. The framecount determines when to call the change orientation and direction functions. For the orientation, when called it simply changes from x to y or vice versa. For the direction, it is determine by the modulus of a random number.
To make the line more interesting, color is added to the point. Whenever a new point is drawn it is drawn with a new color, when the change color function is called, the red, green and the blue values are changed by 1. This gives the effect of a smooth color transition.
void setup() {
size(640, 480);
}
int x = floor(random(640));
int y = floor(random(480));
int orientation = floor(random(10))%2; // 0 -> x, y -> 1
int direction = floor(random(10))%2; // 0 for up or right | 1 for down or left
//colors
int r = floor(random(255));
int rAddition = 1;
int g = floor(random(255));
int gAddition = 1;
int b = floor(random(255));
int bAddition = 1;
void draw() {
// println(x,y); // debugging code
int length = floor(random(7)); // to determine of segment
for (int i=0; i< length; i++)
{
strokeWeight(10); // make the point thicker
drawPoint(); // draw a point
updateCoordinate();
offScreenFix();
}
int nextInterval = floor(random(25, 60));
if (frameCount%nextInterval ==0) // to change the direction
{
orientation();
direction();
}
changeColor();
}
void offScreenFix() {
//if point off screen
if (y>478) {
y-=1;
println("off screen");
} else if (y<2) {
y+=1;
println("off screen");
}
if (x>638) {
x-=1;
println("off screen");
} else if (x<2) {
x+=1;
println("off screen");
}
}
void updateCoordinate() {
if (orientation == 0) {
// do x operations
if (direction == 0) x+=1;
else if (direction ==1) x-=1;
} else if (orientation == 1) {
// do y operations
if (direction == 1) y+=1;
else if (direction == 0) y-=1;
}
}
void orientation() {
if (orientation==0) orientation = 1;
else if (orientation==1) orientation = 0;
}
void direction() {
direction = floor(random(10))%2;
}
void drawPoint() {
stroke(r, g, b);
point(x, y);
}
void changeColor() {
if (r==255) {
rAddition = -1;
r += rAddition;
} else if (r==0) {
rAddition = 1;
}
if (g==255) {
gAddition = -1;
} else if (g==0) {
gAddition = 1;
}
if (b==255) {
bAddition = -1;
} else if (g==0) {
bAddition = 1;
}
r += rAddition;
g += gAddition;
b += bAddition;
}
For this exercise I changed some parameters in the for() loop building upon the code we started writing during class. I wanted to experiment more with color and random(). Here, the color of the background is changed on mouse click while the larger ellipses and rectangles change colors randomly. To me, the outcome looks like a whirlwind of confetti. Accidentally, the screen recording captured a song of the RealAD show which I was listening to in the background. This started a new idea for creating a Processing artwork that reacts to sound but this will have to wait until I learn more about Processing and how it can react to different input.