Draw n points around a circle

see processing code at: rupert.id.au/processing/snippets.php

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax // Released under the MIT licence // https://mit-license.org/ // you can use this for commercial gain if you like eg you can sell artworks with this image. Canvas.setpenopacity(1); // Global code will be evaluated once. const turtle = new Turtle(); const h = 0; const k = 0; const Pointradius = 6; //min=1 max=120 step=1 const numberOfPoints = 24; //min=4 max=50 step=1 const circleRadius = 50; //min=10 max=180 step=1 const xOffset = 0; // //min=-10 max=20 step=1 const yOffset = -20; //min=-160 max=20 step=1 var x; var y; var degree = 0; // Draw n points around a circle for ( i = 0; i < numberOfPoints; i++) { x = h + circleRadius * Math.cos(degrees_to_radians(degree)); y = k - circleRadius * Math.sin(degrees_to_radians(degree)); turtle.penup(); turtle.goto(x + xOffset, y + yOffset); turtle.pendown(); turtle.circle(Pointradius) degree = degree + 360 / numberOfPoints; } function degrees_to_radians(degrees) { return degrees * (Math.PI / 180); }