Assignment 1: Portrait of Myself

This is my self-portrait, depicting me with some items of interest: two flags representing my ethnicity and nationality; gears depicting my love for engineering; and Yugioh cards showing my love for the game.

📋Assignment Brief

  • Make a self-portrait using p5.js using the online editor
  • The portrait must be entirely created using code
  • The portrait may be stylised and should be inspired by one’s character

💭Conceptualisation

I started the project by sketching elements that I identified with, things that resonated with who I am. I chose to highlight my flags, Yugioh cards, a paintbrush, and even a rough sketch of myself. I chose to use a very stylised, art style in order to play into the strengths of the software, hoping to recreate an almost vector-art look.

I then thought about features to implement. Despite not being taught any interactive elements just yet, I wanted to make my piece do something special. Hence, I made the eyes follow the user’s mouse. I achieved this through a combination of researching other people’s projects, YouTube, and Chat GPT.

💻Process

I worked on this project in chunks- isolating each component into an element that would need to be individually coded,  and then planning what tools I would need to use for it. I really enjoyed this as it taught me the thought process and planning needed for a piece like this- something completely new to me.

As I used many repeated elements, I was able to focus on creating a singular good piece and then just translate the element into the other areas it’s needed.

I felt particularly proud that I was able to code the moving eyes: I had to research how different features worked, create and effectively use variables, and had to think through logic to ensure it moved the eyes correctly. This was all iterative, I had to stop and re-try many times but was able to manage in the end.

//Eyes
 fill(256); //Set the fill colour to white
   rect(285, 375, 45, 50, 17);
   rect(370, 375, 45, 50, 17);
   rect(285, 400, 45, 25, 3);
   rect(370, 400, 45, 25, 3);
 noFill(); // Disable the fill colour

 
 // Eye variables
 let leftEyeX = 310; // Left eye X position
 let rightEyeX = 395; // Right eye X position
 let eyeY = 400; // Both eyes Y position
 let eyeSize = 40; // Size of outer eye circles
 let pupilSize = 25; // Size of pupils

 // Calculate pupil positions for both eyes
 for (let eyeX of [leftEyeX, rightEyeX]) 
 {
   let dx = mouseX - eyeX;
   let dy = mouseY - eyeY;
   let angle = atan2(dy, dx);

   // Limit pupil movement
   let maxDistance = (eyeSize - pupilSize) / 4;
   let distance = min(dist(eyeX, eyeY, mouseX, mouseY), maxDistance);

   // Calculate and draw each pupil
   let pupilX = eyeX + cos(angle) * distance;
   let pupilY = eyeY + sin(angle) * distance;

   fill(56, 16, 28); //Set the fill colour to brown
     circle(pupilX, pupilY, pupilSize);
   noFill(); // Disable the fill colour
 }

🚩Challenges

Creating the moving eyes were a tad difficult because this uses a lot of knowledge that we have not yet learned in class. However, I was able to look at past projects and use the internet to self-teach how it works. The Pakistani flag was rather tedious, too, as I had to research how to make a star shape and use another new feature. Additionally, the new coordinate system was rather strange. I had to adjust to using the downwards is positive mindset, but it became easy after I introduced a temporary mouse tracker- using the software’s mouseX and mouseY features.

📶Potential Improvements

To improve, I would use more variables so that my portrait may be scaled to whatever size the canvas is. This would allow the portrait to keep a high resolution despite being scaled up or down. Additionally, I could introduce a clicking feature, something where an element on the screen would change every time I click it. This introduces a sense of whimsy and fun that I identify with.

</>Source Code

GitHub Link: https://github.com/theSumeed/Self-Portrait

 

 

Week 1 – Self Portrait

Concept

My main objective was to create an accurate self-portrait of myself. To achieve this, I started by taking a photo of myself at the beginning of the assignment and then attempted to capture all the details I saw in the photo using p5.js. The challenge arose when it came to my wavy (almost curly) hair, as I needed to accurately depict its shape. Additionally, I spent a considerable amount of time figuring out what kind of facial expression to depict, I ended up doing “closed eyes” look since it looked better than the “open eyes” to me. I also focused on maintaining the correct proportions of my body in the portrait. In the end, I was pleased with the minimalistic aesthetic that emerged, as it seemed to align well with my personality.

Demo

Code Highlight (Hair area):

So this part is the part of the code that I am most proud of, maybe due to the fact that I spent so much time on it 🙂

It was the most challenging part of the code due to various reasons like lack of p5.js knowledge (I had to look a lot of stuff up), trying to make different shapes work in harmony and perfectionism stalling the productivity.

At the end, I tried to imitate a middle-part hairstyle using arcs and triangles (might not be the best way but I am fine with the end result).

Here’s the code snippet of the Hair class:

// Hair class 
class Hair {
  draw() {
    fill(0, 0, 0); // Hair color
    noStroke();
    arc(300, 205, 197, 170, PI, 0); // Top hair arc
    fill(228, 177, 171); // Skin color
    arc(300, 210, 50, 50, PI, 0); // Forehead section (mid-part separation)
    fill(1, 1, 1); // Hair color
    triangle(201, 205, 275, 205, 175, 230); // Left side bangs
    rect(200, 205, 15, 45); // Left side hair sideburn
    rect(385, 205, 15, 45); // Right side hair sideburn
    triangle(326, 205, 400, 205, 430, 230); // Right side bangs
  }
}

Reflection & Improvements for Future Work

The experience was quite enjoyable for me because, I was exposed to p5.js before, but it never went beyond some simple sketches, just messing around with the software, nothing serious.  Additionally, it felt like I was opening a new realm of coding. After completing handful of courses in Computer Science curriculum, coding started to associate with efficiency and work, not necessarily artistic vision/creativity, so I was delighted to work on something creative using code.

I always wanted to try to do digital portraits, previously I only did pencil portraits, but I never had the time or reason to do it until now. Discovering that I could make art with code was a delightful surprise. It made me realize I had missed out on a great way to express myself creatively. This experience has sparked a new interest in combining technology and art in my work, and I’m eager to explore this intersection more in the future.

Week 1: Self-Portrait

Concept

I wanted my portrait to be somewhat realistic and visually representative of me to a certain extent, so I put a great emphasis on colors. I pulled up a photo of myself online and used a Chrome extension (ColorZilla) to find the exact colors of my facial features, i.e. eyes, brows, cheeks, lips, skin, hair, and used them in my sketch. The blue background color is taken from a photo of a clear sky I took 2 weeks ago on campus.

Process

I finished a bulk of my sketch before our second class when we learned it is actually possible to find precise coordinates using our mouse.  Even though it was a very tedious process to guess the coordinates of where I wanted my shapes to be and do some rough calculations in my head, in hindsight, I think it was helpful as it led to lots of experimentation that made sketching any shape more intuitive later on.

There are many different ways to draw nose and lips, but I decided to use triangles for both based on sculpting techniques. To sculpt nose and lips, it is very common to create triangular blobs out of the clay first and then shape them delicately with your fingers, so I used that idea in my sketch.

The part I found to be the most difficult was the hair. The first time I created the hair, I was using many individual shapes, which made it not only overly complicated but also unfitting with the rest of the sketch.

//   hair
  fill(56, 48, 47);
  rect(160, 50, 275, 50);
  rect(160, 100, 50, 250);
  rect(385, 100, 50, 250);
  triangle(210, 100, 240, 100, 210, 150);
  triangle(355, 100, 385, 100, 385, 150);
//   hair top edges
  fill(101, 163, 204);
  triangle(160, 50, 210, 50, 160, 120);
  triangle(445, 50, 395, 50, 445, 130);

After trying out different shapes, I realized that I could use the same combination of circle and rectangle I used for my neck for the hair. Sketching the hair this way made it look a lot better, as there were no strange angles and gaps anymore. This also became a reminder that, sometimes, simple solutions can lead to much better outcomes.

//   hair
  fill(56, 48, 47);
  rect(167, 159, 264, 190);
  circle(299, 170, 265);

Finally, I added two musical notes to my sketch to represent my love for music. I wanted my portrait to be symmetrical, so I sketched both notes to be on either side of the sketch to follow the same symmetrical pattern. I had learned to find coordinates using my mouse at this point, so sketching the notes took a lot less time than most of the other shapes on the portrait.

//   left musical note
  fill(0);
  stroke(0);
  strokeWeight(2);
  ellipse(49, 106, 17, 12);
  ellipse(89, 126, 17, 12);
  line(57, 72, 57, 102);
  line(97, 93, 97, 123);
  line(57, 72, 97, 93);
// right musical note
  ellipse(499, 126, 17, 12);
  ellipse(539, 106, 17, 12);
  line(507, 94, 507, 124);
  line(547, 73, 547, 103);
  line(507, 94, 547, 73);

Reflections & Improvements for Future Work

I had a lot of fun working on my portrait. I began working on this assignment quite early without having read through the documentation first to check all of its functionality, so it is mostly based on what we learned in class and is limited to 2D primitive shapes only. Next time, I want to experiment with curves and transformations, and play with the draw function to create animations. As I focused on making the sketch (somewhat?) realistic this time, I hope to explore my creativity and produce more imaginative pieces next time!

Week 1 – Self-portrait

Concept

In my self-portrait, I wanted to take a different approach and portray myself as who I want to be rather than who I am in real life. Since young, I have read numerous comics and enjoyed watching animated movies: my favorite being “Zootopia”.  Thus, I imagined myself being in the movie, and I call him : Mr. preachy cow! He gives motivation to those who may be having a bad day and tries to make everyone’s day better!

In order to do so, I needed to implement anthropomorphism and try to five Mr. preachy cow some human characteristics such as wearing a suit or being able to communicate in human languages.

I chose to use circles as my primary medium of drawing as it is the most friendly shapes out of all as there are no edges: representing Mr preachy cow’s inclusive personality. Also, I wanted to change colors of his facial features and the background to show his ability to embrace all cultures and diversity.

Demo

Code Highlight

function checkRepeat(arrayColor, colorCheck){ 
  //checking whether colors are repeating by deleting already assigned color values from the array
   for(let i=0;i<arrayColor.length;i++){
      if(arrayColor[i]==(colorCheck)) {
            arrayColor.splice(i,1);
      }
}
}
function doubleClicked() { //double click function to open a new page
 window.open('https://www.pinterest.com/hibluchic/inspirational-quotes/'); //opening a pinterest page full of inspirational quotes
}
function mouseClicked() { //mouse click function to generate random moticational words
    colorRepeatCheck = '';
    randomColorCheck = [];
    //inserting all the color values to the array that would be used to generate random color values 
     for(let i=0;i<randomColor.length;i++){
      append(randomColorCheck,randomColor[i]);

    }
    sentenceDisplay = random(motivationalWords); //generating random text value from the array to display when clicked
  
    backgroundColor = random(randomColorCheck);  //generating random color value from the array to change the background color when clicked
    checkRepeat(randomColorCheck,backgroundColor); //deleting the color of the background from the array to prevent being repeated

    faceColor = random(randomColorCheck); //generating random color value from the array to change the face color when clicked
    checkRepeat(randomColorCheck,faceColor); //deleting the color of the face from the array to prevent being repeated
  
    sclerColor = random(randomColorCheck); //generating random color value from the array to change the scler color when clicked
    checkRepeat(randomColorCheck,sclerColor); //deleting the color of the scler from the array to prevent being repeated

    irisColor = random(randomColorCheck);  //generating random color value from the array to change the iris color when clicked
    checkRepeat(randomColorCheck,irisColor); //deleting the color of the iris from the array to prevent being repeated

    eyeBrowColor = random(randomColorCheck); //generating random color value from the array to change the eye brow color when clicked
    checkRepeat(randomColorCheck,eyeBrowColor); //deleting the color of the eye brow from the array to prevent being repeated
  
    mouthColor = random(randomColorCheck); //generating random color value from the array to change the mouth color when clicked
    checkRepeat(randomColorCheck,mouthColor); //deleting the color of the mouth from the array to prevent being repeated

}

I am most proud of creating my own function to prevent the colors to repeat when changing. I purposefully made such function to avoid Mr. preachy cow to have the same colors for all his facial features : including his background. Even though the colors are generated randomly when mouse is clicked, there is still a possibility for the colors to be repeated; so I have implemented a function to prevent such event from happening.

Moreover, I made Mr. Preachy Cow to say motivational words when clicked and lead the visitor to a Pinterest page full of inspirational quotes as he is “Mr. Preachy Cow” after all!

Reflection and Possible Improvements

Even though it was fun making my own “Mr. Preachy Cow”, it took me a lot of time getting used to the x- and y-coordinates of the p5.js when drawing as I was not used to the coordinate system. Some of the shapes drawn on the self-portrait are not exactly symmetric and there are rough edges on his ears which could be better polished.

In addition, I think there could be more fun elements used when displaying the texts by making the texts move in certain ways so the user would have more fun with Mr. Preachy Cow.

Despite few regrets and possible improvements I have on my first assignment, I am happy to learn about basics of interactive media and looking forward to develop my learning to create more refined works in the future.

Week 1-self portrait

Concept of the Self-Portrait
In this self-portrait, I tried to represent a more simplified and stylized version of me through emphasizing more geometric shapes and clean lines. The hijab is a very big part of my identity, and through soft curves and bold colors, I tried showing elegance. Therefore, the intention was to be harmonious and balanced in that composition-representative with minimum design. In the future, I would like to add more detailed features, such as patterns on the hijab or dynamic animations that could give it more personality. even making it seem more decent and realistic

The self-portrait uses a hijab which is drawn in arcs that wrap comfortably, gracefully around the face, I was trying my limits to make it creative. reflecting comfort and simplicity. The minimalist approach uses clean shapes for eyes, eyebrows, nose, and a subtle smile to show very expressive yet understated design. This artwork used soft, warm skin tone colors versus deep black from the hijab, which really exudes balance and harmony. It can be customized for any given user’s preference-for example, using a different-colored hijab color by calling fill(), complex patterns, or gradients for texturing. Future enhancements could include animating the hijab to simulate a fabric-like flow, adding a sunlit room or cultural motifs as a background to enrich the narrative, and introducing interactivity, such as clicking to change hijab colors or toggling facial expressions. These features and enhancements aim at creating a dynamic and meaningful representation of identity and creativity.

// Draw hijab
fill(0); // Black hijab
arc(200, 200, 150, 200, PI + QUARTER_PI, TWO_PI – QUARTER_PI); // Main hijab
arc(200, 230, 200, 280, PI + QUARTER_PI, TWO_PI – QUARTER_PI); // Outer hijab layer

this was the hardest dealing with this self-portrait since I couldn’t make it seem more realistic