The circle() function is used to draw the circle on the screen. A circle is the closed shape. A circle can be created by using the center and radius of the circle.
Syntax:
circle(x, y, d)
Parameters:
- x: It is used to set the x-coordinate of the center of the circle.
- y: It is used to set the y-coordinate of the center of the circle.
- d: It is used to set the diameter of the circle.
Example 1:
function setup() {
createCanvas(400, 300);
}
function draw() {
background(220);
let c = color( 'green' );
fill(c);
circle(200, 100, 150);
}
|
Output:
Example 2:
function setup() {
createCanvas(400, 300);
}
function draw() {
background(220);
circle(200, 150, 150);
noFill();
circle(100, 150, 150);
circle(150, 75, 150);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/circle
Last Updated :
11 Aug, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...