Add Circle using polar coordinates
This commit is contained in:
@ -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>
|
||||||
3
CM2030 Graphics Programming/Topic 8/8.1.6 Circle in Polar Coords/p5.min.js
vendored
Normal file
3
CM2030 Graphics Programming/Topic 8/8.1.6 Circle in Polar Coords/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user