Skip to content

Language Settings

Simple Shapes

This examples includes a circle, square, triangle, and a flower.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function setup() {
  // Create the canvas
  createCanvas(720, 400);
  background(200);
  // Set colors
  fill(204, 101, 192, 127);
  stroke(127, 63, 120);
  // A rectangle
  rect(40, 120, 120, 40);
  // An ellipse
  ellipse(240, 240, 80, 80);
  // A triangle
  triangle(300, 100, 320, 100, 310, 80);
  // A design for a simple flower
  translate(580, 200);
  noStroke();
  for (let i = 0; i < 10; i ++) {
    ellipse(0, 30, 20, 80);
    rotate(PI/5);
  }
}
X

creative commons license