Car Example

You can download the sketch here: http://aaron-sherwood.com/carExample.zip

Car sportsCar;
Car miniVan;

void setup(){
size(640, 480);
rectMode(CENTER);
sportsCar = new Car(255,0,0,100,15,15);
miniVan = new Car(150,50,200,150,112,2);
}

void draw(){
background(255);
sportsCar.display();
sportsCar.move(0);
miniVan.display();
miniVan.move(2);
}

class Car{
int speed;
int w;
int h;
int red, green, blue;
float x, y;
float angle;
int radius=200;

Car(int r, int g, int b, int W, int H, int s){
speed=s;
w=W;
h=H;
red=r;
green=g;
blue=b;
x = 0;
y = random(height);
angle=0;
radius=200;
}

void move(int mode){
x+=speed;
if (mode==0){
if(x>width || x<0){ speed*=-1; } } if (mode==1) { if (x>width){
x=0;
}
}

if (mode==2) {
x = width/2 + radius * cos(angle);
y = height/2 + radius * sin(angle);
angle+=.01;
}
}

void display(){
fill(red,green,blue);
rect(x, y, w, h);
}

}

Variability in New Media

In “The Language of New Media” the author Lev Manovich talks about the evolution of new media and how this new concept and form of media took over everything that was previously known and used. He talks about the principles of new media and one that is specifically intriguing to me is variability. “New media is characterized by variability!” What is interesting is how much variability there is in new media compared to old media. With the advancement of computers it is now possible to create almost an infinite amount of variations that can be automatically generated by a computer. For example, even in Processing one can alter their creations in so many ways that would be impossible in old media. Variability also closely connects to interactivity, as the user can create new variations of the elements used in the object. I also liked the metaphor of a map used by the author when describing scalability (a principle od variability). Basically with the automatic generation it is possible to include as much or as little detail about the object as wanted, just like a map with different scales that also provides more or less detailed information about the area. I believe that all this variability is going to continue defining new media in the future and distinguishing it from other forms of media.

Assignment 8: Recreating Computer Art

This week’s assignment, which was to recreate one of the artworks from this article, was probably the hardest assignment of the semester for me. This, I realized, is due to my inexperience with coding and algorithm-based thinking. Hopefully, after this assignment, I will have a little more experience with those skills that I can put to use in future assignments 🙂

Many artworks in the article caught my eye, but the two I liked best were these:

the Dots piece (whose real name is Untitled Serigraphs):\

the Peacock piece:

However, I tried my hand at both and did not get where I wanted to be — with the first dots one, I could just manage to create a single line of ellipses. With the peacock one, I ended up with a sort of rough draft in which I found I was unable to do the lines within the circles.

My peacock piece draft:

So for Monday’s class, I decided to go for the simple shape-filled artwork. I honestly enjoyed doing it because I could do shapes quite easily, and it was a break from the frustration that I felt while working on the other two.

Here are the shapes:

 

However, I decided that I still really wanted to work on the dots piece, which had been my favorite artwork from the start, and so I got a TON (seriously, a lot) of help and finally arrived at this:

(Sorry for the unclear picture, but the screenshot was even worse.)

It’s not too much like the original, but I’m really quite happy with it because it is so much of an improvement from what I was able to do with it before. The code divides the image into a few sections — the uneven parts at the beginning and end, the two diamonds, and the part between the two. Here is the code:

void setup () {
 size (1000, 640);
 background(0, 0, 0);
 noStroke();
 rect(10, 9, 30, 619);
 rect(10, 598, 980, 30);
 rect(960, 9, 30, 619);
 rect(10, 9, 980, 30);
}

int addition = 0;
void draw() {
 println(mouseX, " ", mouseY);

 int radius =2;
 int spacing =7;
 int counter=544;
 int i = 1;
 int startY = 0;
 int endY = 0;



//first part of screen
 for (int x=63; x<120; x += spacing) {
 //ellipse(x, 329, radius, radius);
 boolean increase = false;
 for (int y=77; y<height-77; y+=spacing) {
 if (y>counter) {
 if (y>77 && y<177) {
 fill(175);
 } else {
 fill(255);
 }
 ellipse(x, y, radius, radius);
 increase = true;
 }
 }
 if (increase == true) {
 if (i == 4)
 counter -= 21;
 else 
 counter -= 7 * (i*7);
 i++;
 }
 }

//middle is 320

int lowD1=200;
int lowD2=0;
int highD1=440;
int highD2=0;

for( int x=120; x<300; x+=spacing){

 lowD1-=spacing/2;
 highD1+=spacing/2;

 if(x%3 ==0){
 //gonna have one that prints to all the way
 
 startY=0;
 endY=height-77;

 }else if(x%3 ==1){
 //one that prints from the top of the diamond to the bottom.
 startY=lowD1;
 endY=height-77;

 }else{

 startY=0;
 endY=highD1;

 }

 for (int y=startY; y<endY; y+=spacing){
 fill(175);
 //figure out shades later.
 ellipse(x, y, radius, radius);
 }


}

lowD2=320;
highD2=320;

for (int x=300; x<500; x+=spacing){

 lowD1-=spacing/2;
 highD1+=spacing/2;
 lowD2-=spacing/2;
 highD2+=spacing/2;


 if(x%3 ==0){
 //this one prints all the way to the bottom from the lowD2; 
 startY=lowD2;
 endY=height-77;

 }else if(x%3 ==1){
 //one that prints the larger diamond shape.
 startY=lowD1;
 endY=highD1;

 }else{
 //one that prints all the way to the top from the high D2;
 startY=0;
 endY=highD2;

 }

 for (int y=startY; y<endY; y+=spacing){
 fill(175);
 ellipse(x, y, radius, radius);
 //figure out shades later.
 }

}



for (int x=500; x<700; x+=spacing){

 lowD1+=spacing/2;
 highD1-=spacing/2;
 lowD2+=spacing/2;
 highD2-=spacing/2;


 if(x%3 ==0){
 //this one prints all the way to the bottom from the lowD2; 
 startY=lowD2;
 endY=height-77;

 }else if(x%3 ==1){
 //one that prints the larger diamond shape.
 startY=lowD1;
 endY=highD1;

 }else{
 //one that prints all the way to the top from the high D2;
 startY=0;
 endY=highD2;

 }

 for (int y=startY; y<endY; y+=spacing){
 fill(175);
 ellipse(x, y, radius, radius);
 //figure out shades later.
 }

}
//second last part of screen

for( int x=700; x<820; x+=spacing){

 lowD1+=spacing/2;
 highD1-=spacing/2;

 if(x%3 ==0){
 //gonna have one that prints to all the way
 
 startY=0;
 endY=highD1;

 }else if(x%3 ==1){
 //one that prints from the top of the diamond to the bottom.
 startY=0;
 endY=height-77;

 }else{
 startY=lowD1;
 endY=height-77;

 }

 for (int y=startY; y<endY; y+=spacing){
 fill(175);
 //add shades.
 ellipse(x, y, radius, radius);
 }


}

//last part of the screen

 counter=544;
 i=1;

for (int x=820; x<950; x+=spacing) {

 boolean increase=true;
 for ( int y=77; y<height-77; y+=spacing) {
 if (y<counter) {
 if (y>77 && y<177) {
 fill(175);
 } else {
 fill(255);
 }
 ellipse(x, y, radius, radius);
 increase=false;
 }
 }
 if (increase==false) {
 if (i == 4)
 counter-=21;
 else 
 counter-=7*(i*7);
 i++;
 }
 }

noLoop();

A few shoutouts:

To Aaron, for being incredibly patient and helping me to set the base for the code.
To UNIX lab friends and lab monitors, for answering all of my silly questions.
To my classmates, who without judgment threw out a bunch of really helpful suggestions to help recreate the dots piece 🙂

Thank you!

Response to Lev Manovich’s “The Language of New Media”

This was a highly information-dense reading, and so it took me a longer time than usual to finish the reading. I did enjoy reading it though — the parameters that Manovich is trying to define new media with are interesting. He makes sure to come at the definition process from many angles: first, he creates five categories to say what constitutes new media (numerical representation, modularity, automation, variability, transcoding). He then goes on to say what does not constitute new media, busting some common myths about defining new media. Finally, having established a sort of parameter for understanding what new media is, he goes on to explore how it relates with our society and culture.

Something I liked about Manovich’s analysis was the connection that he made between changing societies and the changing nature of new media. I particularly liked, like Mari, the point about trends in new media reflecting the cultural shift from a sort of mass public sphere into a more individualized, unique one.

I also liked the section on cinema. Manovich writes: “Cinema, the major cultural form of the twentieth century, has found a new life as the toolbox of a computer user. Cinematic means of perception, of connecting space and time, of representing human memory, thinking, and emotions become a way of work and a way of life for millions in the computer age. Cinema’s aesthetic strategies have become basic organizational principles of computer software. The window in a fictional world of a cinematic narrative has become a window in a datascape. In short, what was cinema has become human-computer interface.” I am currently taking a class in which we are exploring principles and strategies of film and cinema, and this connection was an interesting one.

Overall, this was an interesting read that A. taught me a lot about the general history of computers and new media and B. has gotten me to think about why these definitions might be necessary and important, and how they can affect my own projects as an IM student.

Computer Graphics and Art (replication assignment)

For this assignment I picked Simulated Color Mosaic by Hiroshi Kawano to recreate in processing:

From the first glance I already knew it would not be as easy as it looks, despite the fact it is made of simple shapes (rectangles).

I first started with trying to recreate it by making rectangles with the values I eyeballed so that whatever comes out looks somehow like the original piece of art. After a couple of rectangles I knew this is not going to work out, as I would spend too much time to place rectangles in the right spots and make them right sized by just eyeballing the values.

I realised I needed exact values and so I was thinking about using Illustrator to help me get the exact coordinates of every corner for every rectangle, so that then I could use rectmode(CORNER) to make a rectangle using two opposite corners. However, I found even easier solution, which was an online website which do the same thing: give me exact coordinates of wherever I click on the image.

So I ended up selecting all the corners I needed, which on the website looked like this:

However, having all the values, I thought it might be a little too tedious and take a bunch of time, since all I was looking at were endless digits and every mistake on my side would cause the whole thing go wrong and the pattern to be different from the original.

So about halfway into recreating the original, a friend of mine suggested that I make a pattern that looks similar but is not exactly the same, so I wrote this code that creates a similar-looking pattern and changes it 3 times a second.

void setup() {
size(610, 620);
background(255);
strokeWeight(0);
noStroke();
frameRate(3);
}


void draw(){
background(255);
for (int x=0; x< width; x++) {
for (int y=0; y< height; y++) {
if (random(1) < 0.0015) {
fill(0);
} else {
noFill();
}
rect(x,y,random(50), random(50));
}
}

}

This is how one of the endless amount of random patterns it creates looks like

However, with a little help this took me no longer than 10 minutes to write, so I felt like I had to do something more, more specifically finish my first idea of making an exact replica of the original artwork.

It took a while, because my eyes would often get tired and I would make lots of typos, but eventually I recreated Simulated Color Mosaic in processing. This is how my version of it looks :

and here again is the original

There are some minor differences that are not noticeable unless someone takes lots of time comparing them, at some point I just realised its time to give up and stop fixing every minor detail. But if you have lots of spare time, you can take on the challenge and let me know if you found them 🙂

The code for the replica is simply too long to attach and would take ages to scroll through to get to other people’s works, but if anyone is interested- feel free to ask, I will send it directly to you.

 

 

On Why New Media is New, But Also Kinda Old, and Everything In Between

(Response to The Language of New Media by Lev Manovich)

The sections of Manovich’s book that we were assigned attempt to define new media in technological, cultural, social, and historical ways. His chapters pack a lot of information about the concept, not only for the sake of definition but also to lay out what he thinks are the characteristics of new media, to validate or debunk commonly-held beliefs about it, to provide examples of new media by developers, artists, etc. and to trace the history of new media within the context of media in general.

It is this last aspect of the book that struck me the most. It often feels that Manovich wants to deal with too many faces of new media at once, a notion that I possibly have because I don’t fully understand all that he explains, but a common thread throughout the sections is his desire to tie new media back to its antecedents, and through this show how the new technologies and interactions that it encompasses did not come out of the blue. Manovich does this from the start, by bringing Charles Babbage’s Analytical Machine and J.M. Jacquard’s loom into the conversation, and continues to do so until the end, when he mentions Leon Battista Alberti’s On Painting among others.

I find that the “timeline” given by Manovich makes the development of new media more interesting, especially given that the book was published in 2001, and as a 2017 reader I can fill it in with new information. Understanding the many dimensions of new media, where it takes its influences from, and how it adapts them in different ways, makes the concept seem much richer, complex, and valuable than just a vague term to describe “what computers do.”

Tetragons

As I was browsing through the different computer graphics, many of them astonished me, but it was also quite a mystery how to recreate them. I must have jumped to the very beginning where everything started, however, just like computer graphics have experienced a major advancement in just a few decades, let’s hope that my work improves as well.

I chose a graphic with a lot of tetragons in it, and there was definitely something that spoke to me in this image. It was the messiness combined with the composition of the shapes in this graphic. Even though there is no symmetry going on, there is also something harmonic about how the shapes work together. I used a function called quad for each of the tetragons and it turned out to be the best function to use, as it essentially draws a four-sided polygon where the angle between two sides does not necessarily have to be 90 degrees. There are 8 values you need to determine for this function and they are the x and y coordinates for each of the corners.

The graphic consists of regularly shaped tetragons where all the 4 sides are of the same length and of irregularly shaped tetragons with different lengths of the sides and angles between them. To draw the regular tetragons I determined the coordinate of the center and measured the distance to the edges, which was the same in each case. That way I could draw a shape with the sides of the same length. For the irregular tetragons it was more challenging, as I had to determine the coordinate for each of the corners and also guess the coordinates of the points that are not in the image. I was usually not right with the first time, so I just had to keep changing the coordinates until I was satisfied with the result. I also added 4 lines as a frame for the sketch. This is the final result:

On the left is the original and not the right – my recreation. As you can see, the original is a little messier in the middle part as more lines are really close to each other there. In my recreation a lot of the lines in the middle are actually overlapping, therefore it doesn’t look as messy.

This is the code I used:

size (250, 350);
background (255,255,255);

noFill();

//squares
quad (105, 325, 75, 295, 105, 265, 135, 295);

quad (135, 235, 120, 220, 135, 205, 150, 220);
quad (130, 225, 105, 200, 130, 175, 155, 200);
quad (140, 225, 115, 200, 140, 175, 165, 200);
quad (93, 195, 75, 178, 93, 160, 110, 178);
quad (127, 170, 95, 137, 127, 105, 160, 137);

quad (150, 140, 135, 125, 150, 110, 165, 125); //the smallest


quad (115, 145, 85, 115, 120, 80, 150, 110);
quad (120, 310, 5, 195, 120, 80, 235, 195);

quad (110, 90, 75, 55, 110, 20, 145, 55);

//the rest
quad (160, 350, 40, 229, 156, 115, 350, 220);
quad (55, 245, 136, 160, 50, 70, -50, 154);

quad (200, 205, 85, 90, 168, -30, 390, -25);
quad (137, 164, 53, 78, 145, -80, 230, 75);

quad (225, 73, 180, 30, 225, -40, 300, 20);
quad (226, 55, 194, 25, 228, -40, 313, 16);

//the frame
line (0, 0, 250, 0);
line (0, 0, 0, 350);
line (249, 0, 249, 349);
line (0, 349, 249, 349);


Cubism, the Pyramids, and a Rainbow

For this week’s assignment, I was torn between two illustrations from Computer Graphics and Art that I found interesting. One was more complex than the other, or so it seemed to me, and thus I began trying out the more difficult one. Halfway through (realizing that option one would take a while), I decided to try my second option. I was eager to see it coded because, frankly, to me it is the more aesthetically pleasing one.

I copied Random Squares by Bill Kolomyjec, which appeared in Computer Graphics and Art in August, 1977.

The Processing sketch I made can be found online.

The generation of the squares is mostly based on randomness, as the code shows, in order to stay true to Kolomyjec’s title. I also added other features (stroke color and weight) that are not present in the publication’s image, which the user can control.

int columns = 7;
int rows = 5;
int gridSquare = 100;
//sides of each square on the grid
//thus, 7x5 squares on the grid
int squareSide = 20;
//sides of the "originating", smaller square within each square on the grid
boolean mouseP = false;
boolean keyP = false;
int hue = 0;
//used to set the stroke() in HSB color mode
int weight = 1;
//used to set the strokeWeight()
int loop = 0;

void setup(){
 size(700, 500);
 //canvas size corresponds to columns, rows, and gridSquare
 background(255);
 fill(0);
 textSize(22);
 text("Click here", 300, 250);
 //instructs the user to click on the canvas
}

void draw(){
 if(mousePressed && mouseP == false){
 background(255);
 textSize(18);
 text("Press UP or DOWN to change color.", 200, 210);
 text("Press LEFT or RIGHT to change stroke weight.", 150, 250);
 text("Press ANY OTHER KEY for black.", 200, 290);
 //lets user know about the features of the program
 fill(255);
 mouseP = true;
 }
 
 if(keyPressed && keyP == false && mouseP == true){
 background(255);
 if(keyCode == UP){
 colorMode(HSB);
 stroke(hue, 240, 240);
 if(hue != 230){
 hue = hue + 10;
 };
 }
 //UP key increases hue (230 is the maximum)
 else if(keyCode == DOWN){
 colorMode(HSB);
 stroke(hue, 240, 240);
 if(hue != 0){
 hue = hue - 10;
 };
 }
 //DOWN key decreases hue (0 is the minimum)
 else if(keyCode == LEFT){
 if(weight != 1){
 weight--;
 };
 strokeWeight(weight);
 }
 //LEFT key decreases stroke weight (1 is the minimum)
 else if(keyCode == RIGHT){
 if(weight != 10){
 weight++;
 };
 strokeWeight(weight);
 }
 //RIGHT key increases stroke weight (10 is the maximum)
 else{
 stroke(0);
 };
 //any other key sets stroke to black
 for(int i = 0; i < (columns*gridSquare); i = i + gridSquare){
 line(i, 0, i, rows*gridSquare);
 };
 //creates grid's rows
 for(int i = 0; i < (rows*gridSquare); i = i + gridSquare){
 line(0, i, columns*gridSquare, i);
 };
 //creates grid's columns
 line((columns*100) - 1, 0, (columns*100) - 1, (rows*100) - 1);
 line(0, (rows*100) - 1, (columns*100) - 1, (rows*100) - 1);
 
 for(int i = 0; i < (columns*gridSquare); i = i + gridSquare){
 for(int j = 0; j < (rows*gridSquare); j = j + gridSquare){
 int xDisplacement = int(random(10, gridSquare - squareSide - 10));
 int yDisplacement = int(random(10, gridSquare - squareSide - 10));
 rect(i + xDisplacement, j + yDisplacement, squareSide, squareSide);
 //creates "originating" square
 int divisions;
 if(xDisplacement < 40 || yDisplacement < 40 || xDisplacement > 60 || yDisplacement > 60){
 if(xDisplacement < 20 || yDisplacement < 20 || xDisplacement > 80 || yDisplacement > 80){
 divisions = int(random(2, 4));
 }
 else{
 divisions = int(random(4, 6));
 };
 }
 else{
 divisions = int(random(6, 10));
 };
 //randomly selects how many rectangles there will be between the "originating" square and the grid square
 int upperDivisions = yDisplacement/divisions;
 int lowerDivisions = (gridSquare - (yDisplacement + squareSide))/divisions;
 int leftDivisions = xDisplacement/divisions;
 int rightDivisions = (gridSquare - (xDisplacement + squareSide))/divisions;
 for(int k = 1; k < divisions; k++){
 line(i + (leftDivisions*k), j + (upperDivisions*k), (i + gridSquare) - (rightDivisions*k), j + (upperDivisions*k));
 line(i + (leftDivisions*k), j + (upperDivisions*k), i + (leftDivisions*k), (j + gridSquare) - (lowerDivisions*k));
 line((i + gridSquare) - (rightDivisions*k), j + (upperDivisions*k), (i + gridSquare) - (rightDivisions*k), (j + gridSquare) - (lowerDivisions*k));
 line(i + (leftDivisions*k), (j + gridSquare) - (lowerDivisions*k), (i + gridSquare) - (rightDivisions*k), (j + gridSquare) - (lowerDivisions*k));
 };
 // creates said rectangles
 };
 };
 keyP = true;
 }
 else if(!keyPressed && keyP == true){
 keyP = false;
 };
}

There is something visually satisfying about the illusion of depth in a 2D space that the squares accomplish. The effect makes the “denser” squares on the grid look like pyramids that point either inwards, towards the screen, or outwards, towards the user. I added the change of hue because I’m a great fan of bright colors and their variation along the visible light spectrum (which I also used in my previous assignment). Finally, I enabled changing the stroke weight because the effect the image completely, and in my opinion, makes it more interesting. It somewhat reminded me of Cubist paintings…

Maybe? Just a little bit?

Screensaver graphics

For this week’s assignment, we had the task of recreating an old computer graphic from a collection of volumes denominated “Computer Graphics and Art”. While I was first browsing through the examples in each issue, I was amazed by the beauty and complexity of the 3D artworks (and their resemblance to the old screensaver graphcis!) Below are some of the artworks that caught my attention the most:

Initially, with still no idea of how it was possible to create such effects simply by coding, I resorted to the internet and discovered the magic of using parametric equations and the sin() and cos() functions to create different line movements and combinations. After a lot of trial and error and some time when I reconsidered the possibility of recreating this type of graphic, I managed to create an effective parametric equation. This was the effect that emerged from this exploring:

First attempt: solely graphing the dots

In order to create this set path, I created a float t that would be the basis for everything, as its increasing values would be used in the equations I established. I then created 4 methods that would return certain values and would determine the movement for the x1, y1, x2, y2 coordinates, since I wanted to make two points that moved at the same time. With this in mind, upon more browsing through the internet, I came upon an amazing tutorial video that gives an overview on computer graphics and the usefulness of using the sin() and cos() functions. Once I implemented these equations, the circular, fluid motion as shows in the previous image was created. Then, to create the lines seem as if they were moving on a 3D plane, I used the coordinates I previously established and implementing them in the line() function.

Once I had figured out how to approach the task of recreating any of the 3D graphics I previously saw, I thought it would be simply a matter of altering the equation to make the movement approximate that of the other ones. However, establishing parametric equations for each of the four coordinates that would recreate the appearance of my chosen image turned out to be an extremely challenging task that, frustratingly, included much more math applications. These are some of the approximations I tried to make:



Overall, it was an extremely big challenge to recreate the image I had in mind due to (at least my) perceived difficulty of altering the equations in such a precise way as to try to imitate its original movement.  Amongst all the attempts, I was able to create many interesting products that, although not as similar to those I previously wanted to make, still presented the same essence of moving along a same path and creating a 3D appearance with this effect. In the end, I was not able to completely recreate any of these images due to the difficulty of figuring out the precise equations, but I still found the graphics that I created extremely interesting and worth to post on this blog.  This whole process was incredibly useful, as I learned a lot about the sin() cos() and line() functions and the many applications they can have in computer graphic art. Along with the pieces I was able to create and the struggle of this whole process, I surely felt satisfied with the graphics I elaborated, since they managed to capture a similar movement as those of the original artists’ pieces. These are, personally, my favorites of the pieces I made: 

 

Another attempt at recreating the previous figures
Black and white version of the final product
Alternate colors
Final product with the addition of color

Attached is the code:

float t = 0;
float s; 


void setup(){
 size(500,500);
 background(0);
}

void draw(){ 
 stroke(255);
 strokeWeight(1);
 translate(width/2,height/2);
 //point(x1(t),y1(t)); //calling the methods, using returned value
 //point(x2(t),y2(t));
 //s = map(t,0,400,50,150);
 s = map(t,0,400,70,140);
 
 //printing lines according to x1, x2, y1, y2 values (using changing values of t)
 if (t <= 100){
 t++;
 stroke(40,s,255-s);
 line(x1(t),x2(t),y1(t),y2(t));
 }
}

//methods that create parametric equations using values of t 
float x1(float t){
 return sin(t/10)*100 + sin(t/15)*100; 
 //better to use lower amplitude if frequency is higher
}

float y1(float t){
 //coefficient inside: changes frequency, smaller coefficient = larger curve
 //bigger coefficient (multiplying) = smaller curves (more frequency)
 //coefficient outside: amplitude changes
 return cos(t/10)*100; 
}

 
float x2(float t){
 return sin(t/20)*100 + sin(t/20)*100;
}

float y2(float t){
 return cos(t/40)*100 + cos(t / 40) * 55;
}