From e4a6d44f121bbcd1b07683f692d553e96fedf9d2 Mon Sep 17 00:00:00 2001 From: Cristiano Belloni Date: Wed, 25 Sep 2013 17:41:59 +0100 Subject: [PATCH] Preparing for release 0.6.0 --- dist/kievII.js | 116 ++++++++++++++++++++++----------------------- dist/kievII.min.js | 7 ++- 2 files changed, 61 insertions(+), 62 deletions(-) diff --git a/dist/kievII.js b/dist/kievII.js index cee5914..9cf04db 100644 --- a/dist/kievII.js +++ b/dist/kievII.js @@ -364,7 +364,7 @@ K2.UI = function(engine, parameters) { var realCoords = that.getEventPosition(evt, that.domElement); - console.log ("About to notify a mouse event of type", type); + 0; that.elementsNotifyEvent(realCoords.x, realCoords.y, type); }; }; @@ -379,7 +379,7 @@ K2.UI = function(engine, parameters) { var realCoords = that.getEventPosition(event, that.domElement, evt); - console.log ("About to notify an Hammer event of type", type); + 0; that.elementsNotifyEvent(realCoords.x, realCoords.y, type); @@ -1017,26 +1017,26 @@ K2.Area.prototype.tap = K2.Area.prototype.dragstart = function(x, y) { if ((x > left_min_prox) && x < (left_max_prox) && this.dragBorders.left === true) { // We're next to the left side this.leftSide = true; - console.log ("Left side click detected"); + 0; } if ((x > right_min_prox) && x < (right_max_prox) && this.dragBorders.right === true) { // We're next to the right side this.rightSide = true; - console.log ("Right side click detected"); + 0; } if ((y > bottom_min_prox) && y < (bottom_max_prox) && this.dragBorders.bottom === true) { // We're next to the bottom side this.bottomSide = true; - console.log ("Bottom side click detected"); + 0; } if ((y > top_min_prox) && y < (top_max_prox) && this.dragBorders.top === true) { // We're next to the top side this.topSide = true; - console.log ("Top side click detected"); + 0; } if (this.isInArea (x,y)) { - console.log ("clicked inside!"); + 0; this.inside = true; this.startPoint = [x,y]; } @@ -1448,7 +1448,7 @@ K2.Curve.prototype.release = function(x, y) { if (this.isInCurve(x, y)) { //Curve is selected this.selectStart = false; - console.log ("selected curve!", this); + 0; return {'slot': 'selected', 'value': [x, y]}; } @@ -1472,12 +1472,12 @@ K2.Curve.prototype.doubletap = function(x, y) { var handleNum; if ((handleNum = this.isInHandle(x, y)) !== null) { // Handle is double-tapped. This has precedence - console.log ("duble tapped handle!", this); + 0; return {'slot' : 'doubletap_h', 'value' : [[x, y], handleNum]}; } if (this.isInCurve(x, y)) { //Curve is double-tapped - console.log ("duble tapped curve!", this); + 0; return {'slot' : 'doubletap_c', 'value' : [x, y]}; } } @@ -2033,7 +2033,7 @@ K2.Bar.prototype.dragstart = function(curr_x, curr_y) { K2.Bar.prototype.setValue = function(slot, value) { - console.log('Setting ' + slot + ' to ' + value); + 0; if (slot == 'barPos') { if (value[0] <= this.width) { @@ -2351,11 +2351,11 @@ K2.ClickBar.prototype.getready = function(args) { K2.ClickBar.prototype.isInROI = function(x, y) { - console.log ('y = ', y, "roitop = ", this.ROITop); + 0; if ((x >= this.ROILeft) && (y >= this.ROITop - this.landingHeight)) { - console.log ("1st"); + 0; if ((x <= (this.ROILeft + this.ROIWidth)) && (y <= (this.ROITop + this.ROIHeight + this.landingHeight))) { - console.log ("In ROI!"); + 0; return true; } } @@ -2366,9 +2366,9 @@ K2.ClickBar.prototype.isInROI = function(x, y) { K2.ClickBar.prototype.calculateValue = function (x,y) { var clickedHeigth = y - this.yOrigin; - console.log ("heigth on click is ", clickedHeigth, " pixels"); + 0; var clickedValue = 1 - (clickedHeigth / this.height); - console.log ("for a value of ", clickedValue, " (", clickedHeigth, " / ", this.height, ")"); + 0; if (clickedValue > this.maxValue) { clickedValue = this.maxValue; @@ -2533,14 +2533,14 @@ K2.Gauge.prototype.calculateAngle = function (x,y) { var centerX = this.xOrigin + this.width / 2; var centerY = this.yOrigin + this.height / 2; - console.log ("Point is: ", x, y, "Center is: ", centerX, centerY); + 0; var radtan = Math.atan2 (x - centerX, y - centerY); - console.log('radiant atan ', radtan); + 0; var degreetan = radtan * (180 / Math.PI); degreetan = 180 - degreetan; - console.log('degree atan ', degreetan); + 0; return K2.MathUtils.linearRange(0, 360, 0, 1, Math.floor(degreetan)); @@ -2549,11 +2549,11 @@ K2.Gauge.prototype.calculateAngle = function (x,y) { K2.Gauge.prototype.touch = function(x, y) { var dist = K2.MathUtils.distance(x, y, this.xOrigin + this.width / 2, this.yOrigin + this.height / 2); - console.log("dist is, ", dist, " radius is ", this.radius, " thickness is ", this.thickness); + 0; if ((dist > this.radius - this.thickness / 2) && (dist < this.radius + this.thickness / 2)) { - console.log("down / tapped Inside the dial"); + 0; this.triggered = true; var range_val = this.calculateAngle (x,y); @@ -2569,7 +2569,7 @@ K2.Gauge.prototype.touch = function(x, y) { K2.Gauge.prototype.drag = function (x, y) { if (this.triggered) { - console.log ("triggered mousemove"); + 0; var range_val = this.calculateAngle (x,y); return {'slot': 'gaugevalue', 'value': range_val}; @@ -2875,18 +2875,18 @@ K2.Knob.prototype.calculateAngle = function (x,y) { var centerX = this.xOrigin + this.width / 2; var centerY = this.yOrigin + this.height / 2; - console.log ("Point is: ", x, y, "Center is: ", centerX, centerY); + 0; var radtan = Math.atan2 (x - centerX, y - centerY); - console.log('radiant atan ', radtan); + 0; // normalize arctan if (radtan < 0) { radtan += (2 * Math.PI); } - console.log ('radiant atan, normalized, is ', radtan); + 0; var degreetan = radtan * (180 / Math.PI); - console.log('degree atan is', degreetan); + 0; // now we have a value from 0 to 360, where 0 is the lowest // intersection with the circumference. degree increases anticlockwise @@ -2907,7 +2907,7 @@ K2.Knob.prototype.calculateAngle = function (x,y) { } var range_val = K2.MathUtils.linearRange(0, 360, 0, 1, Math.floor(degreetan)); - console.log ('value is', range_val); + 0; return range_val; }; @@ -3187,16 +3187,16 @@ K2.RotKnob.prototype.getRangedAmount = function (angle) { var endAngOffset = this.stopAngValue - this.initAngValue; var startAngOffset = this.startAngValue - this.initAngValue; - console.log ("start -> end", startAngOffset, endAngOffset); + 0; if ((angle > this.initAngValue) && (startAngOffset < 0)) { - console.log ("Angle now is", angle); + 0; angle = -(360 - angle); } var rangedAng = K2.MathUtils.linearRange(startAngOffset, endAngOffset, 0, 1, angle); - console.log ("knob value", rangedAng); + 0; if (rangedAng < 0) { rangedAng = 0; @@ -3225,10 +3225,10 @@ K2.RotKnob.prototype.calculateAngle = function (x,y) { var centerX = this.xOrigin + this.width / 2; var centerY = this.yOrigin + this.height / 2; - console.log ("Point is: ", x, y, "Center is: ", centerX, centerY); + 0; var radtan = Math.atan2 (x - centerX, y - centerY); - console.log('radiant atan ', radtan); + 0; var degreetan = radtan * (180 / Math.PI); degreetan = 180 - degreetan; @@ -3241,7 +3241,7 @@ K2.RotKnob.prototype.calculateAngle = function (x,y) { } var degreeMod = (degreetan - this.initAngValue) % 360; - console.log('degreetan -> offset', degreetan, degreeOffset, degreeMod); + 0; return this.getRangedAmount(Math.floor(degreeOffset)); @@ -3359,7 +3359,7 @@ K2.RotKnob.prototype.setValue = function(slot, value) { stepped_new_value = value; } - console.log('Value is: ', stepped_new_value); + 0; // Now, we call the superclass K2.RotKnob.superclass.setValue.call(this, slot, stepped_new_value); @@ -3678,13 +3678,13 @@ K2.Wavebox.prototype.release = function(curr_x, curr_y) { } else { - console.error('orientation invalid, this will probably break something'); + 0; } // Click on button is completed, the button is no more triggered. this.triggered = false; - console.log ("returning event", ret); + 0; return ret; } } @@ -3750,11 +3750,11 @@ K2.Wavebox.prototype.setValue = function(slot, value) { if (slot == 'yPos') { if (value <= this.height) { - console.log('Setting yPos to ' + value); + 0; this.values.yPos = value; } else { - console.log('NOT setting yPos to ' + value + ' because height is ' + this.height); + 0; } } }; @@ -3791,7 +3791,7 @@ K2.Wavebox.prototype.refresh_CANVAS2D = function(engine) { binFunction = this.calculateBinNone; } else { - console.log('Error: no binMethod!'); + 0; } var i; @@ -4008,7 +4008,7 @@ var CurveEditor = function(parameters) { this.callback = function() { var that = this; return function(slot, value, element) { - console.log("Element: ", element, ". onValueSet callback: slot is ", slot, " and value is ", value, " while that is ", that); + 0; // Call the optional callback if (typeof that.externalCallback === 'function') { @@ -4071,7 +4071,7 @@ var CurveEditor = function(parameters) { that.status.curveArray.splice(that.status.selected + 1, 0, newCurveArgs.ID); } - console.log("Reorganizing elements"); + 0; that.reorganizeElements(); that.ui.refresh(); }; @@ -4089,7 +4089,7 @@ var CurveEditor = function(parameters) { }; this.addCurve = function(curveType, grade, first_point, last_point) { - console.log("Adding a curve"); + 0; var lastElementID; // Get a deep copy of the template object @@ -4143,7 +4143,7 @@ var CurveEditor = function(parameters) { if ((lastPoint[0] === this.lastCalculatedPoint[0]) && (lastPoint[1] === this.lastCalculatedPoint[1])) { // Set the curve to paint only its first handle - console.log("Remove something before adding stuff"); + 0; // Undo the previous paintTerminalPoints inference this.ui.setProp(lastElementID, 'paintTerminalPoints', 'all'); return; @@ -4184,7 +4184,7 @@ var CurveEditor = function(parameters) { var prevID; if (this.status.selected !== null) { - console.log("Deleting selected curve " + this.status.selected); + 0; //arr = arr.filter(function(){return true}); @@ -4229,7 +4229,7 @@ var CurveEditor = function(parameters) { var i; if (this.status.selected !== null) { - console.log("Transforming selected curve " + this.status.selected); + 0; var bezierN = grade; @@ -4240,11 +4240,11 @@ var CurveEditor = function(parameters) { if (curveNow === curveType) { if (curveType !== 'bezier') { - console.log("Identical type, doing nothing"); + 0; return; } else { if (bezierN === curveGrade) { - console.log("Identical type and grade, doing nothing"); + 0; return; } } @@ -4369,7 +4369,7 @@ var AreaEditor = function(parameters) { this.callback = function() { var that = this; return function(slot, value, element) { - console.log("Element: ", element, ". onValueSet callback: slot is ", slot, " and value is ", value, " while that is ", that); + 0; // Call the optional callback if (typeof that.externalCallback === 'function') { @@ -4438,7 +4438,7 @@ var AreaEditor = function(parameters) { }; this.addArea = function(width, height) { - console.log("Adding an area"); + 0; var lastElement; // Get a deep copy of the template object @@ -4565,11 +4565,11 @@ var BarSelect = function (parameters) { this.callback = function() { var that = this; return function(slot, value, element) { - console.log("Element: ", element, ". onValueSet callback: slot is ", slot, " and value is ", value, " while that is ", that); + 0; var width; if (slot === 'dragStart') { - console.log ('Storing dragStart value ', value); + 0; that.dragStart = value; if (that.areaElement === null) { @@ -5099,7 +5099,7 @@ K2.OSC.Decoder.prototype.decode = function (msg) { } } catch (e) { - console.log("can't decode incoming message: " + e.message); + 0; } }; @@ -5145,13 +5145,13 @@ K2.OSCHandler = function (proxyServer, udpServers) { this.socket = io.connect('http://' + this.proxyServer.host + ':' + this.proxyServer.port); } catch (e) { - console.error ("io.connect failed. No proxy server?"); + 0; return; } this.socket.on('admin', function (data) { // TODO check the version and the ID - console.log("Received an admin message: ", data); + 0; // Let's assume everything is OK this.proxyOK = true; @@ -5167,7 +5167,7 @@ K2.OSCHandler = function (proxyServer, udpServers) { // OSC is received from the server // Transform it in an array var oscArray = Array.prototype.slice.call(data.osc, 0); - console.log ("received osc from the server: " + oscArray); + 0; // Send it to the local clients this.sendLocalMessage (oscArray); @@ -5175,7 +5175,7 @@ K2.OSCHandler = function (proxyServer, udpServers) { this.socket.on ('disconnect', function (data) { - console.log ("socket disconnected"); + 0; this.proxyConnected = false; this.proxyOK = false; @@ -5183,7 +5183,7 @@ K2.OSCHandler = function (proxyServer, udpServers) { this.socket.on ('connect', function (data) { - console.log ("socket connected"); + 0; this.proxyConnected = true; }.bind(this)); @@ -5202,7 +5202,7 @@ K2.OSCHandler.prototype.unregisterClient = function (clientID) { K2.OSCHandler.prototype.sendLocalMessage = function (oscMessage, clientID) { // Try to decode it var received = this.OSCDecoder.decode (oscMessage); - console.log ("decoded OSC = " + received); + 0; // Send it to the callbacks, except for the clientID one for (var client in this.localClients) { diff --git a/dist/kievII.min.js b/dist/kievII.min.js index 2cbeca8..c5e7a23 100644 --- a/dist/kievII.min.js +++ b/dist/kievII.min.js @@ -1,4 +1,3 @@ -/*! kievII v0.6.0 built on 24-09-2013 */ -!function(a){"function"==typeof define&&define.amd?define(["hammer"],a):window.K2=window.KievII=a(window.Hammer)}(function(a){var b={};b.extend=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a,a.superclass=b.prototype,b.prototype.constructor==Object.prototype.constructor&&(b.prototype.constructor=b)},b.clone=function(a){var b;if(null===a||"object"!=typeof a)return a;if(a instanceof Date)return b=new Date,b.setTime(a.getTime()),b;if(a instanceof Array){b=[];for(var c=0,d=a.length;d>c;++c)b[c]=clone(a[c]);return b}if(a instanceof Object){b={};for(var e in a)a.hasOwnProperty(e)&&(b[e]=clone(a[e]));return b}throw new Error("Unable to copy obj! Its type isn't supported.")},b.mergeObject=function(a,b){var c={};if(!b)return a;for(var d in a)c[d]=d in b?b[d]:a[d];return c},b.UIElement=function(a){arguments.length&&this.getready(a)},b.UIElement.prototype.getready=function(a){if(this.ID=a.ID,this.isListening=a.isListening,"undefined"==typeof this.isListening&&(this.isListening=!0),"boolean"!=typeof this.isListening)throw"Property isListening for element "+this.ID+" is not boolean "+this.isListening;if(this.isVisible=a.isVisible,"undefined"==typeof this.isVisible&&(this.isVisible=!0),"boolean"!=typeof this.isVisible)throw"Property isVisible for element "+this.ID+" is not boolean "+this.isVisible;this.xOrigin=a.left,this.yOrigin=a.top,this.ROILeft="undefined"!=typeof a.ROILeft?a.ROILeft:this.xOrigin,this.ROITop="undefined"!=typeof a.ROITop?a.ROITop:this.yOrigin,this.ROIWidth=a.ROIWidth,this.ROIHeight=a.ROIHeight,this.values={},this.transparency=a.transparency||1,this.objParms=a.objParms,"undefined"!=typeof a&&(this.onValueSet=a.onValueSet)},b.UIElement.prototype.isInROI=function(){return!1},b.UIElement.prototype.getValues=function(){var a,b=[];for(a in this.values)this.values.hasOwnProperty(a)&&b.push(a);return b},b.UIElement.prototype.getXCoord=function(){return this.xOrigin},b.UIElement.prototype.getYCoord=function(){return this.yOrigin},b.UIElement.prototype.getWidth=function(){return this.width},b.UIElement.prototype.getHeight=function(){return this.height},b.UIElement.prototype.setHeight=function(a){this.height=a,"undefined"==typeof this.ROIHeight&&(this.ROIHeight=a)},b.UIElement.prototype.setWidth=function(a){this.width=a,"undefined"==typeof this.ROIWidth&&(this.ROIWidth=a)},b.UIElement.prototype.getValue=function(a){if("undefined"==typeof this.values[a])throw new Error("Slot "+a+" not present or value undefined");return this.values[a]},b.UIElement.prototype.setValue=function(a,b){if("undefined"==typeof this.values[a])throw new Error("Slot "+a+" not present or value undefined");b!==this.values[a]&&(this.values[a]=b)},b.UIElement.prototype.setListening=function(a){if("boolean"!=typeof a)throw"Property isListening for element "+this.ID+" is not boolean "+a;this.isListening=a},b.UIElement.prototype.getListening=function(){return this.isListening},b.UIElement.prototype.refresh=function(a){var b="call_"+a.type;if("function"!=typeof this[b])throw"Element "+this.ID+" "+b+" is not a function. Its type is "+typeof this[b];this[b](a)},b.UIElement.prototype.call_CANVAS2D=function(a){var b="refresh_"+a.type;if(a.context.save(),a.context.globalAlpha=this.transparency,"function"!=typeof this[b])throw"Element "+this.ID+" "+b+" is not a function. Its type is "+typeof this[b];this[b](a),a.context.restore()},b.UIElement.prototype.getID=function(){return this.ID},b.UIElement.prototype.setDrawClass=function(a){this.drawClass=a},b.UIElement.prototype.setVisible=function(a){if("boolean"!=typeof a)throw"Property isVisible for element "+this.ID+" is not boolean "+a;this.isVisible=a},b.UIElement.prototype.getVisible=function(){return this.isVisible},b.UIElement.prototype.setGraphicWrapper=function(a){this.wrapper=a},b.UI=function(c,d){this.getEventPosition=function(a,b){var c,d,e=parseInt(document.defaultView.getComputedStyle(b,null).paddingLeft,10)||0,f=parseInt(document.defaultView.getComputedStyle(b,null).paddingTop,10)||0,g=parseInt(document.defaultView.getComputedStyle(b,null).borderLeftWidth,10)||0,h=parseInt(document.defaultView.getComputedStyle(b,null).borderTopWidth,10)||0,i=document.body.parentNode,j=i.offsetTop,k=i.offsetLeft,l=b,m=0,n=0;if("undefined"!=typeof l.offsetParent)do m+=l.offsetLeft,n+=l.offsetTop;while(l=l.offsetParent);m+=e+g+k,n+=f+h+j,c=a.pageX-m,d=a.pageY-n;var o=parseInt(document.defaultView.getComputedStyle(b,null).getPropertyValue("width"),10)||0,p=parseInt(document.defaultView.getComputedStyle(b,null).getPropertyValue("height"),10)||0,q=b.getAttribute("width"),r=b.getAttribute("height"),s=q/o,t=r/p;return c*=s,d*=t,{x:c,y:d}},this.onMouseEvent=function(){var a=this;return function(b){var c=b.type,d=a.getEventPosition(b,a.domElement);console.log("About to notify a mouse event of type",c),a.elementsNotifyEvent(d.x,d.y,c)}},this.onHammerEvent=function(){var a=this;return function(b){var c=b.gesture.srcEvent,d=b.type,e=a.getEventPosition(c,a.domElement,b);console.log("About to notify an Hammer event of type",d),a.elementsNotifyEvent(e.x,e.y,d)}},this.elementsNotifyEvent=function(a,b,c){for(var d=this.zMax;d>=this.zMin;d-=1)if("undefined"!=typeof this.zArray[d])for(var e=this.zArray[d].length-1;e>=0;e-=1)if(this.zArray[d][e].getListening()&&"function"==typeof this.zArray[d][e][c]){var f=this.zArray[d][e][c](a,b);if("undefined"!=typeof f){if(f instanceof Array)for(var g=0;gc||"number"!=typeof c)throw new Error("zIndex "+c+" invalid");this.elements[a.ID]={element:a,zIndex:c},"undefined"==typeof this.zArray[c]&&(this.zArray[c]=[]),this.zArray[c].push(this.elements[a.ID].element),("undefined"==typeof this.zMin||this.zMin>c)&&(this.zMin=c),("undefined"==typeof this.zMax||this.zMaxb)&&(this.zMin=b),("undefined"==typeof this.zMax||this.zMaxm)throw new Error("Recursion exceeded");if(l[n].element===f&&l[n].slot===h)return}}if(this.elements[f].element.setValue(h,g),"function"==typeof this.elements[f].element.onValueSet&&i!==!1&&this.elements[f].element.onValueSet(h,this.elements[f].element.values[h],f),l.push({element:f,slot:h}),"undefined"!=typeof this.connections[f]&&"undefined"!=typeof this.connections[f][h])for(e in this.connections[f][h])if(this.connections[f][h].hasOwnProperty(e)){if(b=this.connections[f][h][e],c=b.recvElement,d=b.recvSlot,"function"==typeof b.callback){var o={sender:f,sendSlot:h,recv:c,recvSlot:d,ui:this};k=b.callback(g,o)}var p;p=b.cascade!==!1,this.setValue({elementID:c,slot:d,value:k,history:l,fireCallback:p})}},this.hideElement=function(a){var b;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");b=this.elements[a].element.getVisible(),b===!0&&(this.elements[a].element.setVisible(!1),this.elements[a].element.setListening(!1))},this.unhideElement=function(a){var b;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");b=this.elements[a].element.getVisible(),b===!1&&(this.elements[a].element.setVisible(!0),this.elements[a].element.setListening(!0))},this.setHidden=function(a,b){this.setVisible(a,!b)},this.setVisible=function(a,b){var c;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");c=this.elements[a].element.getVisible(),c!==b&&(this.elements[a].element.setVisible(b),this.elements[a].element.setListening(b))},this.setListening=function(a,b){var c;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");c=this.elements[a].element.getListening(),c!==b&&this.elements[a].element.setListening(b)},this.refreshZ=function(a){for(var b=a,c=this.zArray.length;c>b;b+=1)if("object"==typeof this.zArray[b])for(var d=0,e=this.zArray[b].length;e>d;d+=1)this.zArray[b][d].getVisible()===!0&&this.zArray[b][d].refresh(this.engine)},this.refresh=function(a){a!==!1&&this.reset(),"undefined"!=typeof this.zMin&&this.refreshZ(this.zMin)},this.reset=function(){this.engine.reset()}},b.Area=function(a){arguments.length&&this.getready(a)},b.extend(b.Area,b.UIElement),b.Area.prototype.getready=function(a){b.Area.superclass.getready.call(this,a),this.values={width:0,height:0,selected:[],xOffset:0,yOffset:0,doubletap:[],held:[]},this.defaultSlot="height",this.color=a.color||"black",this.borderColor=a.borderColor||"green",this.proximity=Math.floor(a.proximity)||10,this.thickness=Math.floor(a.thickness)||this.proximity,0===a.thickness&&(this.thickness=0),this.borders=a.borders||{top:!0,bottom:!0,right:!0,left:!0},this.dragBorders=a.dragBorders||{top:!0,bottom:!0,right:!0,left:!0},this.move=a.move||"all",this.xMonotone=a.xMonotone||!1,this.yMonotone=a.yMonotone||!1;var c=a.height||0,d=a.width||0;this.values.width=d,this.values.height=c;var e=a.left||0,f=a.top||0;this.values.xOffset=e,this.values.yOffset=f},b.Area.prototype.isInArea=function(a,b){var c=!1,d=!1;return this.values.width>0?a>this.values.xOffset&&athis.values.xOffset+this.values.width&&(c=!0),this.values.height>0?b>this.values.yOffset&&bthis.values.height+this.values.yOffset&&(d=!0),c&&d},b.Area.prototype.tap=b.Area.prototype.dragstart=function(a,b){var c=this.values.xOffset-this.proximity,d=this.values.xOffset+this.proximity,e=this.values.xOffset+this.values.width-this.proximity,f=this.values.xOffset+this.values.width+this.proximity,g=this.values.height+this.values.yOffset+this.proximity,h=this.values.height+this.values.yOffset-this.proximity,i=this.values.yOffset+this.proximity,j=this.values.yOffset-this.proximity;a>c&&d>a&&this.dragBorders.left===!0&&(this.leftSide=!0,console.log("Left side click detected")),a>e&&f>a&&this.dragBorders.right===!0&&(this.rightSide=!0,console.log("Right side click detected")),b>h&&g>b&&this.dragBorders.bottom===!0&&(this.bottomSide=!0,console.log("Bottom side click detected")),b>j&&i>b&&this.dragBorders.top===!0&&(this.topSide=!0,console.log("Top side click detected")),this.isInArea(a,b)?(console.log("clicked inside!"),this.inside=!0,this.startPoint=[a,b]):this.inside=!1},b.Area.prototype.drag=function(a,b){var c,d,e=[];if(this.leftSide&&this.borders.left){c=this.values.width-(a-this.values.xOffset);var f=a;this.xMonotone&&0>c&&(c=0,f=this.values.xOffset),e.push({slot:"width",value:c}),e.push({slot:"xOffset",value:f})}if(this.rightSide&&this.borders.right&&!this.leftSide&&(c=a-this.values.xOffset,this.xMonotone&&0>c&&(c=0),e.push({slot:"width",value:c})),this.bottomSide&&this.borders.bottom&&(d=this.values.height+(b-(this.values.yOffset+this.values.height)),this.yMonotone&&0>d&&(d=0),e.push({slot:"height",value:d})),this.topSide&&this.borders.top&&!this.bottomSide){d=this.values.height+(this.values.yOffset-b);var g=b;this.yMonotone&&0>d&&(d=0,g=this.values.yOffset),e.push({slot:"yOffset",value:g}),e.push({slot:"height",value:d})}if(e.length>0)return e;if(this.inside&&"none"!==this.move){var h=a-this.startPoint[0],i=b-this.startPoint[1];if(this.startPoint=[a,b],"all"===this.move)return[{slot:"xOffset",value:this.values.xOffset+h},{slot:"yOffset",value:this.values.yOffset+i}];if("x"===this.move)return{slot:"xOffset",value:this.values.xOffset+h};if("y"===this.move)return{slot:"yOffset",value:this.values.yOffset+i}}return void 0},b.Area.prototype.dragend=function(a,b){var c;return this.leftSide=this.rightSide=this.bottomSide=this.topSide=!1,this.inside&&this.isInArea(a,b)&&(c={slot:"selected",value:[a,b]}),this.inside=!1,c},b.Area.prototype.hold=function(a,b){return this.isInArea(a,b)?{slot:"held",value:[a,b]}:void 0},b.Area.prototype.doubletap=function(a,b){return this.isInArea(a,b)?{slot:"doubletap",value:[a,b]}:void 0},b.Area.prototype.setValue=function(a,c){b.Area.superclass.setValue.call(this,a,c)},b.Area.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){a.context.fillStyle=this.color,a.context.strokeStyle=this.borderColor,a.context.lineWidth=this.thickness;var b=Math.floor(this.thickness/2);a.context.fillRect(this.xOrigin+this.values.xOffset+b,this.values.yOffset+b,this.values.width-2*b,this.values.height-2*b),this.thickness>0&&a.context.strokeRect(this.xOrigin+this.values.xOffset,this.values.yOffset,this.values.width,this.values.height)}},b.Area.prototype.getXCoord=function(){return this.values.xOrigin},b.Area.prototype.getYCoord=function(){return this.values.yOrigin},b.Area.prototype.getWidth=function(){return this.values.width},b.Area.prototype.getHeight=function(){return this.values.height},b.Area.prototype.setHeight=function(a){this.values.height=a,"undefined"==typeof this.ROIHeight&&(this.ROIHeight=a)},b.Area.prototype.setWidth=function(a){this.values.width=a,"undefined"==typeof this.ROIWidth&&(this.ROIWidth=a)},b.Curve=function(a){arguments.length&&this.getready(a)},b.extend(b.Curve,b.UIElement),b.Curve.prototype.getready=function(a){switch(b.Curve.superclass.getready.call(this,a),this.values={points:[],selected:[],held:[],doubletap_c:[],doubletap_h:[]},this.defaultSlot="points",this.setWidth(a.width),this.setHeight(a.height),this.curveType=a.curveType||"bezier",this.thickness=a.thickness||2,this.curveColor=a.curveColor||"black",this.helperColor=a.helperColor||"#CCCCCC",this.handleColor=a.handleColor||"red",this.curveLabels="boolean"==typeof a.curveLabels?a.curveLabels:!1,this.terminalPointStyle=a.terminalPointStyle||"rect",this.paintTerminalPoints=a.paintTerminalPoints||"all",this.midPointStyle=a.midPointStyle||"circle",this.terminalPointSize=a.terminalPointSize||16,this.midPointSize=a.midPointSize||8,this.terminalPointColor=a.terminalPointColor||this.handleColor,this.midPointColor=a.midPointColor||this.handleColor,this.terminalPointFill=a.terminalPointFill||null,this.midPointFill=a.midPointFill||null,this.xMonotone=a.xMonotone||!1,this.handleSize=a.handleSize||this.terminalPointSize>this.midPointSize?this.terminalPointSize:this.midPointSize,this.handleClicked=null,this.supportPoints=[],this.selectStart=!1,this.whereHappened=[],a.curveType){case"bezier":if(0!==a.points.length%2||a.points.length<4)throw"Incorrect number of points "+a.points.length;break;case"halfcosine":case"smooth":case"linear":if(4!==a.points.length)throw"Incorrect number of points "+a.points.length;break;default:throw"Unknown curve type "+a.curveType}for(var c=[],d=0;dthis.supportPoints[c][0]-this.thickness&&athis.supportPoints[c][1]-this.thickness&&bc[d][0]-this.handleSize&&ac[d][1]-this.handleSize&&bthis.ROILeft&&b>this.ROITop&&aa[a.length-1][0]&&(a[0][0]>this.values.points[0][0]?a[0][0]=a[a.length-1][0]:a[a.length-1][0]=a[0][0])},b.Curve.prototype.drag=function(a,c){var d,e={};return null!==this.handleClicked?(d=b.GenericUtils.clone(this.values.points),this.isInROI(a,c)?(this.triggered=!1,d[this.handleClicked][0]=a,d[this.handleClicked][1]=c):(d[this.handleClicked][0]=a,d[this.handleClicked][1]=c,a>this.ROILeft+this.ROIWidth&&(d[this.handleClicked][0]=this.ROILeft+this.ROIWidth),athis.ROITop+this.ROIHeight&&(d[this.handleClicked][1]=this.ROITop+this.ROIHeight),ca&&0>b)){var c=this.drag(a,b);return this.handleClicked=null,c}},b.Curve.prototype.release=function(a,b){return this.handleClicked=null,this.selectStart===!0&&this.isInCurve(a,b)?(this.selectStart=!1,console.log("selected curve!",this),{slot:"selected",value:[a,b]}):void 0},b.Curve.prototype.hold=function(a,b){if(this.isInROI(a,b)&&this.isInCurve(a,b)){var c={slot:"held",value:[a,b]};return c}return void 0},b.Curve.prototype.doubletap=function(a,b){if(this.isInROI(a,b)){var c;if(null!==(c=this.isInHandle(a,b)))return console.log("duble tapped handle!",this),{slot:"doubletap_h",value:[[a,b],c]};if(this.isInCurve(a,b))return console.log("duble tapped curve!",this),{slot:"doubletap_c",value:[a,b]}}return void 0},b.Curve.prototype.setValue=function(a,c){var d=!0;if("points"===a)for(var e=this.values[a],f=0;f=d;d+=b){var e=this[this.curveType].P(d,this.values.points);c.push(e)}return c},b.Curve.prototype.getCurveYPoints=function(a,b){"undefined"==typeof b&&(b=1);for(var c=1/a,d=[],e=0;1>=e;e+=c){var f=this[this.curveType].P(e,this.values.points)[1]*b;d.push(f)}return d},b.Curve.prototype.getPoint=function(a){return this.supportPoints[a]},b.Curve.prototype.getnumPoints=function(){return this.supportPoints.length},b.Curve.prototype.halfcosine={P:function(a,b){var c=(1-Math.cos(a*Math.PI))/2,d=[0,0];return d[0]=b[0][0]+(b[1][0]-b[0][0])*a,d[1]=b[0][1]*(1-c)+b[1][1]*c,d}},b.Curve.prototype.smooth={P:function(a,b){var c=a*a*(3-2*a),d=[0,0];return d[0]=b[0][0]+(b[1][0]-b[0][0])*a,d[1]=b[0][1]+c*(b[1][1]-b[0][1]),d}},b.Curve.prototype.linear={P:function(a,b){var c=[0,0];return c[0]=b[0][0]+(b[1][0]-b[0][0])*a,c[1]=b[0][1]*(1-a)+b[1][1]*a,c}},b.Curve.prototype.cubic={P:function(a,b){var c=[0,0];c[0]=b[0][0]+(b[3][0]-b[0][0])*a;var d=a,e=a*a,f=b[3][1]-b[2][1]-b[0][1]+b[1][1],g=b[0][1]-b[1][1]-f,h=b[2][1]-b[0][1],i=b[1][1];return c[1]=f*d*e+g*e+h*d+i,c}},b.Curve.prototype.catmull={P:function(a,b){var c=[0,0];c[0]=b[0][0]+(b[3][0]-b[0][0])*a;var d=a,e=a*a,f=b[0][1],g=b[1][1],h=b[2][1],i=b[3][1],j=-.5*f+1.5*g-1.5*h+.5*i,k=f-2.5*g+2*h-.5*i,l=-.5*f+.5*h,m=g;return c[1]=j*d*e+k*e+l*d+m,c}},b.Curve.prototype.hermite={P:function(a,b,c,d){var e=[0,0];e[0]=b[0][0]+(b[3][0]-b[0][0])*a;var f,g,h,i,j,k,l,m,n=d||0,o=c||0,p=a,q=b[0][1],r=b[1][1],s=b[2][1],t=b[3][1];return h=p*p,i=h*p,f=(r-q)*(1+n)*(1-o)/2,f+=(s-r)*(1-n)*(1-o)/2,g=(s-r)*(1+n)*(1-o)/2,g+=(t-s)*(1-n)*(1-o)/2,j=2*i-3*h+1,k=i-2*h+p,l=i-h,m=-2*i+3*h,e[1]=j*r+k*f+l*g+m*s,e}},b.Curve.prototype.bezier={P:function(a,b){function c(a,b,c){var e=d;return"function"==typeof fact_lookup&&(e=fact_lookup),e(b)/(e(a)*e(b-a))*Math.pow(c,a)*Math.pow(1-c,b-a)}for(var d=function(a){for(var b=1,c=2;a>=c;c++)b*=c;return b},e=[0,0],f=b.length-1,g=0;f>=g;g++)e[0]+=b[g][0]*c(g,f,a),e[1]+=b[g][1]*c(g,f,a);return e}},b.Curve.prototype.genericCurve=function(a,b){function c(a,b){return Math.sqrt(Math.pow(a[0]-b[0],2)+Math.pow(a[1]-b[1],2))}function d(a){for(var b=0,d=0;d=f;f+=c){var g=b.P(f,a);e.push(g)}return e}this.supportPoints=e(a,this[b])},b.Curve.prototype.paintHandle=function(a,b,c){c===!0?this.paintPoint(a,b,this.terminalPointStyle,this.terminalPointFill,this.terminalPointColor,this.terminalPointSize):this.paintPoint(a,b,this.midPointStyle,this.midPointFill,this.midPointColor,this.midPointSize)},b.Curve.prototype.paintPoint=function(a,b,c,d,e,f){if("rect"===c)a.save(),a.strokeStyle=e,a.lineWidth=Math.round(f/5),a.strokeRect(b[0]-Math.round(f/2),b[1]-Math.round(f/2),f,f),null!==d&&(a.fillStyle=d,a.fillRect(b[0]-Math.ceil(f/2)+Math.floor(a.lineWidth/2),b[1]-Math.ceil(f/2)+Math.floor(a.lineWidth/2),f-a.lineWidth+1,f-a.lineWidth+1)),a.restore();else if("circle"===c)a.save(),a.beginPath(),a.strokeStyle=e,a.lineWidth=Math.round(f/5),a.arc(b[0],b[1],f,0,2*Math.PI,!1),null!==d&&(a.fillStyle=d,a.fill()),a.stroke(),a.restore();else if("none"!==c)throw"Unknown handle style: "+c},b.Curve.prototype.paintPoints=function(a){var b,c=this.values.points;for(a.save(),a.strokeStyle=this.helperColor,a.beginPath(),a.moveTo(c[0][0],c[0][1]),b=1;bthis.ROILeft&&b>this.ROITop&&athis.ROILeft&&athis.ROITop&&athis.width&&(c[0]=this.width),c[0]<0&&(c[0]=0)}else if(1===this.orientation){if(!this.isInROIY(a))return void 0;c=[d[0],b-this.yOrigin],c[1]>this.height&&(c[1]=this.height),c[1]<0&&(c[1]=0)}return c},b.Bar.prototype.touch=function(a,b){if(this.isInROI(a,b)){this.started=!0;var c=this.commonDrag(a,b);if("undefined"!=typeof c)return{slot:"barPos",value:c}}return void 0},b.Bar.prototype.drag=function(a,b){if(this.started){var c=this.commonDrag(a,b);if("undefined"!=typeof c)return{slot:"barPos",value:c}}return void 0},b.Bar.prototype.dragend=b.Bar.prototype.swipe=function(a,b){if(this.started){this.started=!1;var c=this.commonDrag(a,b);if("undefined"!=typeof c)return[{slot:"barPos",value:c},{slot:"dragEnd",value:[a-this.xOrigin,b-this.yOrigin]}]}return void 0},b.Bar.prototype.dragstart=function(a,b){return this.isInROI(a,b)?{slot:"dragStart",value:[a-this.xOrigin,b-this.yOrigin]}:void 0},b.Bar.prototype.setValue=function(a,b){console.log("Setting "+a+" to "+b),"barPos"==a?(b[0]<=this.width&&(this.values.barPos[0]=b[0]),b[1]<=this.height&&(this.values.barPos[1]=b[1])):this.values[a]=b},b.Bar.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var b=a.context;if(b.lineWidth=this.thickness,b.strokeStyle=this.barColor,b.beginPath(),0===this.orientation){var c=this.xOrigin+this.values.barPos[0];b.moveTo(c,this.yOrigin+this.height),b.lineTo(c,this.yOrigin)}else 1===this.orientation&&(b.moveTo(this.xOrigin+this.width,this.yOrigin+this.values.barPos[1]),b.lineTo(this.xOrigin,this.yOrigin+this.values.barPos[1]));b.stroke(),b.closePath()}},b.Button=function(a){arguments.length&&this.getready(a)},b.extend(b.Button,b.UIElement),b.Button.prototype.getready=function(a){if(void 0===a)throw new Error("Error: args is undefined!");if(b.Button.superclass.getready.call(this,a),this.values={buttonvalue:0},this.defaultSlot="buttonvalue",this.triggered=!1,this.mode=a.mode||"persistent",this.imagesArray=a.imagesArray,this.imagesArray.length<1)throw new Error("Invalid images array length, "+this.imagesArray.length);this.nButtons=this.imagesArray.length;for(var c=0;c=this.ROILeft&&b>=this.ROITop&&a<=this.ROILeft+this.ROIWidth&&b<=this.ROITop+this.ROIHeight?!0:!1},b.Button.prototype.touch=function(a,b){if(this.isInROI(a,b)){if(this.triggered=!0,"persistent"===this.mode)return void 0;if("immediate"===this.mode){var c=(this.values.buttonvalue+1)%this.nButtons;return{slot:"buttonvalue",value:c}}}return void 0},b.Button.prototype.release=function(a,b){var c=0,d={};if("persistent"===this.mode){if(this.triggered&&this.isInROI(a,b))return c=(this.values.buttonvalue+1)%this.nButtons,d={slot:"buttonvalue",value:c},this.triggered=!1,d}else if("immediate"===this.mode&&this.triggered)return c=(this.values.buttonvalue-1)%this.nButtons,d={slot:"buttonvalue",value:c},this.triggered=!1,d;return void 0},b.Button.prototype.mouseout=function(a,b){return"immediate"===this.mode?this.release(a,b):void 0},b.Button.prototype.setValue=function(a,c){0>c||c>this.nButtons||b.Button.superclass.setValue.call(this,a,c)},b.Button.prototype.refresh_CANVAS2D=function(a){this.isVisible===!0&&a.context.drawImage(this.imagesArray[this.values.buttonvalue],this.xOrigin,this.yOrigin)},b.Button.prototype.setStatesNumber=function(a){this.nButtons=a},b.Button.prototype.getStatesNumber=function(){return this.nButtons},b.Background=function(a){arguments.length&&this.getready(a)},b.extend(b.Background,b.UIElement),b.Background.prototype.getready=function(a){if("undefined"==typeof a)throw new Error("Error: args is undefined!");b.Background.superclass.getready.call(this,a),this.values={selected:[],held:[],doubletap:[],tap:[]},this.defaultSlot="selected",this.image=a.image,this.setWidth(this.image.width),this.setHeight(this.image.height)},b.Background.prototype.GetImage=function(){return this.image},b.Background.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop?athis.maxValue&&(d=this.maxValue),dthis.radius-this.thickness/2&&d=this.ROILeft&&b>=this.ROITop&&a<=this.ROILeft+this.ROIWidth&&b<=this.ROITop+this.ROIHeight?!0:!1},b.Grid.prototype.touch=function(a,b){return this.isInROI(a,b)&&(this.triggered=!0),void 0},b.Grid.prototype.release=function(a,b){return this.triggered&&this.isInROI(a,b)?(this.triggered=!1,{slot:"selected",value:[a,b]}):void 0},b.Grid.prototype.setValue=function(a,c){b.Grid.superclass.setValue.call(this,a,c)},b.Grid.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var b=a.context,c=Math.floor(this.height/this.rows),d=Math.floor(this.width/this.columns);b.fillStyle=this.bgColor,b.fillRect(this.xOrigin,this.yOrigin,this.width,this.height),b.beginPath(),b.lineWidth=this.lineWidth;for(var e=this.xOrigin+0;ee;e+=1)this.imagesArray[e].width>c&&(c=this.imagesArray[e].width),this.imagesArray[e].height>d&&(d=this.imagesArray[e].height)}this.setWidth(c),this.setHeight(d)},b.Knob.prototype.getImageNum=function(){return this.values.knobvalue<0||this.values.knobvalue>1?void 0:Math.round(this.values.knobvalue*(this.imageNum-1))},b.Knob.prototype.getImage=function(){var a=this.getImageNum();return this.imagesArray[a]},b.Knob.prototype.calculateAngle=function(a,c){var d=this.xOrigin+this.width/2,e=this.yOrigin+this.height/2;console.log("Point is: ",a,c,"Center is: ",d,e);var f=Math.atan2(a-d,c-e);console.log("radiant atan ",f),0>f&&(f+=2*Math.PI),console.log("radiant atan, normalized, is ",f);var g=f*(180/Math.PI);console.log("degree atan is",g),g=360-g,"undefined"!=typeof this.bottomAngularOffset&&(g=b.MathUtils.linearRange(0,360,-this.bottomAngularOffset,360+this.bottomAngularOffset,g),0>g&&(g=0),g>360&&(g=360));var h=b.MathUtils.linearRange(0,360,0,1,Math.floor(g));return console.log("value is",h),h},b.Knob.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&a1&&(f=1),0>f&&(f=0),c={slot:"knobvalue",value:f}}}else if("atan"===this.knobMethod&&void 0!==this.start_x&&void 0!==this.start_y){var g=this.calculateAngle(a,b);return c={slot:"knobvalue",value:g}}return void 0},b.Knob.prototype.setValue=function(a,c){0>c||c>1||b.Knob.superclass.setValue.call(this,a,c)},b.Knob.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0)if(this.imagesArray.length>1){var b=this.getImageNum();a.context.drawImage(this.imagesArray[b],this.xOrigin,this.yOrigin)}else if(1==this.imagesArray.length){var c=0,d=this.height*this.getImageNum();a.context.drawImage(this.imagesArray[0],c,d,this.width,this.height,this.xOrigin,this.yOrigin,this.width,this.height)}},b.Label=function(a){arguments.length&&this.getready(a)},b.extend(b.Label,b.UIElement),b.Label.prototype.getready=function(a){b.Label.superclass.getready.call(this,a),this.values={labelvalue:""},this.defaultSlot="labelvalue",this.textColor=a.textColor||"black",this.setWidth(a.width),this.setHeight(a.height)},b.Label.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&a1)return void 0;var a=360*this.values.knobvalue,b=360-(a*(this.startAngValue-this.stopAngValue)/360+this.stopAngValue)%360,c=(360-this.initAngValue+b)%360;return c*Math.PI/180},b.RotKnob.prototype.getRangedAmount=function(a){var c=this.stopAngValue-this.initAngValue,d=this.startAngValue-this.initAngValue;console.log("start -> end",d,c),a>this.initAngValue&&0>d&&(console.log("Angle now is",a),a=-(360-a));var e=b.MathUtils.linearRange(d,c,0,1,a);return console.log("knob value",e),0>e&&(e=0),e>1&&(e=1),e},b.RotKnob.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&ag&&(g=360+g);var h=(f-this.initAngValue)%360;return console.log("degreetan -> offset",f,g,h),this.getRangedAmount(Math.floor(g))},b.RotKnob.prototype.touch=function(a,b){var c=this.isInROI(a,b);if(c&&(this.start_x=a,this.start_y=b,"atan"===this.knobMethod)){var d=this.calculateAngle(a,b);return{slot:"knobvalue",value:d}}return void 0},b.RotKnob.prototype.release=function(){return this.start_x=null,this.start_y=null,void 0},b.RotKnob.prototype.drag=function(a,b){var c;if("updown"===this.knobMethod){if(null!==this.start_x&&null!==this.start_y){var d,e,f;return d=b-this.start_y,e=this.values.realknobvalue,f=e-d/this.sensitivity*this.moveDirection,f>1&&(f=1),0>f&&(f=0),c={slot:"knobvalue",value:f}}}else if("atan"===this.knobMethod&&this.isInROI(a,b)&&null!==this.start_x&&null!==this.start_y){var g=this.calculateAngle(a,b);return c={slot:"knobvalue",value:g}}return void 0},b.RotKnob.prototype.setValue=function(a,c){var d;if(!(0>c||c>1)){if(void 0===this.values[a])throw new Error("Slot "+a+" not present or value undefined");if(c!==this.values[a]&&c!==this.values["real"+a]){if(this.values["real"+a]=c,void 0!==this.angSteps){var e=1/this.angSteps;if(d=Math.floor(c/e)*e,d===this.values[a])return}else d=c;console.log("Value is: ",d),b.RotKnob.superclass.setValue.call(this,a,d)}}},b.RotKnob.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var c=this.getRotateAmount();b.CanvasUtils.drawRotate(a.context,{image:this.image,x:this.xOrigin,y:this.yOrigin,rot:c})}},b.Slider=function(a){arguments.length&&this.getready(a)},b.extend(b.Slider,b.UIElement),b.Slider.prototype.getready=function(a){if("undefined"==typeof a)throw"Slider error: args is undefined!";b.Slider.superclass.getready.call(this,a),this.values={slidervalue:0},this.defaultSlot="slidervalue",this.width=0,this.height=0,this.sliderImage=a.sliderImg,this.knobImage=a.knobImg,this.type=a.type,"horizontal"!==this.type&&"vertical"!==this.type&&(this.type="vertical"),this.calculateDimensions()},b.Slider.prototype.getKnobPosition=function(){var a;if(this.values.slidervalue<0||this.values.slidervalue>1)return void 0;switch(this.type){case"horizontal":a=Math.round(this.values.slidervalue*this.width+this.zeroLimit);break;case"vertical":a=Math.round(this.values.slidervalue*this.height+this.zeroLimit);break;default:throw new Error("Error: Slider orientation is undefined!")}return a},b.Slider.prototype.isInROI=function(a,b){switch(this.type){case"horizontal":if(a>this.getKnobPosition()&&b>this.ROITop&&athis.getKnobPosition()&&a>this.ROILeft&&b1&&(c=1),0>c&&(c=0),d={slot:"slidervalue",value:c}}return void 0},b.Slider.prototype.setValue=function(a,c){0>c||c>1||b.Slider.superclass.setValue.call(this,a,c)},b.Slider.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0)switch(a.context.drawImage(this.sliderImage,this.xOrigin,this.yOrigin),this.type){case"horizontal":a.context.drawImage(this.knobImage,this.getKnobPosition(),this.yOrigin);break;case"vertical":a.context.drawImage(this.knobImage,this.xOrigin,this.getKnobPosition());break;default:throw new Error("Error: Slider orientation unknown: ",this.type)}},b.Slider.prototype.calculateDimensions=function(){switch(this.kWidth=this.knobImage.width,this.kHeight=this.knobImage.height,this.setWidth(this.sliderImage.width),this.setHeight(this.sliderImage.height),this.type){case"horizontal":this.totalStride=this.width+this.kWidth,this.additionalEndSpace=Math.round(this.kWidth/2),this.zeroLimit=this.xOrigin-this.additionalEndSpace,this.oneLimit=this.xOrigin+this.width+this.additionalEndSpace;break;case"vertical":this.totalStride=this.height+this.kHeight,this.additionalEndSpace=Math.round(this.kHeight/2),this.zeroLimit=this.yOrigin-this.additionalEndSpace,this.oneLimit=this.yOrigin+this.height+this.additionalEndSpace;break;default:throw new Error("Error: Slider orientation is undefined!")}},b.Slider.prototype.setGraphicWrapper=function(a){b.Slider.superclass.setGraphicWrapper.call(this,a),this.drawClass=a.initObject([{objName:"drawImage",objParms:this.objParms}])},b.Wavebox=function(a){arguments.length&&this.getready(a)},b.extend(b.Wavebox,b.UIElement),b.Wavebox.prototype.getready=function(a){b.Wavebox.superclass.getready.call(this,a),this.values={waveboxposition:0,startsample:0,endsample:null,waveboxsignal:[],xPos:0,yPos:0},this.defaultSlot="waveboxposition",this.setWidth(a.width),this.setHeight(a.height),this.binMethod=a.binMethod||"minmax",this.orientation=a.orientation||0,this.waveColor=a.waveColor||"black"},b.Wavebox.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&ab)throw new Error("Error: Trying to set "+a+" less than 0: "+b);if("undefined"!=typeof this.values.waveboxsignal&&b>this.values.waveboxsignal.length)throw new Error("Error: Trying to set "+a+" bigger than signal length: "+b+" > "+this.values.waveboxsignal.length)}if("startsample"===a&&b>this.values.endsample)throw new Error("Error: Trying to set startsample > endsample: "+b+" > "+this.values.endsample);if("endsample"===a&&bj;j+=1)f=i(j,e,this.values),0===this.orientation?(c=h-(f.max+1)*h/2+this.yOrigin,d=j+this.xOrigin):1===this.orientation&&(c=j+this.yOrigin,d=h-(f.max+1)*h/2+this.xOrigin),b.lineTo(d,c);for(0===this.orientation?b.lineTo(g+this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.lineTo(.5*h+this.xOrigin,g+this.yOrigin),b.fill(),b.closePath(),b.beginPath(),0===this.orientation?b.moveTo(this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.moveTo(this.xOrigin+.5*h,this.yOrigin),j=0;g>j;j+=1)f=i(j,e,this.values),0===this.orientation&&(c=h-(f.min+1)*h/2+this.yOrigin,d=j+this.xOrigin),1===this.orientation&&(c=j+this.yOrigin,d=h-(f.min+1)*h/2+this.xOrigin),b.lineTo(d,c);0===this.orientation?b.lineTo(g+this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.lineTo(.5*h+this.xOrigin,g+this.yOrigin),b.fill(),b.closePath()}},b.Wavebox.prototype.calculateBinMix=function(a,b,c){var d=c.waveboxsignal,e=c.startsample+a*b,f=c.startsample+(a+1)*b;f>c.endsample&&(f=c.endsample);for(var g=d[e],h=d[e],i=1;b>i;i++)d[e+i]h&&(h=d[e+i]);return{max:h,min:g}},b.Wavebox.prototype.calculateBinNone=function(a,b,c){var d=c.startsample+a*b,e=parseInt(b/2,10),f=c.waveboxsignal[d+e];return{max:f,min:-f}},b.Wavebox.prototype.calculateBinAvg=function(a,b){var c=this.values.waveboxsignal,d=this.values.startsample+a*b,e=d+(a+1)*b;e>this.values.endsample&&(e=this.values.endsample);for(var f=c.subarray(d,e),g=0,h=f.length,i=0;h-1>i;i++)g=(f[i+1]+i*g)/(i+1);return g},b.ENGINE={},b.ENGINE.engineFactory=function(a,b){function c(a){this.reset=function(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},this.canvas=a,this.context=a.getContext("2d"),this.type="CANVAS2D",this.getContext=function(){return this.context},this.getCanvas=function(){return this.canvas}}switch(a){case"CANVAS2D":if(void 0!==b.target)return new c(b.target);throw"Engine: args is undefined";case"ANOTHERTYPE":throw"Engine type not recognized: "+a;default:throw"Engine type not recognized: "+a}};var c=window.CanvasRenderingContext2D&&CanvasRenderingContext2D.prototype;return c.lineTo&&(c.dashedLine=function(a,b,c,d,e){e||(e=[10,5]),this.save();var f=c-a,g=d-b,h=Math.sqrt(f*f+g*g),i=Math.atan2(g,f);this.translate(a,b),this.moveTo(0,0),this.rotate(i);var j=e.length,k=0,l=!0;for(a=0;h>a;)a+=e[k++%j],a>h&&(a=h),l?this.lineTo(a,0):this.moveTo(a,0),l=!l;this.restore()}),b.OSC={},b.OSC.Message=function(a){this.address=a,this.typetags="",this.args=[];for(var c=1;c"+a+"s",b,0,[this.value])}},b.OSC.TInt=function(a){this.value=a},b.OSC.TInt.prototype={typetag:"i",decode:function(a){if(a.length<4)throw new ShortBuffer("int",a,4);return this.value=Struct.Unpack(">i",a.slice(0,4))[0],a.slice(4)},encode:function(){var a=new Array(4);return Struct.PackTo(">i",a,0,[this.value])}},b.OSC.TTime=function(a){this.value=a},b.OSC.TTime.prototype={typetag:"t",decode:function(a){if(a.length<8)throw new ShortBuffer("time",a,8);return this.value=Struct.Unpack(">LL",a.slice(0,8))[0],a.slice(8)},encode:function(a,b){return Struct.PackTo(">LL",a,b,this.value)}},b.OSC.TFloat=function(a){this.value=a},b.OSC.TFloat.prototype={typetag:"f",decode:function(a){if(a.length<4)throw new ShortBuffer("float",a,4);return this.value=Struct.Unpack(">f",a.slice(0,4))[0],a.slice(4)},encode:function(){var a=new Array(4);return Struct.PackTo(">f",a,0,[this.value])}},b.OSC.TBlob=function(a){this.value=a},b.OSC.TBlob.prototype={typetag:"b",decode:function(a){var b=Struct.Unpack(">i",a.slice(0,4))[0],c=parseInt(4*Math.ceil(b/4),10)+4;return this.value=a.slice(4,b+4),a.slice(c)},encode:function(a,b){var c=4*Math.ceil(this.value.length/4,10);return Struct.PackTo(">i"+c+"s",a,b,[c,this.value])}},b.OSC.TDouble=function(a){this.value=a},b.OSC.TDouble.prototype={typetag:"d",decode:function(a){if(a.length<8)throw new ShortBuffer("double",a,8);return this.value=Struct.Unpack(">d",a.slice(0,8))[0],a.slice(8)},encode:function(a,b){return Struct.PackTo(">d",a,b,[this.value])}},b.OSC.tagToConstructor={i:function(){return new b.OSC.TInt},f:function(){return new b.OSC.TFloat},s:function(){return new b.OSC.TString},b:function(){return new b.OSC.TBlob},d:function(){return new b.OSC.TDouble}},b.OSC.decodeBundle=function(a){var c=[],d={time:null,args:[]},e=new b.OSC.TTime;for(a=e.decode(a),d.time=e.value;a.length>0;){var f=new b.OSC.TInt;a=f.decode(a);var g=b.OSC.decode(a.slice(0,f.value));d.args.push(g),a=a.slice(f.value)}return c.push(d),c},b.OSC.decode=function(a){var c=[],d=new b.OSC.TString;if(a=d.decode(a),c.push(d.value),"#bundle"===d.value)return b.OSC.decodeBundle(a);if(a.length>0){var e=new b.OSC.TString;if(a=e.decode(a),e=e.value,","!=e[0])throw"invalid type tag in incoming OSC message, must start with comma";for(var f=1;fd;++d)c[d]=b.GenericUtils.clone(a[d]);return c}if(a instanceof Object){c={};for(var f in a)a.hasOwnProperty(f)&&(c[f]=b.GenericUtils.clone(a[f]));return c}throw new Error("Unable to copy obj! Its type isn't supported.")},b.MathUtils={},b.MathUtils.linearRange=function(a,b,c,d,e){var f=(e-a)*(d-c)/(b-a)+c;return f},b.MathUtils.distance=function(a,b,c,d){return Math.sqrt(Math.pow(a-c,2)+Math.pow(b-d,2))},b.MathUtils.fact_table=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3,0x1b02b9306890000,243290200817664e4,5109094217170944e4,0x3ceea4c2b3e0d80000,2.585201673888498e22,6.204484017332394e23,1.5511210043330986e25,4.0329146112660565e26,1.0888869450418352e28,3.0488834461171387e29,8.841761993739702e30,2.6525285981219107e32,8.222838654177922e33,2.631308369336935e35,8.683317618811886e36,2.9523279903960416e38,1.0333147966386145e40,3.7199332678990125e41,1.3763753091226346e43,5.230226174666011e44,2.0397882081197444e46,8.159152832478977e47,3.345252661316381e49,1.40500611775288e51,6.041526306337383e52,2.658271574788449e54,1.1962222086548019e56,5.502622159812089e57,2.5862324151116818e59,1.2413915592536073e61,6.082818640342675e62,3.0414093201713376e64,1.5511187532873822e66,8.065817517094388e67,4.2748832840600255e69,2.308436973392414e71,1.2696403353658276e73,7.109985878048635e74,4.0526919504877214e76,2.3505613312828785e78,1.3868311854568984e80,8.32098711274139e81,5.075802138772248e83,3.146997326038794e85,1.98260831540444e87,1.2688693218588417e89,8.247650592082472e90,5.443449390774431e92,3.647111091818868e94,2.4800355424368305e96,1.711224524281413e98,1.1978571669969892e100,8.504785885678623e101,6.1234458376886085e103,4.4701154615126844e105,3.307885441519386e107,2.48091408113954e109,1.8854947016660504e111,1.4518309202828587e113,1.1324281178206297e115,8.946182130782976e116,7.156945704626381e118,5.797126020747368e120,4.753643337012842e122,3.945523969720659e124,3.314240134565353e126,2.81710411438055e128,2.4227095383672734e130,2.107757298379528e132,1.8548264225739844e134,1.650795516090846e136,1.4857159644817615e138,1.352001527678403e140,1.2438414054641308e142,1.1567725070816416e144,1.087366156656743e146,1.032997848823906e148,9.916779348709496e149,9.619275968248212e151,9.426890448883248e153,9.332621544394415e155,9.332621544394415e157],b.MathUtils.fact_lookup=function(a){if(100>=(a>0))return b.MathUtils.fact_table[a]; -for(var c=1,d=2;a>=d;d++)c*=d;return c},b.CanvasUtils={},b.CanvasUtils.drawRotate=function(a,b){a.save(),a.translate(b.x+b.image.width/2,b.y+b.image.height/2),a.rotate(b.rot),a.translate(-(b.image.width/2)-b.x,-(b.image.height/2)-b.y),a.drawImage(b.image,b.x,b.y),a.restore()},b}); \ No newline at end of file +/*! kievII v0.6.0 built on 25-09-2013 */ +!function(a){"function"==typeof define&&define.amd?define(["hammer"],a):window.K2=window.KievII=a(window.Hammer)}(function(a){var b={};b.extend=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a,a.superclass=b.prototype,b.prototype.constructor==Object.prototype.constructor&&(b.prototype.constructor=b)},b.clone=function(a){var b;if(null===a||"object"!=typeof a)return a;if(a instanceof Date)return b=new Date,b.setTime(a.getTime()),b;if(a instanceof Array){b=[];for(var c=0,d=a.length;d>c;++c)b[c]=clone(a[c]);return b}if(a instanceof Object){b={};for(var e in a)a.hasOwnProperty(e)&&(b[e]=clone(a[e]));return b}throw new Error("Unable to copy obj! Its type isn't supported.")},b.mergeObject=function(a,b){var c={};if(!b)return a;for(var d in a)c[d]=d in b?b[d]:a[d];return c},b.UIElement=function(a){arguments.length&&this.getready(a)},b.UIElement.prototype.getready=function(a){if(this.ID=a.ID,this.isListening=a.isListening,"undefined"==typeof this.isListening&&(this.isListening=!0),"boolean"!=typeof this.isListening)throw"Property isListening for element "+this.ID+" is not boolean "+this.isListening;if(this.isVisible=a.isVisible,"undefined"==typeof this.isVisible&&(this.isVisible=!0),"boolean"!=typeof this.isVisible)throw"Property isVisible for element "+this.ID+" is not boolean "+this.isVisible;this.xOrigin=a.left,this.yOrigin=a.top,this.ROILeft="undefined"!=typeof a.ROILeft?a.ROILeft:this.xOrigin,this.ROITop="undefined"!=typeof a.ROITop?a.ROITop:this.yOrigin,this.ROIWidth=a.ROIWidth,this.ROIHeight=a.ROIHeight,this.values={},this.transparency=a.transparency||1,this.objParms=a.objParms,"undefined"!=typeof a&&(this.onValueSet=a.onValueSet)},b.UIElement.prototype.isInROI=function(){return!1},b.UIElement.prototype.getValues=function(){var a,b=[];for(a in this.values)this.values.hasOwnProperty(a)&&b.push(a);return b},b.UIElement.prototype.getXCoord=function(){return this.xOrigin},b.UIElement.prototype.getYCoord=function(){return this.yOrigin},b.UIElement.prototype.getWidth=function(){return this.width},b.UIElement.prototype.getHeight=function(){return this.height},b.UIElement.prototype.setHeight=function(a){this.height=a,"undefined"==typeof this.ROIHeight&&(this.ROIHeight=a)},b.UIElement.prototype.setWidth=function(a){this.width=a,"undefined"==typeof this.ROIWidth&&(this.ROIWidth=a)},b.UIElement.prototype.getValue=function(a){if("undefined"==typeof this.values[a])throw new Error("Slot "+a+" not present or value undefined");return this.values[a]},b.UIElement.prototype.setValue=function(a,b){if("undefined"==typeof this.values[a])throw new Error("Slot "+a+" not present or value undefined");b!==this.values[a]&&(this.values[a]=b)},b.UIElement.prototype.setListening=function(a){if("boolean"!=typeof a)throw"Property isListening for element "+this.ID+" is not boolean "+a;this.isListening=a},b.UIElement.prototype.getListening=function(){return this.isListening},b.UIElement.prototype.refresh=function(a){var b="call_"+a.type;if("function"!=typeof this[b])throw"Element "+this.ID+" "+b+" is not a function. Its type is "+typeof this[b];this[b](a)},b.UIElement.prototype.call_CANVAS2D=function(a){var b="refresh_"+a.type;if(a.context.save(),a.context.globalAlpha=this.transparency,"function"!=typeof this[b])throw"Element "+this.ID+" "+b+" is not a function. Its type is "+typeof this[b];this[b](a),a.context.restore()},b.UIElement.prototype.getID=function(){return this.ID},b.UIElement.prototype.setDrawClass=function(a){this.drawClass=a},b.UIElement.prototype.setVisible=function(a){if("boolean"!=typeof a)throw"Property isVisible for element "+this.ID+" is not boolean "+a;this.isVisible=a},b.UIElement.prototype.getVisible=function(){return this.isVisible},b.UIElement.prototype.setGraphicWrapper=function(a){this.wrapper=a},b.UI=function(c,d){this.getEventPosition=function(a,b){var c,d,e=parseInt(document.defaultView.getComputedStyle(b,null).paddingLeft,10)||0,f=parseInt(document.defaultView.getComputedStyle(b,null).paddingTop,10)||0,g=parseInt(document.defaultView.getComputedStyle(b,null).borderLeftWidth,10)||0,h=parseInt(document.defaultView.getComputedStyle(b,null).borderTopWidth,10)||0,i=document.body.parentNode,j=i.offsetTop,k=i.offsetLeft,l=b,m=0,n=0;if("undefined"!=typeof l.offsetParent)do m+=l.offsetLeft,n+=l.offsetTop;while(l=l.offsetParent);m+=e+g+k,n+=f+h+j,c=a.pageX-m,d=a.pageY-n;var o=parseInt(document.defaultView.getComputedStyle(b,null).getPropertyValue("width"),10)||0,p=parseInt(document.defaultView.getComputedStyle(b,null).getPropertyValue("height"),10)||0,q=b.getAttribute("width"),r=b.getAttribute("height"),s=q/o,t=r/p;return c*=s,d*=t,{x:c,y:d}},this.onMouseEvent=function(){var a=this;return function(b){var c=b.type,d=a.getEventPosition(b,a.domElement);a.elementsNotifyEvent(d.x,d.y,c)}},this.onHammerEvent=function(){var a=this;return function(b){var c=b.gesture.srcEvent,d=b.type,e=a.getEventPosition(c,a.domElement,b);a.elementsNotifyEvent(e.x,e.y,d)}},this.elementsNotifyEvent=function(a,b,c){for(var d=this.zMax;d>=this.zMin;d-=1)if("undefined"!=typeof this.zArray[d])for(var e=this.zArray[d].length-1;e>=0;e-=1)if(this.zArray[d][e].getListening()&&"function"==typeof this.zArray[d][e][c]){var f=this.zArray[d][e][c](a,b);if("undefined"!=typeof f){if(f instanceof Array)for(var g=0;gc||"number"!=typeof c)throw new Error("zIndex "+c+" invalid");this.elements[a.ID]={element:a,zIndex:c},"undefined"==typeof this.zArray[c]&&(this.zArray[c]=[]),this.zArray[c].push(this.elements[a.ID].element),("undefined"==typeof this.zMin||this.zMin>c)&&(this.zMin=c),("undefined"==typeof this.zMax||this.zMaxb)&&(this.zMin=b),("undefined"==typeof this.zMax||this.zMaxm)throw new Error("Recursion exceeded");if(l[n].element===f&&l[n].slot===h)return}}if(this.elements[f].element.setValue(h,g),"function"==typeof this.elements[f].element.onValueSet&&i!==!1&&this.elements[f].element.onValueSet(h,this.elements[f].element.values[h],f),l.push({element:f,slot:h}),"undefined"!=typeof this.connections[f]&&"undefined"!=typeof this.connections[f][h])for(e in this.connections[f][h])if(this.connections[f][h].hasOwnProperty(e)){if(b=this.connections[f][h][e],c=b.recvElement,d=b.recvSlot,"function"==typeof b.callback){var o={sender:f,sendSlot:h,recv:c,recvSlot:d,ui:this};k=b.callback(g,o)}var p;p=b.cascade!==!1,this.setValue({elementID:c,slot:d,value:k,history:l,fireCallback:p})}},this.hideElement=function(a){var b;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");b=this.elements[a].element.getVisible(),b===!0&&(this.elements[a].element.setVisible(!1),this.elements[a].element.setListening(!1))},this.unhideElement=function(a){var b;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");b=this.elements[a].element.getVisible(),b===!1&&(this.elements[a].element.setVisible(!0),this.elements[a].element.setListening(!0))},this.setHidden=function(a,b){this.setVisible(a,!b)},this.setVisible=function(a,b){var c;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");c=this.elements[a].element.getVisible(),c!==b&&(this.elements[a].element.setVisible(b),this.elements[a].element.setListening(b))},this.setListening=function(a,b){var c;if("undefined"==typeof this.elements[a])throw new Error("Element "+a+" not present.");c=this.elements[a].element.getListening(),c!==b&&this.elements[a].element.setListening(b)},this.refreshZ=function(a){for(var b=a,c=this.zArray.length;c>b;b+=1)if("object"==typeof this.zArray[b])for(var d=0,e=this.zArray[b].length;e>d;d+=1)this.zArray[b][d].getVisible()===!0&&this.zArray[b][d].refresh(this.engine)},this.refresh=function(a){a!==!1&&this.reset(),"undefined"!=typeof this.zMin&&this.refreshZ(this.zMin)},this.reset=function(){this.engine.reset()}},b.Area=function(a){arguments.length&&this.getready(a)},b.extend(b.Area,b.UIElement),b.Area.prototype.getready=function(a){b.Area.superclass.getready.call(this,a),this.values={width:0,height:0,selected:[],xOffset:0,yOffset:0,doubletap:[],held:[]},this.defaultSlot="height",this.color=a.color||"black",this.borderColor=a.borderColor||"green",this.proximity=Math.floor(a.proximity)||10,this.thickness=Math.floor(a.thickness)||this.proximity,0===a.thickness&&(this.thickness=0),this.borders=a.borders||{top:!0,bottom:!0,right:!0,left:!0},this.dragBorders=a.dragBorders||{top:!0,bottom:!0,right:!0,left:!0},this.move=a.move||"all",this.xMonotone=a.xMonotone||!1,this.yMonotone=a.yMonotone||!1;var c=a.height||0,d=a.width||0;this.values.width=d,this.values.height=c;var e=a.left||0,f=a.top||0;this.values.xOffset=e,this.values.yOffset=f},b.Area.prototype.isInArea=function(a,b){var c=!1,d=!1;return this.values.width>0?a>this.values.xOffset&&athis.values.xOffset+this.values.width&&(c=!0),this.values.height>0?b>this.values.yOffset&&bthis.values.height+this.values.yOffset&&(d=!0),c&&d},b.Area.prototype.tap=b.Area.prototype.dragstart=function(a,b){var c=this.values.xOffset-this.proximity,d=this.values.xOffset+this.proximity,e=this.values.xOffset+this.values.width-this.proximity,f=this.values.xOffset+this.values.width+this.proximity,g=this.values.height+this.values.yOffset+this.proximity,h=this.values.height+this.values.yOffset-this.proximity,i=this.values.yOffset+this.proximity,j=this.values.yOffset-this.proximity;a>c&&d>a&&this.dragBorders.left===!0&&(this.leftSide=!0),a>e&&f>a&&this.dragBorders.right===!0&&(this.rightSide=!0),b>h&&g>b&&this.dragBorders.bottom===!0&&(this.bottomSide=!0),b>j&&i>b&&this.dragBorders.top===!0&&(this.topSide=!0),this.isInArea(a,b)?(this.inside=!0,this.startPoint=[a,b]):this.inside=!1},b.Area.prototype.drag=function(a,b){var c,d,e=[];if(this.leftSide&&this.borders.left){c=this.values.width-(a-this.values.xOffset);var f=a;this.xMonotone&&0>c&&(c=0,f=this.values.xOffset),e.push({slot:"width",value:c}),e.push({slot:"xOffset",value:f})}if(this.rightSide&&this.borders.right&&!this.leftSide&&(c=a-this.values.xOffset,this.xMonotone&&0>c&&(c=0),e.push({slot:"width",value:c})),this.bottomSide&&this.borders.bottom&&(d=this.values.height+(b-(this.values.yOffset+this.values.height)),this.yMonotone&&0>d&&(d=0),e.push({slot:"height",value:d})),this.topSide&&this.borders.top&&!this.bottomSide){d=this.values.height+(this.values.yOffset-b);var g=b;this.yMonotone&&0>d&&(d=0,g=this.values.yOffset),e.push({slot:"yOffset",value:g}),e.push({slot:"height",value:d})}if(e.length>0)return e;if(this.inside&&"none"!==this.move){var h=a-this.startPoint[0],i=b-this.startPoint[1];if(this.startPoint=[a,b],"all"===this.move)return[{slot:"xOffset",value:this.values.xOffset+h},{slot:"yOffset",value:this.values.yOffset+i}];if("x"===this.move)return{slot:"xOffset",value:this.values.xOffset+h};if("y"===this.move)return{slot:"yOffset",value:this.values.yOffset+i}}return void 0},b.Area.prototype.dragend=function(a,b){var c;return this.leftSide=this.rightSide=this.bottomSide=this.topSide=!1,this.inside&&this.isInArea(a,b)&&(c={slot:"selected",value:[a,b]}),this.inside=!1,c},b.Area.prototype.hold=function(a,b){return this.isInArea(a,b)?{slot:"held",value:[a,b]}:void 0},b.Area.prototype.doubletap=function(a,b){return this.isInArea(a,b)?{slot:"doubletap",value:[a,b]}:void 0},b.Area.prototype.setValue=function(a,c){b.Area.superclass.setValue.call(this,a,c)},b.Area.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){a.context.fillStyle=this.color,a.context.strokeStyle=this.borderColor,a.context.lineWidth=this.thickness;var b=Math.floor(this.thickness/2);a.context.fillRect(this.xOrigin+this.values.xOffset+b,this.values.yOffset+b,this.values.width-2*b,this.values.height-2*b),this.thickness>0&&a.context.strokeRect(this.xOrigin+this.values.xOffset,this.values.yOffset,this.values.width,this.values.height)}},b.Area.prototype.getXCoord=function(){return this.values.xOrigin},b.Area.prototype.getYCoord=function(){return this.values.yOrigin},b.Area.prototype.getWidth=function(){return this.values.width},b.Area.prototype.getHeight=function(){return this.values.height},b.Area.prototype.setHeight=function(a){this.values.height=a,"undefined"==typeof this.ROIHeight&&(this.ROIHeight=a)},b.Area.prototype.setWidth=function(a){this.values.width=a,"undefined"==typeof this.ROIWidth&&(this.ROIWidth=a)},b.Curve=function(a){arguments.length&&this.getready(a)},b.extend(b.Curve,b.UIElement),b.Curve.prototype.getready=function(a){switch(b.Curve.superclass.getready.call(this,a),this.values={points:[],selected:[],held:[],doubletap_c:[],doubletap_h:[]},this.defaultSlot="points",this.setWidth(a.width),this.setHeight(a.height),this.curveType=a.curveType||"bezier",this.thickness=a.thickness||2,this.curveColor=a.curveColor||"black",this.helperColor=a.helperColor||"#CCCCCC",this.handleColor=a.handleColor||"red",this.curveLabels="boolean"==typeof a.curveLabels?a.curveLabels:!1,this.terminalPointStyle=a.terminalPointStyle||"rect",this.paintTerminalPoints=a.paintTerminalPoints||"all",this.midPointStyle=a.midPointStyle||"circle",this.terminalPointSize=a.terminalPointSize||16,this.midPointSize=a.midPointSize||8,this.terminalPointColor=a.terminalPointColor||this.handleColor,this.midPointColor=a.midPointColor||this.handleColor,this.terminalPointFill=a.terminalPointFill||null,this.midPointFill=a.midPointFill||null,this.xMonotone=a.xMonotone||!1,this.handleSize=a.handleSize||this.terminalPointSize>this.midPointSize?this.terminalPointSize:this.midPointSize,this.handleClicked=null,this.supportPoints=[],this.selectStart=!1,this.whereHappened=[],a.curveType){case"bezier":if(0!==a.points.length%2||a.points.length<4)throw"Incorrect number of points "+a.points.length;break;case"halfcosine":case"smooth":case"linear":if(4!==a.points.length)throw"Incorrect number of points "+a.points.length;break;default:throw"Unknown curve type "+a.curveType}for(var c=[],d=0;dthis.supportPoints[c][0]-this.thickness&&athis.supportPoints[c][1]-this.thickness&&bc[d][0]-this.handleSize&&ac[d][1]-this.handleSize&&bthis.ROILeft&&b>this.ROITop&&aa[a.length-1][0]&&(a[0][0]>this.values.points[0][0]?a[0][0]=a[a.length-1][0]:a[a.length-1][0]=a[0][0])},b.Curve.prototype.drag=function(a,c){var d,e={};return null!==this.handleClicked?(d=b.GenericUtils.clone(this.values.points),this.isInROI(a,c)?(this.triggered=!1,d[this.handleClicked][0]=a,d[this.handleClicked][1]=c):(d[this.handleClicked][0]=a,d[this.handleClicked][1]=c,a>this.ROILeft+this.ROIWidth&&(d[this.handleClicked][0]=this.ROILeft+this.ROIWidth),athis.ROITop+this.ROIHeight&&(d[this.handleClicked][1]=this.ROITop+this.ROIHeight),ca&&0>b)){var c=this.drag(a,b);return this.handleClicked=null,c}},b.Curve.prototype.release=function(a,b){return this.handleClicked=null,this.selectStart===!0&&this.isInCurve(a,b)?(this.selectStart=!1,{slot:"selected",value:[a,b]}):void 0},b.Curve.prototype.hold=function(a,b){if(this.isInROI(a,b)&&this.isInCurve(a,b)){var c={slot:"held",value:[a,b]};return c}return void 0},b.Curve.prototype.doubletap=function(a,b){if(this.isInROI(a,b)){var c;if(null!==(c=this.isInHandle(a,b)))return{slot:"doubletap_h",value:[[a,b],c]};if(this.isInCurve(a,b))return{slot:"doubletap_c",value:[a,b]}}return void 0},b.Curve.prototype.setValue=function(a,c){var d=!0;if("points"===a)for(var e=this.values[a],f=0;f=d;d+=b){var e=this[this.curveType].P(d,this.values.points);c.push(e)}return c},b.Curve.prototype.getCurveYPoints=function(a,b){"undefined"==typeof b&&(b=1);for(var c=1/a,d=[],e=0;1>=e;e+=c){var f=this[this.curveType].P(e,this.values.points)[1]*b;d.push(f)}return d},b.Curve.prototype.getPoint=function(a){return this.supportPoints[a]},b.Curve.prototype.getnumPoints=function(){return this.supportPoints.length},b.Curve.prototype.halfcosine={P:function(a,b){var c=(1-Math.cos(a*Math.PI))/2,d=[0,0];return d[0]=b[0][0]+(b[1][0]-b[0][0])*a,d[1]=b[0][1]*(1-c)+b[1][1]*c,d}},b.Curve.prototype.smooth={P:function(a,b){var c=a*a*(3-2*a),d=[0,0];return d[0]=b[0][0]+(b[1][0]-b[0][0])*a,d[1]=b[0][1]+c*(b[1][1]-b[0][1]),d}},b.Curve.prototype.linear={P:function(a,b){var c=[0,0];return c[0]=b[0][0]+(b[1][0]-b[0][0])*a,c[1]=b[0][1]*(1-a)+b[1][1]*a,c}},b.Curve.prototype.cubic={P:function(a,b){var c=[0,0];c[0]=b[0][0]+(b[3][0]-b[0][0])*a;var d=a,e=a*a,f=b[3][1]-b[2][1]-b[0][1]+b[1][1],g=b[0][1]-b[1][1]-f,h=b[2][1]-b[0][1],i=b[1][1];return c[1]=f*d*e+g*e+h*d+i,c}},b.Curve.prototype.catmull={P:function(a,b){var c=[0,0];c[0]=b[0][0]+(b[3][0]-b[0][0])*a;var d=a,e=a*a,f=b[0][1],g=b[1][1],h=b[2][1],i=b[3][1],j=-.5*f+1.5*g-1.5*h+.5*i,k=f-2.5*g+2*h-.5*i,l=-.5*f+.5*h,m=g;return c[1]=j*d*e+k*e+l*d+m,c}},b.Curve.prototype.hermite={P:function(a,b,c,d){var e=[0,0];e[0]=b[0][0]+(b[3][0]-b[0][0])*a;var f,g,h,i,j,k,l,m,n=d||0,o=c||0,p=a,q=b[0][1],r=b[1][1],s=b[2][1],t=b[3][1];return h=p*p,i=h*p,f=(r-q)*(1+n)*(1-o)/2,f+=(s-r)*(1-n)*(1-o)/2,g=(s-r)*(1+n)*(1-o)/2,g+=(t-s)*(1-n)*(1-o)/2,j=2*i-3*h+1,k=i-2*h+p,l=i-h,m=-2*i+3*h,e[1]=j*r+k*f+l*g+m*s,e}},b.Curve.prototype.bezier={P:function(a,b){function c(a,b,c){var e=d;return"function"==typeof fact_lookup&&(e=fact_lookup),e(b)/(e(a)*e(b-a))*Math.pow(c,a)*Math.pow(1-c,b-a)}for(var d=function(a){for(var b=1,c=2;a>=c;c++)b*=c;return b},e=[0,0],f=b.length-1,g=0;f>=g;g++)e[0]+=b[g][0]*c(g,f,a),e[1]+=b[g][1]*c(g,f,a);return e}},b.Curve.prototype.genericCurve=function(a,b){function c(a,b){return Math.sqrt(Math.pow(a[0]-b[0],2)+Math.pow(a[1]-b[1],2))}function d(a){for(var b=0,d=0;d=f;f+=c){var g=b.P(f,a);e.push(g)}return e}this.supportPoints=e(a,this[b])},b.Curve.prototype.paintHandle=function(a,b,c){c===!0?this.paintPoint(a,b,this.terminalPointStyle,this.terminalPointFill,this.terminalPointColor,this.terminalPointSize):this.paintPoint(a,b,this.midPointStyle,this.midPointFill,this.midPointColor,this.midPointSize)},b.Curve.prototype.paintPoint=function(a,b,c,d,e,f){if("rect"===c)a.save(),a.strokeStyle=e,a.lineWidth=Math.round(f/5),a.strokeRect(b[0]-Math.round(f/2),b[1]-Math.round(f/2),f,f),null!==d&&(a.fillStyle=d,a.fillRect(b[0]-Math.ceil(f/2)+Math.floor(a.lineWidth/2),b[1]-Math.ceil(f/2)+Math.floor(a.lineWidth/2),f-a.lineWidth+1,f-a.lineWidth+1)),a.restore();else if("circle"===c)a.save(),a.beginPath(),a.strokeStyle=e,a.lineWidth=Math.round(f/5),a.arc(b[0],b[1],f,0,2*Math.PI,!1),null!==d&&(a.fillStyle=d,a.fill()),a.stroke(),a.restore();else if("none"!==c)throw"Unknown handle style: "+c},b.Curve.prototype.paintPoints=function(a){var b,c=this.values.points;for(a.save(),a.strokeStyle=this.helperColor,a.beginPath(),a.moveTo(c[0][0],c[0][1]),b=1;bthis.ROILeft&&b>this.ROITop&&athis.ROILeft&&athis.ROITop&&athis.width&&(c[0]=this.width),c[0]<0&&(c[0]=0)}else if(1===this.orientation){if(!this.isInROIY(a))return void 0;c=[d[0],b-this.yOrigin],c[1]>this.height&&(c[1]=this.height),c[1]<0&&(c[1]=0)}return c},b.Bar.prototype.touch=function(a,b){if(this.isInROI(a,b)){this.started=!0;var c=this.commonDrag(a,b);if("undefined"!=typeof c)return{slot:"barPos",value:c}}return void 0},b.Bar.prototype.drag=function(a,b){if(this.started){var c=this.commonDrag(a,b);if("undefined"!=typeof c)return{slot:"barPos",value:c}}return void 0},b.Bar.prototype.dragend=b.Bar.prototype.swipe=function(a,b){if(this.started){this.started=!1;var c=this.commonDrag(a,b);if("undefined"!=typeof c)return[{slot:"barPos",value:c},{slot:"dragEnd",value:[a-this.xOrigin,b-this.yOrigin]}]}return void 0},b.Bar.prototype.dragstart=function(a,b){return this.isInROI(a,b)?{slot:"dragStart",value:[a-this.xOrigin,b-this.yOrigin]}:void 0},b.Bar.prototype.setValue=function(a,b){"barPos"==a?(b[0]<=this.width&&(this.values.barPos[0]=b[0]),b[1]<=this.height&&(this.values.barPos[1]=b[1])):this.values[a]=b},b.Bar.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var b=a.context;if(b.lineWidth=this.thickness,b.strokeStyle=this.barColor,b.beginPath(),0===this.orientation){var c=this.xOrigin+this.values.barPos[0];b.moveTo(c,this.yOrigin+this.height),b.lineTo(c,this.yOrigin)}else 1===this.orientation&&(b.moveTo(this.xOrigin+this.width,this.yOrigin+this.values.barPos[1]),b.lineTo(this.xOrigin,this.yOrigin+this.values.barPos[1]));b.stroke(),b.closePath()}},b.Button=function(a){arguments.length&&this.getready(a)},b.extend(b.Button,b.UIElement),b.Button.prototype.getready=function(a){if(void 0===a)throw new Error("Error: args is undefined!");if(b.Button.superclass.getready.call(this,a),this.values={buttonvalue:0},this.defaultSlot="buttonvalue",this.triggered=!1,this.mode=a.mode||"persistent",this.imagesArray=a.imagesArray,this.imagesArray.length<1)throw new Error("Invalid images array length, "+this.imagesArray.length);this.nButtons=this.imagesArray.length;for(var c=0;c=this.ROILeft&&b>=this.ROITop&&a<=this.ROILeft+this.ROIWidth&&b<=this.ROITop+this.ROIHeight?!0:!1},b.Button.prototype.touch=function(a,b){if(this.isInROI(a,b)){if(this.triggered=!0,"persistent"===this.mode)return void 0;if("immediate"===this.mode){var c=(this.values.buttonvalue+1)%this.nButtons;return{slot:"buttonvalue",value:c}}}return void 0},b.Button.prototype.release=function(a,b){var c=0,d={};if("persistent"===this.mode){if(this.triggered&&this.isInROI(a,b))return c=(this.values.buttonvalue+1)%this.nButtons,d={slot:"buttonvalue",value:c},this.triggered=!1,d}else if("immediate"===this.mode&&this.triggered)return c=(this.values.buttonvalue-1)%this.nButtons,d={slot:"buttonvalue",value:c},this.triggered=!1,d;return void 0},b.Button.prototype.mouseout=function(a,b){return"immediate"===this.mode?this.release(a,b):void 0},b.Button.prototype.setValue=function(a,c){0>c||c>this.nButtons||b.Button.superclass.setValue.call(this,a,c)},b.Button.prototype.refresh_CANVAS2D=function(a){this.isVisible===!0&&a.context.drawImage(this.imagesArray[this.values.buttonvalue],this.xOrigin,this.yOrigin)},b.Button.prototype.setStatesNumber=function(a){this.nButtons=a},b.Button.prototype.getStatesNumber=function(){return this.nButtons},b.Background=function(a){arguments.length&&this.getready(a)},b.extend(b.Background,b.UIElement),b.Background.prototype.getready=function(a){if("undefined"==typeof a)throw new Error("Error: args is undefined!");b.Background.superclass.getready.call(this,a),this.values={selected:[],held:[],doubletap:[],tap:[]},this.defaultSlot="selected",this.image=a.image,this.setWidth(this.image.width),this.setHeight(this.image.height)},b.Background.prototype.GetImage=function(){return this.image},b.Background.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop?a=this.ROILeft&&b>=this.ROITop-this.landingHeight&&a<=this.ROILeft+this.ROIWidth&&b<=this.ROITop+this.ROIHeight+this.landingHeight?!0:!1},b.ClickBar.prototype.calculateValue=function(a,b){var c=b-this.yOrigin,d=1-c/this.height;return d>this.maxValue&&(d=this.maxValue),dthis.radius-this.thickness/2&&d=this.ROILeft&&b>=this.ROITop&&a<=this.ROILeft+this.ROIWidth&&b<=this.ROITop+this.ROIHeight?!0:!1},b.Grid.prototype.touch=function(a,b){return this.isInROI(a,b)&&(this.triggered=!0),void 0},b.Grid.prototype.release=function(a,b){return this.triggered&&this.isInROI(a,b)?(this.triggered=!1,{slot:"selected",value:[a,b]}):void 0},b.Grid.prototype.setValue=function(a,c){b.Grid.superclass.setValue.call(this,a,c)},b.Grid.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var b=a.context,c=Math.floor(this.height/this.rows),d=Math.floor(this.width/this.columns);b.fillStyle=this.bgColor,b.fillRect(this.xOrigin,this.yOrigin,this.width,this.height),b.beginPath(),b.lineWidth=this.lineWidth;for(var e=this.xOrigin+0;ee;e+=1)this.imagesArray[e].width>c&&(c=this.imagesArray[e].width),this.imagesArray[e].height>d&&(d=this.imagesArray[e].height)}this.setWidth(c),this.setHeight(d)},b.Knob.prototype.getImageNum=function(){return this.values.knobvalue<0||this.values.knobvalue>1?void 0:Math.round(this.values.knobvalue*(this.imageNum-1))},b.Knob.prototype.getImage=function(){var a=this.getImageNum();return this.imagesArray[a]},b.Knob.prototype.calculateAngle=function(a,c){var d=this.xOrigin+this.width/2,e=this.yOrigin+this.height/2,f=Math.atan2(a-d,c-e);0>f&&(f+=2*Math.PI);var g=f*(180/Math.PI);g=360-g,"undefined"!=typeof this.bottomAngularOffset&&(g=b.MathUtils.linearRange(0,360,-this.bottomAngularOffset,360+this.bottomAngularOffset,g),0>g&&(g=0),g>360&&(g=360));var h=b.MathUtils.linearRange(0,360,0,1,Math.floor(g));return h},b.Knob.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&a1&&(f=1),0>f&&(f=0),c={slot:"knobvalue",value:f}}}else if("atan"===this.knobMethod&&void 0!==this.start_x&&void 0!==this.start_y){var g=this.calculateAngle(a,b);return c={slot:"knobvalue",value:g}}return void 0},b.Knob.prototype.setValue=function(a,c){0>c||c>1||b.Knob.superclass.setValue.call(this,a,c)},b.Knob.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0)if(this.imagesArray.length>1){var b=this.getImageNum();a.context.drawImage(this.imagesArray[b],this.xOrigin,this.yOrigin)}else if(1==this.imagesArray.length){var c=0,d=this.height*this.getImageNum();a.context.drawImage(this.imagesArray[0],c,d,this.width,this.height,this.xOrigin,this.yOrigin,this.width,this.height)}},b.Label=function(a){arguments.length&&this.getready(a)},b.extend(b.Label,b.UIElement),b.Label.prototype.getready=function(a){b.Label.superclass.getready.call(this,a),this.values={labelvalue:""},this.defaultSlot="labelvalue",this.textColor=a.textColor||"black",this.setWidth(a.width),this.setHeight(a.height)},b.Label.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&a1)return void 0;var a=360*this.values.knobvalue,b=360-(a*(this.startAngValue-this.stopAngValue)/360+this.stopAngValue)%360,c=(360-this.initAngValue+b)%360;return c*Math.PI/180},b.RotKnob.prototype.getRangedAmount=function(a){var c=this.stopAngValue-this.initAngValue,d=this.startAngValue-this.initAngValue;a>this.initAngValue&&0>d&&(a=-(360-a));var e=b.MathUtils.linearRange(d,c,0,1,a);return 0>e&&(e=0),e>1&&(e=1),e},b.RotKnob.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&ag&&(g=360+g),(f-this.initAngValue)%360,this.getRangedAmount(Math.floor(g))},b.RotKnob.prototype.touch=function(a,b){var c=this.isInROI(a,b);if(c&&(this.start_x=a,this.start_y=b,"atan"===this.knobMethod)){var d=this.calculateAngle(a,b);return{slot:"knobvalue",value:d}}return void 0},b.RotKnob.prototype.release=function(){return this.start_x=null,this.start_y=null,void 0},b.RotKnob.prototype.drag=function(a,b){var c;if("updown"===this.knobMethod){if(null!==this.start_x&&null!==this.start_y){var d,e,f;return d=b-this.start_y,e=this.values.realknobvalue,f=e-d/this.sensitivity*this.moveDirection,f>1&&(f=1),0>f&&(f=0),c={slot:"knobvalue",value:f}}}else if("atan"===this.knobMethod&&this.isInROI(a,b)&&null!==this.start_x&&null!==this.start_y){var g=this.calculateAngle(a,b);return c={slot:"knobvalue",value:g}}return void 0},b.RotKnob.prototype.setValue=function(a,c){var d;if(!(0>c||c>1)){if(void 0===this.values[a])throw new Error("Slot "+a+" not present or value undefined");if(c!==this.values[a]&&c!==this.values["real"+a]){if(this.values["real"+a]=c,void 0!==this.angSteps){var e=1/this.angSteps;if(d=Math.floor(c/e)*e,d===this.values[a])return}else d=c;b.RotKnob.superclass.setValue.call(this,a,d)}}},b.RotKnob.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0){var c=this.getRotateAmount();b.CanvasUtils.drawRotate(a.context,{image:this.image,x:this.xOrigin,y:this.yOrigin,rot:c})}},b.Slider=function(a){arguments.length&&this.getready(a)},b.extend(b.Slider,b.UIElement),b.Slider.prototype.getready=function(a){if("undefined"==typeof a)throw"Slider error: args is undefined!";b.Slider.superclass.getready.call(this,a),this.values={slidervalue:0},this.defaultSlot="slidervalue",this.width=0,this.height=0,this.sliderImage=a.sliderImg,this.knobImage=a.knobImg,this.type=a.type,"horizontal"!==this.type&&"vertical"!==this.type&&(this.type="vertical"),this.calculateDimensions()},b.Slider.prototype.getKnobPosition=function(){var a;if(this.values.slidervalue<0||this.values.slidervalue>1)return void 0;switch(this.type){case"horizontal":a=Math.round(this.values.slidervalue*this.width+this.zeroLimit);break;case"vertical":a=Math.round(this.values.slidervalue*this.height+this.zeroLimit);break;default:throw new Error("Error: Slider orientation is undefined!")}return a},b.Slider.prototype.isInROI=function(a,b){switch(this.type){case"horizontal":if(a>this.getKnobPosition()&&b>this.ROITop&&athis.getKnobPosition()&&a>this.ROILeft&&b1&&(c=1),0>c&&(c=0),d={slot:"slidervalue",value:c}}return void 0},b.Slider.prototype.setValue=function(a,c){0>c||c>1||b.Slider.superclass.setValue.call(this,a,c)},b.Slider.prototype.refresh_CANVAS2D=function(a){if(this.isVisible===!0)switch(a.context.drawImage(this.sliderImage,this.xOrigin,this.yOrigin),this.type){case"horizontal":a.context.drawImage(this.knobImage,this.getKnobPosition(),this.yOrigin);break;case"vertical":a.context.drawImage(this.knobImage,this.xOrigin,this.getKnobPosition());break;default:throw new Error("Error: Slider orientation unknown: ",this.type)}},b.Slider.prototype.calculateDimensions=function(){switch(this.kWidth=this.knobImage.width,this.kHeight=this.knobImage.height,this.setWidth(this.sliderImage.width),this.setHeight(this.sliderImage.height),this.type){case"horizontal":this.totalStride=this.width+this.kWidth,this.additionalEndSpace=Math.round(this.kWidth/2),this.zeroLimit=this.xOrigin-this.additionalEndSpace,this.oneLimit=this.xOrigin+this.width+this.additionalEndSpace;break;case"vertical":this.totalStride=this.height+this.kHeight,this.additionalEndSpace=Math.round(this.kHeight/2),this.zeroLimit=this.yOrigin-this.additionalEndSpace,this.oneLimit=this.yOrigin+this.height+this.additionalEndSpace;break;default:throw new Error("Error: Slider orientation is undefined!")}},b.Slider.prototype.setGraphicWrapper=function(a){b.Slider.superclass.setGraphicWrapper.call(this,a),this.drawClass=a.initObject([{objName:"drawImage",objParms:this.objParms}])},b.Wavebox=function(a){arguments.length&&this.getready(a)},b.extend(b.Wavebox,b.UIElement),b.Wavebox.prototype.getready=function(a){b.Wavebox.superclass.getready.call(this,a),this.values={waveboxposition:0,startsample:0,endsample:null,waveboxsignal:[],xPos:0,yPos:0},this.defaultSlot="waveboxposition",this.setWidth(a.width),this.setHeight(a.height),this.binMethod=a.binMethod||"minmax",this.orientation=a.orientation||0,this.waveColor=a.waveColor||"black"},b.Wavebox.prototype.isInROI=function(a,b){return a>this.ROILeft&&b>this.ROITop&&ab)throw new Error("Error: Trying to set "+a+" less than 0: "+b);if("undefined"!=typeof this.values.waveboxsignal&&b>this.values.waveboxsignal.length)throw new Error("Error: Trying to set "+a+" bigger than signal length: "+b+" > "+this.values.waveboxsignal.length)}if("startsample"===a&&b>this.values.endsample)throw new Error("Error: Trying to set startsample > endsample: "+b+" > "+this.values.endsample);if("endsample"===a&&bj;j+=1)f=i(j,e,this.values),0===this.orientation?(c=h-(f.max+1)*h/2+this.yOrigin,d=j+this.xOrigin):1===this.orientation&&(c=j+this.yOrigin,d=h-(f.max+1)*h/2+this.xOrigin),b.lineTo(d,c);for(0===this.orientation?b.lineTo(g+this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.lineTo(.5*h+this.xOrigin,g+this.yOrigin),b.fill(),b.closePath(),b.beginPath(),0===this.orientation?b.moveTo(this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.moveTo(this.xOrigin+.5*h,this.yOrigin),j=0;g>j;j+=1)f=i(j,e,this.values),0===this.orientation&&(c=h-(f.min+1)*h/2+this.yOrigin,d=j+this.xOrigin),1===this.orientation&&(c=j+this.yOrigin,d=h-(f.min+1)*h/2+this.xOrigin),b.lineTo(d,c);0===this.orientation?b.lineTo(g+this.xOrigin,.5*h+this.yOrigin):1===this.orientation&&b.lineTo(.5*h+this.xOrigin,g+this.yOrigin),b.fill(),b.closePath()}},b.Wavebox.prototype.calculateBinMix=function(a,b,c){var d=c.waveboxsignal,e=c.startsample+a*b,f=c.startsample+(a+1)*b;f>c.endsample&&(f=c.endsample);for(var g=d[e],h=d[e],i=1;b>i;i++)d[e+i]h&&(h=d[e+i]);return{max:h,min:g}},b.Wavebox.prototype.calculateBinNone=function(a,b,c){var d=c.startsample+a*b,e=parseInt(b/2,10),f=c.waveboxsignal[d+e];return{max:f,min:-f}},b.Wavebox.prototype.calculateBinAvg=function(a,b){var c=this.values.waveboxsignal,d=this.values.startsample+a*b,e=d+(a+1)*b;e>this.values.endsample&&(e=this.values.endsample);for(var f=c.subarray(d,e),g=0,h=f.length,i=0;h-1>i;i++)g=(f[i+1]+i*g)/(i+1);return g},b.ENGINE={},b.ENGINE.engineFactory=function(a,b){function c(a){this.reset=function(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},this.canvas=a,this.context=a.getContext("2d"),this.type="CANVAS2D",this.getContext=function(){return this.context},this.getCanvas=function(){return this.canvas}}switch(a){case"CANVAS2D":if(void 0!==b.target)return new c(b.target);throw"Engine: args is undefined";case"ANOTHERTYPE":throw"Engine type not recognized: "+a;default:throw"Engine type not recognized: "+a}};var c=window.CanvasRenderingContext2D&&CanvasRenderingContext2D.prototype;return c.lineTo&&(c.dashedLine=function(a,b,c,d,e){e||(e=[10,5]),this.save();var f=c-a,g=d-b,h=Math.sqrt(f*f+g*g),i=Math.atan2(g,f);this.translate(a,b),this.moveTo(0,0),this.rotate(i);var j=e.length,k=0,l=!0;for(a=0;h>a;)a+=e[k++%j],a>h&&(a=h),l?this.lineTo(a,0):this.moveTo(a,0),l=!l;this.restore()}),b.OSC={},b.OSC.Message=function(a){this.address=a,this.typetags="",this.args=[];for(var c=1;c"+a+"s",b,0,[this.value])}},b.OSC.TInt=function(a){this.value=a},b.OSC.TInt.prototype={typetag:"i",decode:function(a){if(a.length<4)throw new ShortBuffer("int",a,4);return this.value=Struct.Unpack(">i",a.slice(0,4))[0],a.slice(4)},encode:function(){var a=new Array(4);return Struct.PackTo(">i",a,0,[this.value])}},b.OSC.TTime=function(a){this.value=a},b.OSC.TTime.prototype={typetag:"t",decode:function(a){if(a.length<8)throw new ShortBuffer("time",a,8);return this.value=Struct.Unpack(">LL",a.slice(0,8))[0],a.slice(8)},encode:function(a,b){return Struct.PackTo(">LL",a,b,this.value)}},b.OSC.TFloat=function(a){this.value=a},b.OSC.TFloat.prototype={typetag:"f",decode:function(a){if(a.length<4)throw new ShortBuffer("float",a,4);return this.value=Struct.Unpack(">f",a.slice(0,4))[0],a.slice(4)},encode:function(){var a=new Array(4);return Struct.PackTo(">f",a,0,[this.value])}},b.OSC.TBlob=function(a){this.value=a},b.OSC.TBlob.prototype={typetag:"b",decode:function(a){var b=Struct.Unpack(">i",a.slice(0,4))[0],c=parseInt(4*Math.ceil(b/4),10)+4;return this.value=a.slice(4,b+4),a.slice(c)},encode:function(a,b){var c=4*Math.ceil(this.value.length/4,10);return Struct.PackTo(">i"+c+"s",a,b,[c,this.value])}},b.OSC.TDouble=function(a){this.value=a},b.OSC.TDouble.prototype={typetag:"d",decode:function(a){if(a.length<8)throw new ShortBuffer("double",a,8);return this.value=Struct.Unpack(">d",a.slice(0,8))[0],a.slice(8)},encode:function(a,b){return Struct.PackTo(">d",a,b,[this.value])}},b.OSC.tagToConstructor={i:function(){return new b.OSC.TInt},f:function(){return new b.OSC.TFloat},s:function(){return new b.OSC.TString},b:function(){return new b.OSC.TBlob},d:function(){return new b.OSC.TDouble}},b.OSC.decodeBundle=function(a){var c=[],d={time:null,args:[]},e=new b.OSC.TTime;for(a=e.decode(a),d.time=e.value;a.length>0;){var f=new b.OSC.TInt;a=f.decode(a);var g=b.OSC.decode(a.slice(0,f.value));d.args.push(g),a=a.slice(f.value)}return c.push(d),c},b.OSC.decode=function(a){var c=[],d=new b.OSC.TString;if(a=d.decode(a),c.push(d.value),"#bundle"===d.value)return b.OSC.decodeBundle(a);if(a.length>0){var e=new b.OSC.TString;if(a=e.decode(a),e=e.value,","!=e[0])throw"invalid type tag in incoming OSC message, must start with comma";for(var f=1;fd;++d)c[d]=b.GenericUtils.clone(a[d]);return c}if(a instanceof Object){c={};for(var f in a)a.hasOwnProperty(f)&&(c[f]=b.GenericUtils.clone(a[f]));return c}throw new Error("Unable to copy obj! Its type isn't supported.")},b.MathUtils={},b.MathUtils.linearRange=function(a,b,c,d,e){var f=(e-a)*(d-c)/(b-a)+c;return f},b.MathUtils.distance=function(a,b,c,d){return Math.sqrt(Math.pow(a-c,2)+Math.pow(b-d,2))},b.MathUtils.fact_table=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3,0x1b02b9306890000,243290200817664e4,5109094217170944e4,0x3ceea4c2b3e0d80000,2.585201673888498e22,6.204484017332394e23,1.5511210043330986e25,4.0329146112660565e26,1.0888869450418352e28,3.0488834461171387e29,8.841761993739702e30,2.6525285981219107e32,8.222838654177922e33,2.631308369336935e35,8.683317618811886e36,2.9523279903960416e38,1.0333147966386145e40,3.7199332678990125e41,1.3763753091226346e43,5.230226174666011e44,2.0397882081197444e46,8.159152832478977e47,3.345252661316381e49,1.40500611775288e51,6.041526306337383e52,2.658271574788449e54,1.1962222086548019e56,5.502622159812089e57,2.5862324151116818e59,1.2413915592536073e61,6.082818640342675e62,3.0414093201713376e64,1.5511187532873822e66,8.065817517094388e67,4.2748832840600255e69,2.308436973392414e71,1.2696403353658276e73,7.109985878048635e74,4.0526919504877214e76,2.3505613312828785e78,1.3868311854568984e80,8.32098711274139e81,5.075802138772248e83,3.146997326038794e85,1.98260831540444e87,1.2688693218588417e89,8.247650592082472e90,5.443449390774431e92,3.647111091818868e94,2.4800355424368305e96,1.711224524281413e98,1.1978571669969892e100,8.504785885678623e101,6.1234458376886085e103,4.4701154615126844e105,3.307885441519386e107,2.48091408113954e109,1.8854947016660504e111,1.4518309202828587e113,1.1324281178206297e115,8.946182130782976e116,7.156945704626381e118,5.797126020747368e120,4.753643337012842e122,3.945523969720659e124,3.314240134565353e126,2.81710411438055e128,2.4227095383672734e130,2.107757298379528e132,1.8548264225739844e134,1.650795516090846e136,1.4857159644817615e138,1.352001527678403e140,1.2438414054641308e142,1.1567725070816416e144,1.087366156656743e146,1.032997848823906e148,9.916779348709496e149,9.619275968248212e151,9.426890448883248e153,9.332621544394415e155,9.332621544394415e157],b.MathUtils.fact_lookup=function(a){if(100>=(a>0))return b.MathUtils.fact_table[a];for(var c=1,d=2;a>=d;d++)c*=d;return c},b.CanvasUtils={},b.CanvasUtils.drawRotate=function(a,b){a.save(),a.translate(b.x+b.image.width/2,b.y+b.image.height/2),a.rotate(b.rot),a.translate(-(b.image.width/2)-b.x,-(b.image.height/2)-b.y),a.drawImage(b.image,b.x,b.y),a.restore()},b}); \ No newline at end of file