W.
01
GRAPHICS PRIMITIVES AND DRAWING
rect(x, y, width, height);
Draws a rectangle anchored at the
top left corner, in position (x, y)
and with size width and height.
rectMode(CORNER);
rectMode(CENTER); (x,y) at the centre
rectMode(RADIUS); width and height
are the radius from the centre at (x,y)
(x, y)
ll(), noFill(), stroke(), noStroke()
Border, stroke & ll seing functions for graphics shapes
ll(red, green, blue) ll(red,green, blue, alpha)
ll(grey_level) ll( grey_level, alpha)
stroke(red, green, blue) stroke(red,green, blue, alpha)
stroke( grey_level) stroke( grey_level, alpha)
line(x1, y1, x2, y2);
Draws a line from point (x1, y1) to
(x2, y2)
(x1, y1)
* Value scale of red, green, blue, alpha and grey_level ranges from
0 (darkest) to 255 (brightest).
noStroke() and noFill();
Disable stroke and ll color.
(x2, y2 )
quad(x1, y1, x2, y2, x3, y3, x4, y4);
Draws a quadrilateral with the four
vertex positions passed to the
function.
(x1, y1)
(x4, y4)
(x2, y2)
Processing Code
(x3, y3)
stroke(0);
triangle(x1, y1, x2, y2, x3, y3);
Draws a triangle with the three
vertex positions passed as
arguments.
(x1, y1)
(x3, y3)
ll(215,223,35);
strokeWeight(1);
ellipse(x,y, 200, 200);
strokeWeight(10);
(x2, y2)
sa
h
ea
w
arc(x, y, w, h, sa, ea);
Draws an arc from position (x,y),
with size w width, h height, sa
start angle and ea end angle
passed as radians.
Useful constants in processing:
TWO_PI, PI, HALF_PI.
ll(255);
stroke(255,0,0);
noFill();
stroke(255,0,0);
strokeWeight(10);
Basic geometry
and graphics primitive shapes
(x, y)
ll(255);
noStroke();
height
(x, y)
width
ellipse(x, y, width, height);
Draws an ellipse centered at position
(x, y) and with size width and
height. Specifying the same values
for width and height makes a
circle.
strokeWeight();
Sets the width of the stroke used for
lines, points, and the border around
shapes. All widths are set in units of
pixels.