JSAD (JavaScript Aided Design) 1.0.12


use F5 to restart project (if you started from empty drawing; if not, take it as "load")
if you want to save your drawing, do so saving as web page (not in all browsers)

use mouse for drawing freehand lines
use "d" (hold the button while you use mouse) for perpenDicular lines
use "f" for nonFreehand lines
use "df" for perpenDicular nonFreehand lines
use "a" for drawing circles
use "s" to find nearest Snap point
use "z" for Zooming mode (try moving mouse)
use "zd" for zooming out
use "zf" for zooming in
use "z" and mouse button to create zoomwindow (zoom into the region defined by drawn rectangle)



Copyright 2012-2015 Cenek Svoboda, svobo.c@gmail.com

'; var jsoDat=d.find("jsonData"); jsoDat.innerHTML=jsonData; return true; }; d.inputHandling=function(xyz) { do{ if(d.inArray(d.zmacklyCudliky,90)){ if(d.inArray(d.zmacklyCudliky,68)&&d.inArray(d.zmacklyCudliky,70)){ break; } if(d.inArray(d.zmacklyCudliky,68)){ // zoom out d.zoomDistance+=0.02; } if(d.inArray(d.zmacklyCudliky,70)){ // zoom in if(d.zoomDistance>0.02){ d.zoomDistance-=0.02; } } if(d.inArray(d.zmacklyCudliky,83)){ // zoom max ... jednorazove?... todo } } }while(false); if(d.zoomingStarts){ d.zoomStartMouseX=d.mouseOnScreenCoordinateX; d.zoomStartMouseY=d.mouseOnScreenCoordinateY; d.screenOriginCaptureX=d.screenOriginOnPlaneCoordinateX; d.screenOriginCaptureY=d.screenOriginOnPlaneCoordinateY; d.zoomingStarts=false; }else if(d.zoomingEnds){ d.zoomStartMouseX=0; d.zoomStartMouseY=0; d.zoomEndMouseX=d.mouseOnScreenCoordinateX; d.zoomEndMouseY=d.mouseOnScreenCoordinateY; d.zoomingEnds=false; }else if(d.zooming){ if(!d.mousePressed){ d.screenOriginOnPlaneCoordinateX=d.screenOriginCaptureX-(d.mouseOnScreenCoordinateX-d.zoomStartMouseX)*d.zoomDistance; d.screenOriginOnPlaneCoordinateY=d.screenOriginCaptureY-(d.mouseOnScreenCoordinateY-d.zoomStartMouseY)*d.zoomDistance; } } return true; }; d.snapping=function(xyz) { if(d.drawingSnappingCircle){ var lineCount=d.count(d.lines); var currentDistanceSquare; var theLine=0; for(;theLinetheDistanceSquare){ d.snappingByLine=true; d.snappingByIntersection=false; d.whichLineIsSnapped=theLine; d.whichEndpointIsSnapped=theEnd; } ++theEnd; } ++theLine; } var intersectionCount=d.count(d.intersections); var theIntersection=0; for(;theIntersectiontheDistanceSquare){ d.snappingByLine=false; d.snappingByIntersection=true; d.whichIntersectionIsSnapped=theIntersection; } ++theIntersection; } } return true; }; d.onmousemoveFunction=function(eve) { var ef=window.event||eve; d.mouseOnScreenCoordinateX=ef.pageX||ef.clientX; d.mouseOnScreenCoordinateY=ef.pageY||ef.clientY; d.mouseOnPlaneCoordinateX=d.getPlaneCoordinateByScreenCoordinateX(d.mouseOnScreenCoordinateX); d.mouseOnPlaneCoordinateY=d.getPlaneCoordinateByScreenCoordinateY(d.mouseOnScreenCoordinateY); if(d.mousePressed&&!d.zooming){ if(d.firstMoophAfterPress){ d.captureX=d.mouseOnPlaneCoordinateX; d.captureY=d.mouseOnPlaneCoordinateY; d.firstMoophAfterPress=false; } if(d.inArray(d.zmacklyCudliky,70)){ }else{ var linesAppended=0; if(!d.inArray(d.zmacklyCudliky,65)){ if(d.inArray(d.zmacklyCudliky,68)){ var dx=d.abs(d.captureX-d.mouseOnPlaneCoordinateX); var dy=d.abs(d.captureY-d.mouseOnPlaneCoordinateY); if(dx0){ if(linesAppended>1){ d.findLastIntersections('lines',2); }else{ d.findLastIntersections('lines',1); } } } d.captureX=d.mouseOnPlaneCoordinateX; d.captureY=d.mouseOnPlaneCoordinateY; } //var snapLog=d.find('snapLog'); if(d.inArray(d.zmacklyCudliky,83)){ d.drawingSnappingCircle=true; //snapLog.innerHTML = "s"; }else{ d.drawingSnappingCircle=false; //snapLog.innerHTML = ""; } }; d.onmousedownFunction=function(eve) { var ef=window.event||eve; d.lastDownOnScreenX=ef.pageX||ef.clientX; d.lastDownOnScreenY=ef.pageY||ef.clientY; if(!d.inArray(d.zmacklyCudliky,83)){ d.lastDownOnPlaneX=d.getPlaneCoordinateByScreenCoordinateX(d.lastDownOnScreenX); d.lastDownOnPlaneY=d.getPlaneCoordinateByScreenCoordinateY(d.lastDownOnScreenY); }else{ d.lastDownOnPlaneX=d.theCurrentPointX; d.lastDownOnPlaneY=d.theCurrentPointY; d.lastDownOnScreenX=d.getScreenCoordinateByPlaneCoordinateX(d.lastDownOnPlaneX); d.lastDownOnScreenY=d.getScreenCoordinateByPlaneCoordinateY(d.lastDownOnPlaneY); } d.mousePressed=true; d.captureX=d.lastDownOnScreenX; d.captureY=d.lastDownOnScreenY; d.redrawing=true; if(d.inArray(d.zmacklyCudliky,70)){ d.drawingTheLine=true; } if(d.inArray(d.zmacklyCudliky,65)){ d.drawingTheCircle=true; } if(d.inArray(d.zmacklyCudliky,90)){ d.drawingTheZoomWindow=true; d.zoomWindowDownX=d.lastDownOnScreenX; d.zoomWindowDownY=d.lastDownOnScreenY; } }; d.onmouseupFunction=function(eve) { var ef=window.event||eve; d.lastUpOnScreenX=ef.pageX||ef.clientX; d.lastUpOnScreenY=ef.pageY||ef.clientY; if(!d.inArray(d.zmacklyCudliky,83)){ d.lastUpOnPlaneX=d.getPlaneCoordinateByScreenCoordinateX(d.lastUpOnScreenX); d.lastUpOnPlaneY=d.getPlaneCoordinateByScreenCoordinateY(d.lastUpOnScreenY); }else{ d.lastUpOnPlaneX=d.theCurrentPointX; d.lastUpOnPlaneY=d.theCurrentPointY; d.lastUpOnScreenX=d.getScreenCoordinateByPlaneCoordinateX(d.lastUpOnPlaneX); d.lastUpOnScreenY=d.getScreenCoordinateByPlaneCoordinateY(d.lastUpOnPlaneY); } d.firstMoophAfterPress=true; d.drawingTheLine=false; d.drawingTheCircle=false; d.drawingTheZoomWindow=false; var linesAppended=0; var circlesAppended=0; if(d.inArray(d.zmacklyCudliky,70)){ if(d.inArray(d.zmacklyCudliky,68)){ var dx=d.abs(d.lastDownOnPlaneX-d.lastUpOnPlaneX); var dy=d.abs(d.lastDownOnPlaneY-d.lastUpOnPlaneY); if(dx(dy/d.windowHeight)){ d.zoomDistance*=(dx/d.windowWidth); }else{ d.zoomDistance*=(dy/d.windowHeight); } } if(!d.inArray(d.zmacklyCudliky,90)){ d.redrawing=false; } d.mousePressed=false; }; d.jsad=function() { document.onkeyup=d.keyup; document.onkeydown=d.keydown; var ih=MOOPH.createPseudoThread(); var dr=MOOPH.createPseudoThread(); var sij=MOOPH.createPseudoThread(); var rf=MOOPH.createPseudoThread(); var sn=MOOPH.createPseudoThread(); ih.setFunction(d.inputHandling); dr.setFunction(d.drawing); var isIE = /*@cc_on!@*/false; if(isIE){ dr.setTimeoutDelay(200); } sij.setFunction(d.savingInJson); rf.setFunction(d.refreshing); sn.setFunction(d.snapping); ih.start(); dr.start(); sij.start(); rf.start(); sn.start(); }; d.startThat=function() { d.find("root").style.overflow="hidden"; d.find("bodisko").style.overflow="hidden"; d.find("intro").innerHTML=""; d.jsad(); }; if(d.count(d.lines)>0||d.count(d.circles)>0){ d.startThat(); } //]]>