Created
December 24, 2011 17:30
-
-
Save pyrocat101/1517864 to your computer and use it in GitHub Desktop.
Twisted Roses in Logo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new() { | |
// set default screen, pen and turtle values | |
setbg(0, 0, 0); | |
setpc(0, 1, 0); | |
setpw(1); | |
pu(); | |
} | |
function ang_col(theta) { | |
return abs(255 * cos(theta)); | |
} | |
function spiral(angle, twist) { | |
// Twisted Rose Curves | |
radius = 180 * sin(4 * angle); | |
angle = angle + 20 * sin(twist * angle); | |
setpw(width(angle, radius)); | |
setpc(ang_col(30 + 3 * angle), 0, 255); | |
setxy(radius * sin(angle), radius * cos(angle)); | |
pd(); | |
} | |
function width(angle, radius) { | |
seth2(radius * sin(angle), radius * cos(angle)); | |
return 2 * (1.5 + sin(45 + 2 * geth())); | |
} | |
new(); | |
for (twist = 0 to 24) {} | |
for (angle = 0 to 360) { | |
spiral(angle, twist); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment