function draw()
{
// you are going to add your own code here, like this:
C(255,0,0);
F(60);
R(90);
F(100);
C(0,255,0);
L(90);
F(150);
}
//--------------- Don't Worry About Anything Below Here! -----------------
function setup()
{
createCanvas(400, 400); // drawing area size
TurtleX = 0; // center of screen
TurtleY = 0; // center of screen
TurtleAngle = 0; // to the right
background( 230, 230, 230 ); // light gray
stroke( 0, 0, 0 ); // black lines
strokeWeight(1);
noLoop( );
}
// move the turtle forwards:
function F( distance )
{
var angle = radians( TurtleAngle);
var newx = TurtleX + distance*cos( angle );
var newy = TurtleY + distance*sin( angle );
line( TurtleX+width/2, height-(TurtleY+height/2),
newx+width/2, height-(newy+height/2) );
TurtleX = newx;
TurtleY = newy;
}
// move the turtle backwards:
function B( distance )
{
F( -distance );
}
// rotate the turtle to the right:
function R( degs )
{
TurtleAngle = TurtleAngle - degs;
}
// rotate the turtle to the left
function L( degs )
{
R( -degs );
}
// set the color to (r,g,b): 0-255
function C( r, g, b )
{
stroke( r, g, b );
}
// set the line width:
function W( wide )
{
strokeWeight( wide );
}
// snowflake branch:
function Branch( b )
{
F( b );
R( 45 );
F( b/2 );
//Branch( b/2 );
B( b/2 );
L( 90 );
F( b/2 );
//Branch( b/2 );
B( b/2 );
R( 45 );
B( b );
}
function Snowflake( length )
{
for( var b = 0; b < 6; b = b + 1)
{
F( length );
R( 45 );
Branch( length/2 );
L( 90 );
Branch( length/2 );
R( 45 );
B( length );
L( 60 );
}
}
var TurtleX; // where is the turtle horizontally?
// (0 = in the center)
var TurtleY; // where is the turtle vertically?
// (0 = in the center)
var TurtleAngle; // where is the turtle heading?
// (0 = to the right)