previous

page 20

next
the other turtle functions
function bg(colr='white') {
g_ctx.fillStyle=colr;
g_ctx.fillRect(0,0,g_side,g_side);
}
function bk(t,d) {
fd(t,-d);
}
function cs() {
g_ctx.clearRect(0,0,g_side,g_side);
}
...
function home(t) {
t.x=400; t.y=400; t.h=0;
}
function join(t1,t2) {
g_ctx.beginPath();
g_ctx.moveTo(t1.x*g_step,t1.y*g_step);
g_ctx.strokeStyle=t1.colr;
g_ctx.lineWidth=t1.width;
g_ctx.lineTo(t2.x*g_step,t2.y*g_step);
g_ctx.stroke();
}
function lt(t,angle) {
rt(t,-angle);
}
function pc(t,colr='black') {
t.colr=colr;
}
function pd(t) {
t.pen='down';
}
function pu(t) {
t.pen='up';
}
previous
next