//------------------------------------------------------------------------------ function drawLine(x1, y1, x2, y2, context, strokeStyle, lineWidth) { context.beginPath(); x1 = Math.floor(x1) + 0.5; x2 = Math.floor(x2) + 0.5; y1 = Math.floor(y1) + 0.5; y2 = Math.floor(y2) + 0.5; context.moveTo(x1, y1); context.lineTo(x2, y2); context.strokeStyle = strokeStyle; context.lineWidth = lineWidth; context.stroke(); } //------------------------------------------------------------------------------ function drawHorizontalDashedLine(xx0, xx, yy0, dashLength, context, strokeStyle, lineWidth) { n = 0; if (xx0 > xx) { tmp = xx0; xx0 = xx; xx = tmp; } while (true) { x1 = xx0 + dashLength * n; if (x1 > xx) break; x2 = xx0 + dashLength * (n + 1); if (x2 > xx) x2 = xx; drawLine(x1, yy0, x2, yy0, context, strokeStyle, lineWidth); n += 2; } } //--------------------------------------------------------------------------- function round(value, decimals) { return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); } //------------------------------------------------------------------------------ function Levels(canvasName) { var canvas = document.getElementById(canvasName); var context = canvas.getContext('2d'); var canvasHeight = canvas.height; var canvasWidth = canvas.width; var lineWidth=1; this.getLineWidth = function () { return lineWidth; }; this.setLineWidth = function (newVal) { lineWidth = newVal; }; var data; this.setData = function (newVal) { data=newVal; this.draw(0, 0, 0, 0);//if(mode===0)//isFirstRun }; this.getData = function () { return data; }; var bgColor = "lightgoldenrodyellow"; this.getBgColor = function () { return bgColor; }; this.setBgColor = function (newVal) { bgColor = newVal; }; var lineColor="red"; this.getLineColor = function () { return lineColor; }; this.setLineColor = function (newVal) { lineColor = newVal; }; var fontColor="black"; this.getFontColor = function () { return fontColor; }; this.setFontColor = function (newVal) { fontColor = newVal; }; var font="12px Calibri"; this.getFont = function () { return font; }; this.setFont = function (newVal) { font = newVal; }; var isFirstRun = true; var isRestorePreviousScale=false; var zoomX1; var zoomY1; var canvas0; var canvas3; var context0; this.startZoom = function (x1, y1) { zoomX1 = x1; zoomY1 = y1; canvas0 = document.createElement('canvas'); canvas0.width = canvas.width; canvas0.height = canvas.height; context0 = canvas0.getContext('2d'); context0.drawImage(canvas, 0, 0); }; var canvas2 = document.createElement('canvas'); canvas2.width = canvas.width; canvas2.height = canvas.height; var context2 = canvas2.getContext('2d'); var canvas3 = document.createElement('canvas'); canvas3.width = canvas.width; canvas3.height = canvas.height; var context3 = canvas3.getContext('2d'); this.continueZoom = function (x2, y2) { context2.clearRect(0, 0, canvas.width, canvas.height); context3.clearRect(0, 0, canvas.width, canvas.height); context3.beginPath(); //context3.rect(zoomX1, zoomY1, -(zoomX1 - x2), -(zoomY1 - y2)); context3.lineWidth = 2; context3.strokeStyle = 'black'; context3.stroke(); drawLine(110-5, zoomY1, 110-5, y2, context3, 'black', 2); drawLine(110+60+5, zoomY1, 110+60+5, y2, context3, 'black', 2); context2.drawImage(canvas0, 0, 0); context2.drawImage(canvas3, 0, 0); context.drawImage(canvas2, 0, 0); }; this.endZoom = function (x1, y1) { if (Math.abs(zoomX1 - x1) < 10 && Math.abs(zoomY1 - y1) < 10) { context.drawImage(canvas0, 0, 0); return; } this.draw(zoomY1, y1, 0, 2);//if(mode===2)//isZoom }; this.restoreInitialScale = function () { this.draw(0, 0, 0, 3);//if(mode===3)//isDraw10=isRestoreInitialScale }; this.restorePreviousScale = function () { this.draw(0, 0, 0, 1);//if(mode===1)//isRestorePreviousScale }; this.drawFirst10 = function () { this.draw(0, 0, 0, 3);//if(mode===3)//isDraw10 } this.drawAll = function () { this.draw(0, 0, 0, 4);//if(mode===4)//isDrawAll } var C,COld,Dmin,Dmax,DminOld,DmaxOld; this.draw = function (y_start, y_end, numLev, mode) { var data1=[],data2=[],data3=[]; var tmp1= data.split('\n'); var i; for(i=0;i