diff --git a/index.html b/index.html index 9552fc2a..0ac3ab41 100644 --- a/index.html +++ b/index.html @@ -60,9 +60,8 @@
+ position:absolute;right:0;bottom:0;width:480px;height:360px; + border:1px solid #c0c0c0" >
0) { - cmdCache.zoomOut(); + turtleShepherd.zoomOut(); } else if (y < 0) { - cmdCache.zoomIn(); + turtleShepherd.zoomIn(); } - + this.clearPenTrails(); reDraw(this.penTrails()); }; diff --git a/stitchcode/commandCache.js b/stitchcode/turtleShepherd.js similarity index 88% rename from stitchcode/commandCache.js rename to stitchcode/turtleShepherd.js index 9a74d0a7..1dcf6ae7 100644 --- a/stitchcode/commandCache.js +++ b/stitchcode/turtleShepherd.js @@ -1,9 +1,9 @@ -function CommandCache() { +function TurtleShepherd() { this.clear(); } -CommandCache.prototype.addMoveTo= function(x,y,penState) { +TurtleShepherd.prototype.addMoveTo= function(x,y,penState) { this.cache.push( { "cmd":"move", @@ -28,11 +28,11 @@ CommandCache.prototype.addMoveTo= function(x,y,penState) { //if (DEBUG) tstools.debug_msg("add move to" + x + " " + y + " " + penState ); }; -CommandCache.prototype.hasSteps = function() { +TurtleShepherd.prototype.hasSteps = function() { return this.count > 0; }; -CommandCache.prototype.addColorChange= function(color) { +TurtleShepherd.prototype.addColorChange= function(color) { this.cache.push( { "cmd":"color", @@ -41,7 +41,7 @@ CommandCache.prototype.addColorChange= function(color) { ); }; -CommandCache.prototype.clear = function() { +TurtleShepherd.prototype.clear = function() { this.cache = []; this.minX = 0; this.minY = 0; @@ -55,35 +55,35 @@ CommandCache.prototype.clear = function() { this.scale = 1; }; -CommandCache.prototype.initPosition = function(x,y) { +TurtleShepherd.prototype.initPosition = function(x,y) { this.initX = x; this.initY = y; }; -CommandCache.prototype.setScale = function(s) { +TurtleShepherd.prototype.setScale = function(s) { this.scale = s; if (DEBUG) tstools.debug_msg("zoom to scale "+ s ); }; -CommandCache.prototype.zoomIn = function() { +TurtleShepherd.prototype.zoomIn = function() { this.scale += 0.1; if (DEBUG) tstools.debug_msg("zoom to scale "+this.scale ); }; -CommandCache.prototype.zoomOut = function() { +TurtleShepherd.prototype.zoomOut = function() { if (this.scale > 0.15) this.scale -= 0.1; if (DEBUG) tstools.debug_msg("zoom to scale "+ this.scale ); }; -CommandCache.prototype.setDimensions = function(x,y) { +TurtleShepherd.prototype.setDimensions = function(x,y) { this.w = x; this.h = y; }; -CommandCache.prototype.renderGrid = function(size=50) { +TurtleShepherd.prototype.renderGrid = function(size=50) { return '' + '' + '' + @@ -91,7 +91,7 @@ CommandCache.prototype.renderGrid = function(size=50) { ''; }; -CommandCache.prototype.toSVG = function() { +TurtleShepherd.prototype.toSVG = function() { //var svgStr = "\n"; //svgStr += "\n"; diff --git a/stitchcode/turtlestitch.js b/stitchcode/turtlestitch.js index 19dba0aa..f783282e 100644 --- a/stitchcode/turtlestitch.js +++ b/stitchcode/turtlestitch.js @@ -1,15 +1,15 @@ -cmdCache = new CommandCache(); +turtleShepherd = new TurtleShepherd(); DEBUG = true; function reDraw(cnv) { //load a svg snippet in the canvas with id = 'svg' canvas = document.getElementById('svg'); //document.getElementById("code").innerHTML = cmdCache.toSVG(); - //document.getElementById("svg2").innerHTML = cmdCache.toSVG(); + document.getElementById("svg2").innerHTML = turtleShepherd.toSVG(); //canvg(document.getElementById('svg'), cmdCache.toSVG()); - canvg(cnv, cmdCache.toSVG()); + //canvg(cnv, cmdCache.toSVG()); //var cnv = caller.parent.penTrails(); //var ctx = cnv.getContext('2d');