Week 1 : Self Portrait Assignment

Introduction:

As for the assignment, I played around with basic shapes on processing using java and got to know about coordinate systems and basic drawing functions which support sketching the idea on canvas with specified dimensions. In short, processing takes a long-term step to make life easier for artists. As from my perspective coding and programming with different languages consists of art and processing going hand in hand with programmers and artists to work under the same umbrella.

The inspiration behind MY self-portrait:

Although I am not a tennis player myself, my sister is a tennis enthusiast and enjoys playing tennis on a weekly basis. Last week, she had a session that I attended with her as a guest to consider signing up with her. She took a video of me as I was messing around in the end of the session, and it gave me an idea to construct this portrait.

The red dot on my face is used to portray how red I was in the field. I am naturally allergic to the sun and the tennis class consumed my energy which led to me looking like a tomato by the end of the day. My orange shirt and tied ponytail are there to replicate how I looked in the video. The tennis ball is placed on the other side of the field to show that I hit the ball and it fell on the other side of the tennis net , and the purple tennis racket is also inspired from the same video.

Challenges and Problems:

The setup and configuration of the processing software are very easy, and it doesn’t take much time. The problem I faced was during the arc () function and the cutting of ellipse and circle shapes. Understanding the angles and implementation of curves on the right place of both face and body was a challenge on its own. I spent most of my time trying to understand the measurements of the shape and parameters of functions. It was even challenging to spend time learning the functions documentation published on processing. Thus, I did customization on some common shapes like the nose, neck, mouth, and ears by cutting the circular shapes on some angles. Finally, I felt challenged to handle the indentation point as it is not as efficient as other IDEs.

Procedure:

First of all, I worked on the two basic functions of processing which are setup() and draw() functions. Then, with a color selector, I selected relevant colors hex values and initialized global variables for each color with the specified naming convention. I put the colors as a global variable to remember the colors further in code. I researched and understood the 2D coordinate system and began coding global variables for the face and initialized the measurements in setup() functions. By initializing variables in setup() functions, it enhances the reusability of measurements throughout the code and my coding speed.

In the draw() function, I drew the face of the girl by using 2D primitive shapes including ellipse, rectangle, circle, arc, and line. I utilized global variables to fill up the shapes function parameters and do some mathematics by adding and subtracting values from the given parameters. For the face sketching, stroke() and fill() functions were used while the arc() function was mostly to draw the face and other body parts. I played with multiple parameters of the same functions to customize the shape accordingly. By joining multiple shapes, I succeeded to sketch out the girl’s body parts. Subsequently, I worked around the background environment for the ground part, the back sky as illustrated, and sketched the tennis net on it. The reason I placed the tennis net in the foreground was to visualize that the girl is standing on the other side of the tennis net. On the other hand, I drew a tennis ball by utilizing a circular shape that is placed on the frontal side of the ground to mimic my idea more accurately.

To draw the tennis bat, I first stored the hand position in terms of x and y coordinates in temporary variables and then used them to act as a placemark for the tennis bat. Moving on, a series of lines with equal distances on the tennis bat was drawn by using nofill() to give the tennis bat a sensible look. For the girl’s arms, two rectangles were drawn with a specified radius by using the body’s central point. The rectangles were later placed on the right and left sides of the body. For the legs, I calculated the distance from the body central point to place the legs under the body. To outline the shapes drawn, I utilized the strokeweight() function. When it comes to the face, I stored its central point x and y values as global variables. I drew the ear, nose, and eyes using the arc() function with extra parameters to customize the arc shape per the face posture.

//Colors
color haircolor,facecolor,shirtcolor,shoescolor, backgroundcolor,groundcolor,tenniscolor;

//BodyParts Measurements
float faceheight;
float facewidth;

float headheight;
float headwidth;

float hairbandheight;
float hairbandwidth;

float facex;
float facey;

void setup()
{
size(700,700);

//Colors
haircolor=#462218;
facecolor=#DDD6D1;
shirtcolor=#CD7324;
shoescolor=#985036;
backgroundcolor=#4AB7F7;
groundcolor=#557A06;
tenniscolor=#7525CB;


background(backgroundcolor);

//BodyParts Measurements
faceheight=150;
facewidth=200;

headheight=100;
headwidth=200;

hairbandheight=30;
hairbandwidth=30;

facex=250;
facey=400;

}


void draw()
{
  
//drawing face
fill(facecolor);
strokeWeight(5);
arc(facey, facex,facewidth,faceheight,radians(0),radians(360));

//drawing head
fill(haircolor);
arc(facey, facex,facewidth,faceheight,radians(180),radians(370));

//drawing hairband
float hairsposy=facey;
float hairposx=facex-125;
fill(shirtcolor);
arc(facey, facex-90,hairbandwidth,hairbandheight,radians(0),radians(360));

//drawing hairs
fill(haircolor);
ellipse(hairsposy, hairposx,80,40);

//drawing eye
fill(#FFFFFF);
ellipse(facey-55, facex+15, 20, 20);
fill(#000000);
ellipse(facey-55, facex+20, 10, 10);

//drawing eye
fill(#FFFFFF);
ellipse(facey+55, facex+20, 20, 20);
fill(#000000);
ellipse(facey+55, facex+25, 10, 10);


//drawing delight smile
fill(facecolor);
arc(facey, facex+40,40,40,radians(40),radians(150));

//drawing nose
fill(facecolor);
arc(facey, facex+25,20,20,radians(90),radians(180));

//drawing blush on cheeks
fill(#DE3C3C);
strokeWeight(0);
arc(facey+50, facex+45,20,20,radians(0),radians(360));


strokeWeight(5);

//drawing ears
fill(facecolor);
arc(facey-90, facex+30,20,20,radians(70),radians(240));
fill(facecolor);
arc(facey+98, facex+30,20,20,radians(270),radians(500));
//drawing body
fill(shirtcolor);
float bodyposy=facey;
float bodyposx=facex+75;
rect(bodyposy-40,bodyposx,80,100,5);

//drawing right arm
fill(facecolor);
rect(bodyposy+40,bodyposx,20,100,5);
//drawing right hand
fill(shoescolor);
arc(bodyposy+50, bodyposx+100,20,20,radians(0),radians(360));



//drawing left  arm
fill(facecolor);
rect(bodyposy-140,bodyposx,100,20,5);

//drawing left hand
fill(shoescolor);
arc(bodyposy-140, bodyposx+10,20,20,radians(0),radians(360));

//Drawing tennis racket
float handposy = bodyposy-140;
float handposx = bodyposx+10;
fill(tenniscolor);
rect(handposy-15,handposx-100,20,100,20);
noFill();
rect(handposy-40,handposx-200,70,100,35);
float nety=handposy-40;
float netx=handposx-200;
line(nety,netx+20, nety+70,netx+20);
line(nety,netx+30, nety+70,netx+30);
line(nety,netx+40, nety+70,netx+40);
line(nety,netx+50, nety+70,netx+50);
line(nety,netx+60, nety+70,netx+60);
line(nety,netx+70, nety+70,netx+70);
line(nety,netx+80, nety+70,netx+80);
//drawing slight showing neck
fill(facecolor);
arc(facey, facex+80,40,20,radians(0),radians(190));

//drawing legs
fill(facecolor);
rect(bodyposy-40,bodyposx+100,30,80,5);
rect(bodyposy+10,bodyposx+100,30,80,5);

//drawing shoes
float footposy=bodyposy-40;
float footposx=bodyposx+100;
fill(shoescolor);
arc(footposy+15, footposx+85,30,30,radians(0),radians(360));
arc(footposy+65, footposx+85,30,30,radians(0),radians(360));

//drawing grassy ground
fill(groundcolor);
float groundx=footposy+170;
float groundy=footposx-500;
rect(groundy,groundx,800,800,5);

//drawing tennis ball
fill(#25CB2E);
arc(footposy+75, footposx+200,40,40,radians(0),radians(360));



//drawing fence
fill(shoescolor);
rect(footposy-250,footposx-140,30,300,5);
fill(shoescolor);
rect(footposy+250,footposx-140,30,300,5);
stroke(5);
line(footposy-250,footposx-80, footposy+250,footposx-80);
line(footposy-250,footposx-60, footposy+250,footposx-60);
line(footposy-250,footposx-40, footposy+250,footposx-40);
line(footposy-250,footposx-20, footposy+250,footposx-20);
line(footposy-250,footposx, footposy+250,footposx);
line(footposy-250,footposx+20, footposy+250,footposx+20);

}

 

 

 

 

 

 

 

 

 

My Self-Portrait Final Edition:

Conclusion:

Working on this assignment allows me to dive into the basics of programming. To understand the basics of computer graphics and math behind the pixels. I learned my way by drawing basic shapes using simple coding on processing. Processing ensures the testing of coding most conveniently and more simply which I like most. There are no debugging configurations in processing. I tested each shape drawing simply by running the code efficiently and reliably.

 

 

Self Portrait – Jade

WEEK 1 Documentation

 

In this project, I used some basic functions of Processing and shapes like lines, quads, ellipses, triangles and rectangles to make a self-portrait. I also included a little animation using knowledge learned from class. I intended to portrait my face in an angle, so in my project, my face has turned right a little bit.

Throughout the whole process, I faced some difficulties, like appropriately locating the points. I had to adjust the coordinates several times so that they can finally make up the shape I want. And when I was doing the animation of my mouth, it was strange that as my mouth moved, there appeared a black triangle, so I had to place a rectangle of the background color behind my mouth triangle. That’s why I have this line of code:

rect(width/2 - 60, height/2 + 50, 100, 70);

However, among all the difficulties, I found depicting my hair most challenging. I first tried to use curves and the BezierVertex, but unfortunately since I didn’t master these functions, it didn’t go well. So then I used arcs, and to make it more me, I added some quads at the back.

From this project, I think I have learned and improved a lot as I tried using various functions and shapes in Processing. Although my work might not be artistic or elaborate, I think it captured some of my features. I am sure that I still have got a lot to learn in Processing since I kept coding in a stupid way, and I look forward to learning more of it!

 

My Code:

int mouth_height = 50;
int speed = 1;
PFont f;


void setup() {
  size(640, 480);
  background(#FFFFAD);
  
  // hair
  noStroke();
  fill(#4B2D0E);
  quad(286, 100, 243, 60, 181, 122, 188, 264);
  quad(398, 110, 454, 95, 460, 283, 300, 283);

  // head
  stroke(0);
  strokeWeight(2);
  fill(249, 236, 228);
  ellipse(width/2, height/2 - 10, 270, 300); 
  quad(269, 360, 274, 433, 422, 440, 401, 360);
  noStroke();
  rect(268, 353, 120, 15);
  fill(255);
  stroke(0);
  quad(252, 400, 281, 450, 322, 435, 296, 415);
  triangle(322, 435, 425, 400, 425, 460);
  
  // eyebrow
  noStroke();
  fill(#4B2D0E);
  triangle(227, 156, 220, 145, 290, 156);
  triangle(329, 152, 378, 140, 390, 153);
  
  // front hair
  noStroke();
  fill(#4B2D0E);
  arc(260, 109, 160, 130, radians(135), radians(315));
  arc(356, 110, 200, 180, radians(200), radians(360+45));
  
  // eyes
  stroke(0);
  fill(255);
  ellipse(240, 180, 70, 30); 
  ellipse(370, 180, 80, 30); 
  
  fill(#461414);
  ellipse(240, 180, 30, 30);
  ellipse(370, 180, 40, 30);

  fill(255);
  ellipse(236, 183, 7, 7);
  ellipse(364, 182, 7, 7);
  

  // nose
  fill(0);
  strokeWeight(2);
  line(width/2 - 20, height/2 - 40, width/2 - 35, height/2 + 10);
  line(width/2 - 10, height/2, width/2, height/2 + 10);
  line(width/2 - 35, height/2 + 10, 298, 256);


  // glasses
  fill(206, 209, 227, 118);
  stroke(#F2E662);
  rect(180, 140, 110, 80, 12, 24, 48, 72);
  line(290, 180, 320, 180);
  rect(320, 142, 115, 80, 12, 24, 48, 72);
  line(435, 180, 450, 160);

  // ear
  stroke(0);
  fill(249, 236, 228);
  arc(455, 229, 35, 50, TWO_PI - HALF_PI, TWO_PI + HALF_PI);
  

  // sign
  f = createFont("AmericanTypewriter-Semibold", 48, true);
}

void draw() {
  println(mouseX + ", " + mouseY);

  // mouth
  fill(249, 236, 228);
  noStroke();
  rect(width/2 - 60, height/2 + 50, 100, 70);
  
  if (mouth_height == 80 || (mouth_height == 50 && speed < 0)) {
    speed *= -1;
  }
  
  mouth_height += speed;
  fill(#FFD3D3);
  stroke(0);
  strokeWeight(2);
  triangle(width/2 - 40, height/2 + 50, width/2 + 30, height/2 + 50, width/2 - 30, height/2 + mouth_height);

  fill(0);
  textFont(f, 30);
  text("Jade Zhou", 480, 389);
}

 

My work:

How to add code to your documentation

Click the {…} button to add code to your post:

You’ll then see this screen where you can paste your code in:For Processing code change the language to Java:

Once you’re done click Add and you’re all set. Easy!

int rectWidth = 8;

void setup() {
  size(640, 480);
  rectMode(CENTER);
}

void draw() {
  background(255);
  for (int x = 0; x<width; x+=rectWidth) {
    float center = height*.25;
    float amplitude = 100;
    float speed = .01;
    float granular = .001;
    float freq = (frameCount* speed) + (x * granular);
    float adjustedHeight = noise(freq);// between 0 & 1
    adjustedHeight -= .5;// between -0.5 & 0.5
    adjustedHeight *= amplitude;
    rect(x + rectWidth/2, center + adjustedHeight, rectWidth, 100);
  }
  for (int x = 0; x<width; x+=rectWidth) {
    float center = height - (height*.25);
    float amplitude = TWO_PI;
    float speed = .01;
    float granular = .001;
    float freq = (frameCount* speed) + (x * granular);
    float angle = noise(freq);// between 0 & 1
    angle *= amplitude; // between 0 & TWO_PI
    pushMatrix();
      translate(x + rectWidth/2, center);
      rotate(angle);
      rect(0,0, rectWidth, 100);
    popMatrix();
  }
}

Github for the class

https://github.com/aaronsherwood/introduction_interactive_media

Git is a powerful way to manage code, and we’ll use only a tiny bit of its power to update the weekly examples folder on our computers. It’s super easy.

Usage

Initialization (you only need to do these steps once):

If you haven’t installed git on your computer, install git on your computer (or optionally here’s a different set of instructions).

Change directory (cd on the command line) into the location where you want the class repository to live.

Clone the repo to your computer: git clone https://github.com/aaronsherwood/introduction_interactive_media.git

Regular Use:

If working off any example, copy that example somewhere outside of the repo to mitigate any merge conflicts later on.

To get new examples: git pull

If you’re unsure if you’ve been working in examples directly in the repo you can stash everything before pulling:

  • git stash
  • git pull

To get stashed code back: git stash pop

To see what’s been stashed: git stash list

To remove all stashes: git stash clear

To reset everything to be just like the repo online:

  • git fetch origin
  • git reset --hard origin/master