function TurtleShepherd() {
this.clear();
}
TurtleShepherd.prototype.addMoveTo= function(x,y,penState) {
this.cache.push(
{
"cmd":"move",
"x":x,
"y":-y,
"penDown":penState,
}
);
if (this.count === 0) {
this.minX = x;
this.minY = y;
this.maxX = x;
this.maxY = y;
} else {
if (x < this.minX) this.minX = x;
if (x > this.maxX) this.maxX = x;
if (y < this.minY) this.minY = y;
if (y > this.maxY) this.maxY = y;
}
this.count++;
//if (DEBUG) tstools.debug_msg("add move to" + x + " " + y + " " + penState );
};
TurtleShepherd.prototype.hasSteps = function() {
return this.count > 0;
};
TurtleShepherd.prototype.addColorChange= function(color) {
this.cache.push(
{
"cmd":"color",
"value":color,
}
);
};
TurtleShepherd.prototype.clear = function() {
this.cache = [];
this.minX = 0;
this.minY = 0;
this.maxX = 0;
this.maxY = 0;
this.count = 0;
this.initX = 0;
this.initY = 0;
this.w = 480;
this.h = 360;
this.scale = 1;
};
TurtleShepherd.prototype.initPosition = function(x,y) {
this.initX = x;
this.initY = y;
};
TurtleShepherd.prototype.setScale = function(s) {
this.scale = s;
if (DEBUG) tstools.debug_msg("zoom to scale "+ s );
};
TurtleShepherd.prototype.zoomIn = function() {
this.scale += 0.1;
if (DEBUG) tstools.debug_msg("zoom to scale "+this.scale );
};
TurtleShepherd.prototype.zoomOut = function() {
if (this.scale > 0.15)
this.scale -= 0.1;
if (DEBUG) tstools.debug_msg("zoom to scale "+ this.scale );
};
TurtleShepherd.prototype.setDimensions = function(x,y) {
this.w = x;
this.h = y;
};
TurtleShepherd.prototype.renderGrid = function(size=50) {
return '' +
'' +
'' +
'' +
'';
};
TurtleShepherd.prototype.toSVG = function() {
//var svgStr = "\n";
//svgStr += "\n";
svgStr = '\n';
return svgStr;
};