How to Draw a Mean Cat Using the Processing Programming Environment
Open a new file., Define window attributes.To begin, we must specify how large we would like the cat image window to be., After specifying the window size, we may specify other window attributes, such as overall image quality and background color...
Step-by-Step Guide
-
Step 1: Open a new file.
To begin, open the Processing program.
A “sketch,” or new file, will automatically be open and ready for typing.
It will originally be labeled “sketch_xxxxxa,” with the current month and day in the x positions in the file name.
You may rename the file to whatever you choose, by selecting File → Save As…, and typing a new name in the resulting window. -
Step 2: Define window attributes.To begin
To do this, we type the following code: size(200, 200); This is the window size function, and we are passing two numbers that represent how many pixels high and wide we want the program to draw the window.
Here, we ask the program to draw the window 200 pixels high and 200 pixels wide. , Below are two functions we will type to do this: smooth(); background(0); The smooth function ensures that all geometric shapes drawn in this window will show with anti-aliased edges.
This provides a higher quality image.
The background function takes a number argument, here a zero, that represents a color.
Because zero is the color for black, the window’s background will now be returned as black. , It is good programming practice to use variables to store data that will be used repeatedly throughout a program.
In our case, we know that there are a few colors we may want to use more than once in our drawing.
We also want to make the programming easier to read.
This is why we define the RGB colors before we use them.
Here are the colors you will need to draw your mean cat: color cat body = color(226); color earsnose = color(237, 159, 176); color black = color(0, 0, 0); color facial = color(202, 200, 193); color fang = color(249, 16, 85) -
Step 3: we must specify how large we would like the cat image window to be.
The color “catbody” above has been assigned to color 226, which is a medium gray.
The other colors use the RGB scale to define more specific hues.
To learn more about RGB, grayscale, and other color-related information, please refer to Processing’s color tutorial at http://processing.org/tutorials/color/. , Now that we know what colors we’ll be using, we will begin to draw the cat.
The order in which we draw its features is important for the final display, because the program will draw each shape in the order it’s called.
Let’s begin with the ears: , fill the cat's body. ,,,, The fill function takes a color as an argument and returns that color inside the triangles that follow the call.
We now have ears! , To draw the head, type the following: fill(catbody); noStroke(); ellipse(100, 100, 100, 100) -
Step 4: After specifying the window size
The noStroke function specifies that we do not wish to have an outline around the shape following it.
In this case, that shape is of course the cat’s head, which is drawn using the ellipse function.
The ellipse function accepts four numbers: an x and y coordinate for the placement of the circle, and pixel width and height of the ellipse at that position. , The following code does this for us: fill(fang); triangle(85, 130, 95, 130, 90, 146); triangle(95, 120, 105, 120, 100, 146); triangle(105, 130, 115, 130, 110, 146) -
Step 5: we may specify other window attributes
We specify our fangs’ fill color, and then create the triangles using the triangle functions again. , The code for this is as follows: //draw muzzle fill(facial); ellipse(115, 120, 30, 30); ellipse(85, 120, 30, 30) -
Step 6: such as overall image quality and background color.
//draw nose fill(earsnose); stroke(1); triangle(100, 100, 90, 115, 110, 115) -
Step 7: Define colors that you will use for the cat.
The stroke function brings back the outlining feature that we previously turned off, passing the number 1 to it to denote the grayscale level desired for the nose’s outline color. , This is done by drawing gray circles containing smaller black circles within them.
The code for this is as follows:
For the larger, gray circles: fill(facial); ellipse(80, 90, 20, 20); ellipse(120, 90, 20, 20); For the smaller, black circles: fill(black); ellipse(80, 95, 10, 10); ellipse(120, 95, 10, 10); Remember that the stroke function is still “on,” therefore the eyes will be outlined.
This adds contrast and looks nice. ,, To do this, we call the strokeWeight function, passing the number of pixels wide we would like the line to be drawn.
Then we simply call two line functions, which accept two sets of x/y coordinates, drawing lines between those points in the window. , To draw whiskers, we again use the line function.
The code for the whiskers is as follows: strokeWeight(1); line(115, 115, 135, 105); line(117, 119, 135, 120); line(115, 123, 135, 130); line(85, 115, 65, 105); line(83, 119, 65, 120); line(85, 123, 65, 130) -
Step 8: the color data type can be defined as any name desired
One pixel is enough width for a delicate whisker. , First, save the file.
Then to run the program and see the resulting window we’ve drawn, press the “play” button at the top of the window or press Ctrl + R.
The cat will appear in its own 200 x 200 window. ,, -
Step 9: then assigned an RGB or grayscale color number set or number.
-
Step 10: Draw the ears using four triangles.
-
Step 11: we choose the color we’d like the main part of the ears to be filled with.
-
Step 12: we specify the x and y coordinates for the points in the triangles that form the ear shapes: triangle(50
-
Step 13: 60); triangle(150
-
Step 14: we choose another color to fill the inside of the ears with: fill(earsnose);
-
Step 15: And last
-
Step 16: we specify the x and y coordinates for the points forming the triangles for the inner ear: triangle(55
-
Step 17: 65); triangle(145
-
Step 18: Since the triangle function takes three sets of x and y coordinates for the window in which we are drawing the cat
-
Step 19: we type those numbers in the order that we want the triangle’s points drawn.
-
Step 20: Draw the head in the center of the window.
-
Step 21: Here we are using another fill color for the circle we will draw to create the cat’s head.
-
Step 22: The next step in our drawing is to make the mean cat fangs.
-
Step 23: Essentially
-
Step 24: we are drawing three long
-
Step 25: skinny triangles to jut downward from the mouth area.
-
Step 26: Because we want the fangs to be partially covered by the cat’s nose area
-
Step 27: we draw the nose area after we draw the fangs.
-
Step 28: we choose a fill color and draw two matching ellipses over the fangs at the specified coordinates.
-
Step 29: we choose a fill color for the nose
-
Step 30: drawing a small triangle in the center of the cat’s face.
-
Step 31: we place the eyes.
-
Step 32: to draw the mean eyebrows
-
Step 33: we type the following code: strokeWeight(12); line(90
-
Step 34: 65); line(110
-
Step 35: Since we would like the eyebrows to be thick and menacing
-
Step 36: we want to use a line function
-
Step 37: and we want the line drawn to be very thick.
-
Step 38: The last part of the cat to draw is his whiskers.
-
Step 39: Notice that we must change the strokeWeight so that the lines aren’t drawn 12 pixels wide
-
Step 40: as they were drawn for the eyebrows!
-
Step 41: Now that we’ve completed the cat drawing
-
Step 42: it’s time to compile the program and run it.
-
Step 43: It is a good idea
-
Step 44: when creating your own drawings
-
Step 45: to periodically check the progress of the drawing by saving and running the program throughout the programming process.
-
Step 46: Enjoy the mean cat and be glad your own cat is very nice.
Detailed Guide
To begin, open the Processing program.
A “sketch,” or new file, will automatically be open and ready for typing.
It will originally be labeled “sketch_xxxxxa,” with the current month and day in the x positions in the file name.
You may rename the file to whatever you choose, by selecting File → Save As…, and typing a new name in the resulting window.
To do this, we type the following code: size(200, 200); This is the window size function, and we are passing two numbers that represent how many pixels high and wide we want the program to draw the window.
Here, we ask the program to draw the window 200 pixels high and 200 pixels wide. , Below are two functions we will type to do this: smooth(); background(0); The smooth function ensures that all geometric shapes drawn in this window will show with anti-aliased edges.
This provides a higher quality image.
The background function takes a number argument, here a zero, that represents a color.
Because zero is the color for black, the window’s background will now be returned as black. , It is good programming practice to use variables to store data that will be used repeatedly throughout a program.
In our case, we know that there are a few colors we may want to use more than once in our drawing.
We also want to make the programming easier to read.
This is why we define the RGB colors before we use them.
Here are the colors you will need to draw your mean cat: color cat body = color(226); color earsnose = color(237, 159, 176); color black = color(0, 0, 0); color facial = color(202, 200, 193); color fang = color(249, 16, 85)
The color “catbody” above has been assigned to color 226, which is a medium gray.
The other colors use the RGB scale to define more specific hues.
To learn more about RGB, grayscale, and other color-related information, please refer to Processing’s color tutorial at http://processing.org/tutorials/color/. , Now that we know what colors we’ll be using, we will begin to draw the cat.
The order in which we draw its features is important for the final display, because the program will draw each shape in the order it’s called.
Let’s begin with the ears: , fill the cat's body. ,,,, The fill function takes a color as an argument and returns that color inside the triangles that follow the call.
We now have ears! , To draw the head, type the following: fill(catbody); noStroke(); ellipse(100, 100, 100, 100)
The noStroke function specifies that we do not wish to have an outline around the shape following it.
In this case, that shape is of course the cat’s head, which is drawn using the ellipse function.
The ellipse function accepts four numbers: an x and y coordinate for the placement of the circle, and pixel width and height of the ellipse at that position. , The following code does this for us: fill(fang); triangle(85, 130, 95, 130, 90, 146); triangle(95, 120, 105, 120, 100, 146); triangle(105, 130, 115, 130, 110, 146)
We specify our fangs’ fill color, and then create the triangles using the triangle functions again. , The code for this is as follows: //draw muzzle fill(facial); ellipse(115, 120, 30, 30); ellipse(85, 120, 30, 30)
//draw nose fill(earsnose); stroke(1); triangle(100, 100, 90, 115, 110, 115)
The stroke function brings back the outlining feature that we previously turned off, passing the number 1 to it to denote the grayscale level desired for the nose’s outline color. , This is done by drawing gray circles containing smaller black circles within them.
The code for this is as follows:
For the larger, gray circles: fill(facial); ellipse(80, 90, 20, 20); ellipse(120, 90, 20, 20); For the smaller, black circles: fill(black); ellipse(80, 95, 10, 10); ellipse(120, 95, 10, 10); Remember that the stroke function is still “on,” therefore the eyes will be outlined.
This adds contrast and looks nice. ,, To do this, we call the strokeWeight function, passing the number of pixels wide we would like the line to be drawn.
Then we simply call two line functions, which accept two sets of x/y coordinates, drawing lines between those points in the window. , To draw whiskers, we again use the line function.
The code for the whiskers is as follows: strokeWeight(1); line(115, 115, 135, 105); line(117, 119, 135, 120); line(115, 123, 135, 130); line(85, 115, 65, 105); line(83, 119, 65, 120); line(85, 123, 65, 130)
One pixel is enough width for a delicate whisker. , First, save the file.
Then to run the program and see the resulting window we’ve drawn, press the “play” button at the top of the window or press Ctrl + R.
The cat will appear in its own 200 x 200 window. ,,
About the Author
Olivia Simmons
Specializes in breaking down complex creative arts topics into simple steps.
Rate This Guide
How helpful was this guide? Click to rate: