§2.6 - Drawing Functions Summary (Reference)
KM
bykarutt
2024-11-11
Drawing Functions
| Function | Description |
|---|---|
circle(x, y, r) | Draws a circle. x and y specify the center coordinates, and r specifies the radius. |
ellipse(x, y, w, h) | Draws an ellipse. x and y specify the center coordinates, w specifies the width, and h specifies the height. |
rect(x, y, w, h) | Draws a rectangle. x and y specify the top-left corner coordinates, w specifies the width, and h specifies the height. |
rect(x, y, w, h, r) | Draws a rectangle with rounded corners. r specifies the radius of the corners. |
rect(x, y, w, h, tl, tr, br, bl) | Draws a rectangle with different rounded corners. tl, tr, br, and bl specify the radius of the top-left, top-right, bottom-right, and bottom-left corners respectively. |
line(x1, y1, x2, y2) | Draws a line. x1 and y1 specify the starting point coordinates, and x2 and y2 specify the ending point coordinates. |
triangle(x1, y1, x2, y2, x3, y3) | Draws a triangle. Specifies the coordinates of the three vertices. |
quad(x1, y1, x2, y2, x3, y3, x4, y4) | Draws a quadrilateral. Specifies the coordinates of the four vertices. |
arc(x, y, w, h, start, stop) | Draws an arc. x and y specify the center coordinates, w specifies the width, h specifies the height, and start and stop specify the angles. |
point(x, y) | Draws a point. x and y specify the coordinates of the point. |
text(str, x, y) | Draws text. str specifies the string to display, and x and y specify the coordinates of the lower-left corner of the text. |
Drawing Polygons
| Function | Description |
|---|---|
beginShape() | Signals the start of a new shape. |
vertex(x, y) | Defines a vertex for the new shape. |
endShape(CLOSE) | Closes the shape. |
Style Functions
| Function | Description |
|---|---|
fill(gray) | Specifies the fill color of shapes. gray is a grayscale value ranging from 0 to 255. |
fill(r, g, b) | Specifies the fill color of shapes. r, g, and b are RGB values. |
fill(r, g, b, a) | Specifies the fill color of shapes. r, g, and b are RGB values, and a represents the alpha (transparency). |
noFill() | Disables the fill color of shapes. |
stroke(gray) | Specifies the stroke color of shapes. gray is a grayscale value ranging from 0 to 255. |
stroke(r, g, b) | Specifies the stroke color of shapes. r, g, and b are RGB values. |
stroke(r, g, b, a) | Specifies the stroke color of shapes. r, g, and b are RGB values, and a represents the alpha (transparency). |
noStroke() | Disables the stroke color of shapes. |
strokeWeight(w) | Specifies the stroke weight of shapes. |