Add Circle using polar coordinates

This commit is contained in:
Lev
2021-07-15 23:08:23 -05:00
parent 827b5419b8
commit 7253eb06b4
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="p5.min.js"></script>
<script src="sketcho.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
function setup()
{
createCanvas(500, 500);
angleMode(DEGREES);
}
function draw()
{
background(0);
translate(width/2, height/2);
let radius = 200;
fill(255);
for(let theta=0; theta < 360; theta += 20)
{
let x = cos(theta) * radius;
let y = sin(theta) * radius;
//let x = cos(radians(theta)) * radius;
//let y = sin(radians(theta)) * radius;
ellipse(x, y, 15, 15);
}
}