written/tested in Daz Studio but will be in an arduino Leonardo plotter firmware
var dirx; var diry; plot( -10, -3 ); function plot( dx, dy ) // this is a relative movement { dirx = ( dx >= 0 ); diry = ( dy >= 0 ); var adx = Math.abs( dx ); var ady = Math.abs( dy ); if( adx >= ady ) { subplot( 0, adx, ady ); } else { subplot( 1, ady, adx ); } } function subplot( horizVert, dx, dy ) { var D = 2 * dy - dx; var stepy = 0; for( x = 1; x <= dx; x++ ) { if( D > 0 ) { stepy = 1; D = D - dx; } D = D + dy; if( horizVert == 0 ) { subsubplot( 1, stepy ); } else { subsubplot( stepy, 1 ); } stepy = 0; } } function subsubplot( stepx, stepy ) { debug( stepx, stepy ); }
No comments:
Post a Comment