Javascript Code from ChatGPT
online at: rupert.id.au/star/
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
const outerRadius = 100; //min=10 max=90 step=1
const innerRadius = 52; //min=10 max=90 step=1
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.pendown();
drawStar(0, 0);
// Function to draw a six-pointed star
function drawStar(x, y) {
for (let i = 0; i < 13; i++) {
const radius = i % 2 === 0 ? outerRadius : innerRadius;
const angle = (i * 30 * Math.PI) / 180;
const xPoint = x + Math.cos(angle) * radius;
const yPoint = y + Math.sin(angle) * radius;
if (i === 0) {
turtle.jump(xPoint, yPoint);
} else {
turtle.goto(xPoint, yPoint);
}
}
}