Skip to content

Instantly share code, notes, and snippets.

@hassi32
Created August 12, 2018 07:21
Show Gist options
  • Save hassi32/3b57ad19eda81ba47e4a82c332ecc69a to your computer and use it in GitHub Desktop.
Save hassi32/3b57ad19eda81ba47e4a82c332ecc69a to your computer and use it in GitHub Desktop.
draw radius lines on a circle by p5.js
function setup() {
createCanvas(1000, 600);
background(255);
strokeWeight(5);
smooth();
var radius = 500;
var centx = 500;
var centy = 300;
stroke(0, 10);
noFill();
ellipse(centx, centy, radius*2, radius*2);
stroke(20, 50, 70);
var x, y;
for (var ang = 0; ang <= 360; ang += 5) {
var rad = radians(ang);
console.log('​setup -> rad', rad);
x = centx + (radius * cos(rad));
y = centy + (radius * sin(rad));
line(centx, centy, x, y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment