PH Logo
Logo intepreter modeled after UCB Logo.
Public Member Functions | Protected Attributes | Friends
phlogo::Turtle Class Reference

#include <Turtle.h>

Inheritance diagram for phlogo::Turtle:
phlogo::JSONTurtle

List of all members.

Public Member Functions

virtual void clear ()=0
virtual void moveTo (int x, int y)=0
virtual void lineTo (int x, int y)=0
virtual void stroke ()=0
void home ()
double getX ()
double getY ()
void setXY (double x, double y)
double getHeading ()
void setHeading (double heading)
void setPendown (bool pendown)
bool getPendown ()

Protected Attributes

bool _firstop
bool _pendown
double _x
double _y
double _heading

Friends

class World

Detailed Description

The turtle outputs graphics in the form of JSON data with operations that operate directly on a canvas in HTML.

Operations are:

"m:[x, y]" -> moveTo(x, y) "l:[x, y]" -> lineTo(x, y) "s:0" -> stroke()

Here is a driver program in JavaScript that will draw this data, given a canvas in the html called "canvas".

function canvas() { var ctx = document.getElementsByTagName('canvas')[0].getContext('2d'); ctx.strokeStyle = "#00CC00"; ctx.lineWidth = 1; return ctx; }

function doop(ctx, op) { if (typeof(op.m) != "undefined") { ctx.moveTo(op.m[0], op.m[1]); } else if (typeof(op.l) != "undefined") { ctx.lineTo(op.l[0], op.l[1]); } else if (typeof(op.s) != "undefined") { ctx.stroke(); } }

var ctx = canvas(); for (l in gdata) { doop(ctx, gdata[l]); }

Definition at line 53 of file Turtle.h.


The documentation for this class was generated from the following files:
 All Classes Functions