UNPKG

@mxtommy/kip

Version:

An advanced and versatile marine instrumentation package to display Signal K data.

24 lines 229 kB
/*! * Name : steelseries.js * Authors : Gerrit Grunwald, Mark Crossley * Last modified : 25.01.2016 * Revision : 0.14.17 * * Copyright (c) 2011, Gerrit Grunwald, Mark Crossley * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: * * # Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * # Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ var steelseries=function(){function c(n,t){var i="#"===n.charAt(0)?n.substring(1,7):n,r=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),f=parseInt(i.substring(4,6),16);return"rgba("+r+","+u+","+f+","+t+")"}function ui(t,i,r,u,f){var c=1/255,e=t.getRed(),o=t.getGreen(),s=t.getBlue(),h=t.getAlpha(),p=i.getRed()-e,w=i.getGreen()-o,b=i.getBlue()-s,k=i.getAlpha()*c-h*c,l=p/r*u,a=w/r*u,v=b/r*u,y=k/r*u;return f=f||!1,f?[(e+l).toFixed(0),(o+a).toFixed(0),(s+v).toFixed(0),h+y]:new n((e+l).toFixed(0),(o+a).toFixed(0),(s+v).toFixed(0),h+y)}function kr(n,t,i){return{start:n,stop:t,color:i}}function v(n,t){var r=Math.floor(Math.log10(n)),i=n/Math.pow(10,r),u;return u=t?1.5>i?1:3>i?2:7>i?5:10:1>=i?1:2>=i?2:5>=i?5:10,u*Math.pow(10,r)}function p(n,t,i,r,u,f){var e=t+r,o=i+u;n.beginPath();n.moveTo(t+f,i);n.lineTo(e-f,i);n.quadraticCurveTo(e,i,e,i+f);n.lineTo(e,i+u-f);n.quadraticCurveTo(e,o,e-f,o);n.lineTo(t+f,o);n.quadraticCurveTo(t,o,t,o-f);n.lineTo(t,i+f);n.quadraticCurveTo(t,i,t+f,i);n.closePath()}function t(n,t){var i=o.createElement("canvas");return i.width=n,i.height=t,i}function si(n,t,i){var r=o.createElement("canvas");return r.width=n,r.height=t,i(r.getContext("2d")),r}function ct(n){var t,i=si(1,1,function(t){t.fillStyle=n;t.beginPath();t.rect(0,0,1,1);t.fill()});return t=i.getContext("2d").getImageData(0,0,2,2).data,[t[0],t[1],t[2],t[3]]}function gt(t){var u,f,e,o,s,r=ct(t),i=new n(r[0],r[1],r[2],r[3]);return u=wi(i,.32),f=wi(i,.62),e=hi(i,.84),o=hi(i,.94),s=hi(i,1),new it(u,f,i,e,o,s)}function dr(n,t,i){var u,r,f,o,s,e;if(n/=255,t/=255,i/=255,r=Math.max(n,t,i),u=Math.min(n,t,i),s=(r+u)/2,r===u)f=o=0;else{e=r-u;o=s>.5?e/(2-r-u):e/(r+u);switch(r){case n:f=(t-i)/e+(t<i?6:0);break;case t:f=(i-n)/e+2;break;case i:f=(n-t)/e+4}f/=6}return[f,o,s]}function bt(n,t,i){var r,u,f,h=Math.floor(n*6),c=n*6-h,e=i*(1-t),o=i*(1-c*t),s=i*(1-(1-c)*t);switch(h%6){case 0:r=i;u=s;f=e;break;case 1:r=o;u=i;f=e;break;case 2:r=e;u=i;f=s;break;case 3:r=e;u=o;f=i;break;case 4:r=s;u=e;f=i;break;case 5:r=i;u=e;f=o}return[Math.floor(r*255),Math.floor(u*255),Math.floor(f*255)]}function wt(n,t,i){var e,r,u,o,s,f;if(n=n/255,t=t/255,i=i/255,r=Math.max(n,t,i),e=Math.min(n,t,i),s=r,f=r-e,o=r===0?0:f/r,r===e)u=0;else{switch(r){case n:u=(t-i)/f+(t<i?6:0);break;case t:u=(i-n)/f+2;break;case i:u=(n-t)/f+4}u/=6}return[u,o,s]}function rt(n,t){return n<0?0:n>t?t:n}function wi(t,i){var r=Math.floor(t.getRed()*(1-i)),u=Math.floor(t.getGreen()*(1-i)),f=Math.floor(t.getBlue()*(1-i));return r=rt(r,255),u=rt(u,255),f=rt(f,255),new n(r,u,f,t.getAlpha())}function hi(t,i){var r=Math.round(t.getRed()*(1+i)),u=Math.round(t.getGreen()*(1+i)),f=Math.round(t.getBlue()*(1+i));return r=rt(r,255),u=rt(u,255),f=rt(f,255),new n(r,u,f,t.getAlpha())}function gr(n,t,i){var r,u;if(i<=t)throw"Rotary bounds are of negative or zero size";return r=i-t,u=Math.floor((n-t)/r),n-u*r}function ci(n,t){return gr(t-n,-180,180)}function w(n){var t=typeof n=="string"||n instanceof String?o.getElementById(n):n;return t.getContext("2d")}var i=Math.PI*.5,r=Math.PI*2,f=Math.PI,u=Math.PI/180,ii=180/Math.PI,o=document,et="LCDMono2Ultra,Arial,Verdana,sans-serif",e="Arial,Verdana,sans-serif",gi=function(n,c){var wi;c=c||{};var wt=undefined===c.gaugeType?steelseries.GaugeType.TYPE4:c.gaugeType,l=undefined===c.size?0:c.size,y=undefined===c.minValue?0:c.minValue,k=undefined===c.maxValue?y+100:c.maxValue,ve=undefined===c.niceScale?!0:c.niceScale,bt=undefined===c.threshold?(k-y)/2+y:c.threshold,ui=undefined===c.thresholdRising?!0:c.thresholdRising,ai=undefined===c.section?null:c.section,vi=undefined===c.area?null:c.area,vu=undefined===c.titleString?"":c.titleString,yu=undefined===c.unitString?"":c.unitString,pu=undefined===c.frameDesign?steelseries.FrameDesign.METAL:c.frameDesign,wu=undefined===c.frameVisible?!0:c.frameVisible,yi=undefined===c.backgroundColor?steelseries.BackgroundColor.DARK_GRAY:c.backgroundColor,bu=undefined===c.backgroundVisible?!0:c.backgroundVisible,hi=undefined===c.pointerType?steelseries.PointerType.TYPE1:c.pointerType,ku=undefined===c.pointerColor?steelseries.ColorDef.RED:c.pointerColor,ye=undefined===c.knobType?steelseries.KnobType.STANDARD_KNOB:c.knobType,pi=undefined===c.knobStyle?steelseries.KnobStyle.SILVER:c.knobStyle,di=undefined===c.lcdColor?steelseries.LcdColor.STANDARD:c.lcdColor,iu=undefined===c.lcdVisible?!0:c.lcdVisible,du=undefined===c.lcdDecimals?2:c.lcdDecimals,pe=undefined===c.digitalFont?!1:c.digitalFont,gu=undefined===c.fractionalScaleDecimals?1:c.fractionalScaleDecimals,ru=undefined===c.ledColor?steelseries.LedColor.RED_LED:c.ledColor,uu=undefined===c.ledVisible?!0:c.ledVisible,fu=undefined===c.userLedColor?steelseries.LedColor.GREEN_LED:c.userLedColor,eu=undefined===c.userLedVisible?!1:c.userLedVisible,nf=undefined===c.thresholdVisible?!0:c.thresholdVisible,ou=undefined===c.minMeasuredValueVisible?!1:c.minMeasuredValueVisible,su=undefined===c.maxMeasuredValueVisible?!1:c.maxMeasuredValueVisible,tf=undefined===c.foregroundType?steelseries.ForegroundType.TYPE1:c.foregroundType,rf=undefined===c.foregroundVisible?!0:c.foregroundVisible,uf=undefined===c.labelNumberFormat?steelseries.LabelNumberFormat.STANDARD:c.labelNumberFormat,rr=undefined===c.playAlarm?!1:c.playAlarm,ff=undefined===c.alarmSound?!1:c.alarmSound,we=undefined===c.customLayer?null:c.customLayer,be=undefined===c.tickLabelOrientation?wt===steelseries.GaugeType.TYPE1?steelseries.TickLabelOrientation.TANGENT:steelseries.TickLabelOrientation.NORMAL:c.tickLabelOrientation,hu=undefined===c.trendVisible?!1:c.trendVisible,lr=undefined===c.trendColors?[steelseries.LedColor.RED_LED,steelseries.LedColor.GREEN_LED,steelseries.LedColor.CYAN_LED]:c.trendColors,ar=undefined===c.useOdometer?!1:c.useOdometer,ci=undefined===c.odometerParams?{}:c.odometerParams,ke=undefined===c.odometerUseValue?!1:c.odometerUseValue,ef=undefined===c.fullScaleDeflectionTime?2.5:c.fullScaleDeflectionTime,p=w(n);l===0&&(l=Math.min(p.canvas.width,p.canvas.height));p.canvas.width=l;p.canvas.height=l;rr&&ff!==!1&&(wi=o.createElement("audio"),wi.setAttribute("src",ff),wi.setAttribute("preload","auto"));var it=y,vr=y,of=this,dt=k,gt=y,ot=!1,yr=!1,sf=0,cu=0,bi,ki=!1,hf=steelseries.TrendState.OFF,pr=l*.06,wr=l*.29,br=l*.36,gi,kt,kr,ni,ti,lu=kt+(it-y)*ti,rt=l,ft=l,lt=rt/2,vt=ft/2,fi=l*.093457,de=.6*rt,ge=.4*ft,no=wt===steelseries.GaugeType.TYPE3?.6*rt:lt-fi/2,to=wt===steelseries.GaugeType.TYPE3?.72*ft:.75*ft,au=Math.floor(rt/10),io=au+"px "+e,ro=au+"px "+et,cf=ft*.13,ur=rt*.4,lf=(rt-ur)/2,af=ft*.57,vf,uo=ft*.61,yf=rt*.006,pf=!1,dr=y,gr=k,fr=k-y,ei=gr-dr,nu=0,oi=0,nr=10,wf=10,fo=function(){ve?(fr=v(k-y,!1),oi=v(fr/(wf-1),!0),dr=Math.floor(y/oi)*oi,gr=Math.ceil(k/oi)*oi,nu=v(oi/(nr-1),!0),y=dr,k=gr,ei=k-y):(fr=k-y,dr=y,gr=k,ei=fr,oi=v(fr/(wf-1),!0),nu=v(oi/(nr-1),!0));it=it<y?y:it>k?k:it;dt=dt<y?y:dt>k?k:dt;gt=gt<y?y:gt>k?k:gt;bt=bt<y?y:bt>k?k:bt;switch(wt.type){case"type1":gi=0;kt=f;kr=i;ni=i;ti=ni/ei;break;case"type2":gi=0;kt=f;kr=i;ni=f;ti=ni/ei;break;case"type3":gi=0;kt=i;kr=0;ni=1.5*f;ti=ni/ei;break;case"type4":default:gi=60*u;kt=i+gi/2;kr=0;ni=r-gi;ti=ni/ei}lu=kt+(it-y)*ti},er=t(l,l),bf=er.getContext("2d"),or=t(l,l),yt=or.getContext("2d"),kf,tr=t(fi,fi),df=tr.getContext("2d"),li=t(fi,fi),gf=li.getContext("2d"),ir=li,si=t(fi,fi),ne=si.getContext("2d"),ri=t(fi,fi),te=ri.getContext("2d"),ii=ri,ie=t(Math.ceil(l*.028037),Math.ceil(l*.028037)),eo=ie.getContext("2d"),re=t(Math.ceil(l*.028037),Math.ceil(l*.028037)),oo=re.getContext("2d"),sr=t(l,l),ue=sr.getContext("2d"),hr=t(l,l),fe=hr.getContext("2d"),ee,oe,se,he,ce,tu,le;ar&&iu&&(tu=t(10,10),le=tu.getContext("2d"));var so=function(n,t){n.restore();n.save();n.textAlign="right";n.strokeStyle=di.textColor;n.fillStyle=di.textColor;(di===steelseries.LcdColor.STANDARD||di===steelseries.LcdColor.STANDARD_GREEN)&&(n.shadowColor="gray",n.shadowOffsetX=rt*.007,n.shadowOffsetY=rt*.007,n.shadowBlur=rt*.007);n.font=pe?ro:io;n.fillText(t.toFixed(du),lf+ur-ur*.05,af+cf*.5+au*.38,ur*.9);n.restore()},ho=function(n){n.save();"type1"===wt.type&&n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.523364,ft*.130841);("type1"===wt.type||"type2"===wt.type)&&n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.130841,ft*.514018);("type2"===wt.type||"type3"===wt.type)&&n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.831775,ft*.514018);"type3"===wt.type&&n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.523364,ft*.831775);"type4"===wt.type&&(n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.336448,ft*.803738),n.drawImage(a(Math.ceil(ft*.037383),steelseries.KnobType.STANDARD_KNOB,pi),rt*.626168,ft*.803738));n.restore()},co=function(){var t=o.createElement("canvas"),n,i;return t.width=Math.ceil(l*.046728),t.height=Math.ceil(t.width*.9),n=t.getContext("2d"),n.save(),i=n.createLinearGradient(0,.1,0,t.height*.9),i.addColorStop(0,"#520000"),i.addColorStop(.3,"#fc1d00"),i.addColorStop(.59,"#fc1d00"),i.addColorStop(1,"#520000"),n.fillStyle=i,n.beginPath(),n.moveTo(t.width*.5,.1),n.lineTo(t.width*.9,t.height*.9),n.lineTo(t.width*.1,t.height*.9),n.lineTo(t.width*.5,.1),n.closePath(),n.fill(),n.strokeStyle="#FFFFFF",n.stroke(),n.restore(),t},ae=function(n,t,i,r,u){if(t<y?t=y:t>k&&(t=k),i<y?i=y:i>k&&(i=k),!(t>=i)){n.save();n.strokeStyle=r;n.fillStyle=r;n.lineWidth=rt*.035;var f=ni/ei*t-ni/ei*y,e=f+(i-t)/(ei/ni);n.translate(lt,vt);n.rotate(kt);n.beginPath();u?(n.moveTo(0,0),n.arc(0,0,rt*.365-n.lineWidth/2,f,e,!1)):n.arc(0,0,rt*.365,f,e,!1);u?(n.moveTo(0,0),n.fill()):n.stroke();n.translate(-lt,-vt);n.restore()}},lo=function(n,t){var p=Math.ceil(rt*.04),o=kt,r=ti*nu,u,s=y,h=nr-1,l=rt*.38,w=rt*.35,b=rt*.355,d=rt*.36,v=rt*.3,c=rt*.1,g=nr/2,nt=parseFloat(k.toFixed(2)),a;for(yi.labelColor.setAlpha(1),n.save(),n.textAlign="center",n.textBaseline="middle",n.font=p+"px "+e,n.strokeStyle=yi.labelColor.getRgbaColor(),n.fillStyle=yi.labelColor.getRgbaColor(),n.translate(lt,vt),n.rotate(kt),(wt.type==="type1"||wt.type==="type2")&&(c=rt*.04),a=y;parseFloat(a.toFixed(2))<=nt;a+=nu){if(u=r+i,h++,h===nr){n.lineWidth=1.5;n.beginPath();n.moveTo(l,0);n.lineTo(w,0);n.closePath();n.stroke();n.save();n.translate(v,0);switch(be.type){case"horizontal":u=-o;break;case"tangent":u=o<=i+f?f:0;break;case"normal":default:u=i}n.rotate(u);switch(t.format){case"fractional":n.fillText(s.toFixed(gu),0,0,c);break;case"scientific":n.fillText(s.toPrecision(2),0,0,c);break;case"standard":default:n.fillText(s.toFixed(0),0,0,c)}n.translate(-v,0);n.restore();s+=oi;h=0;n.rotate(r);o+=r;continue}0==nr%2&&h===g?(n.lineWidth=1,n.beginPath(),n.moveTo(l,0),n.lineTo(b,0),n.closePath(),n.stroke()):(n.lineWidth=.5,n.beginPath(),n.moveTo(l,0),n.lineTo(d,0),n.closePath(),n.stroke());n.rotate(r);o+=r}n.translate(-lt,-vt);n.restore()},ct=function(n){var t,r,f;n=n||{};var e=undefined===n.frame?!1:n.frame,u=undefined===n.background?!1:n.background,o=undefined===n.led?!1:n.led,s=undefined===n.userLed?!1:n.userLed,c=undefined===n.pointer?!1:n.pointer,a=undefined===n.foreground?!1:n.foreground,v=undefined===n.trend?!1:n.trend,p=undefined===n.odo?!1:n.odo;if(pf=!0,fo(),e&&wu&&d(bf,pu,lt,vt,rt,ft),u&&bu&&(nt(yt,yi,lt,vt,rt,ft),ht(yt,we,lt,vt,rt,ft)),o&&(df.drawImage(h(Math.ceil(l*.093457),1,ru),0,0),gf.drawImage(h(Math.ceil(l*.093457),0,ru),0,0)),s&&(ne.drawImage(h(Math.ceil(l*.093457),1,fu),0,0),te.drawImage(h(Math.ceil(l*.093457),0,fu),0,0)),ou&&eo.drawImage(b(Math.ceil(l*.028037),steelseries.ColorDef.BLUE.dark.getRgbaColor(),!0,!0),0,0),su&&oo.drawImage(b(Math.ceil(l*.028037),steelseries.ColorDef.RED.medium.getRgbaColor(),!0),0,0),u&&bu){if(ho(yt),null!==ai&&0<ai.length){t=ai.length;do t--,ae(yt,ai[t].start,ai[t].stop,ai[t].color,!1);while(0<t)}if(null!==vi&&0<vi.length){r=vi.length;do r--,ae(yt,vi[r].start,vi[r].stop,vi[r].color,!0);while(0<r)}lo(yt,uf);pt(yt,rt,ft,vu,yu,yi,!0,!0)}u&&nf&&(yt.save(),yt.translate(lt,vt),yt.rotate(kt+(bt-y)*ti+i),yt.translate(-lt,-vt),yt.drawImage(co(),rt*.475,ft*.13),yt.translate(lt,vt),yt.restore());u&&iu&&(ar&&p?(ce=new steelseries.Odometer("",{_context:le,height:l*.075,decimals:ci.decimals,digits:ci.digits===undefined?5:ci.digits,valueForeColor:ci.valueForeColor,valueBackColor:ci.valueBackColor,decimalForeColor:ci.decimalForeColor,decimalBackColor:ci.decimalBackColor,font:ci.font,value:it}),vf=(rt-tu.width)/2):ar||(kf=tt(ur,cf,di),yt.drawImage(kf,lf,af)));c&&st(ue,rt,hi,ku,yi.labelColor);a&&rf&&(f=hi.type==="type15"||hi.type==="type16"?!1:!0,g(fe,tf,rt,ft,f,ye,pi,wt));v&&hu&&(ee=ut(pr,steelseries.TrendState.UP,lr),oe=ut(pr,steelseries.TrendState.STEADY,lr),se=ut(pr,steelseries.TrendState.DOWN,lr),he=ut(pr,steelseries.TrendState.OFF,lr))},at=function(n){n=n||{};var t=undefined===n.frame?!1:n.frame,i=undefined===n.background?!1:n.background,r=undefined===n.led?!1:n.led,u=undefined===n.userLed?!1:n.userLed,f=undefined===n.pointer?!1:n.pointer,e=undefined===n.foreground?!1:n.foreground;t&&(er.width=l,er.height=l,bf=er.getContext("2d"));i&&(or.width=l,or.height=l,yt=or.getContext("2d"));r&&(tr.width=Math.ceil(l*.093457),tr.height=Math.ceil(l*.093457),df=tr.getContext("2d"),li.width=Math.ceil(l*.093457),li.height=Math.ceil(l*.093457),gf=li.getContext("2d"),ir=li);u&&(si.width=Math.ceil(l*.093457),si.height=Math.ceil(l*.093457),ne=si.getContext("2d"),ri.width=Math.ceil(l*.093457),ri.height=Math.ceil(l*.093457),te=ri.getContext("2d"),ii=ri);f&&(sr.width=l,sr.height=l,ue=sr.getContext("2d"));e&&(hr.width=l,hr.height=l,fe=hr.getContext("2d"))},ao=function(){uu&&(ir=ir===tr?li:tr,ki||(ki=!0,s(of.repaint)))},vo=function(){eu&&(ii=ii===si?ri:si,ki||(ki=!0,s(of.repaint)))},cr=function(n){n?sf=setInterval(ao,1e3):(clearInterval(sf),ir=li)},yo=function(n){n?cu=setInterval(vo,1e3):(clearInterval(cu),ii=ri)};return this.setValue=function(n){n=parseFloat(n);var t=n<y?y:n>k?k:n;return it!==t&&(it=t,it>gt&&(gt=it),it<dt&&(dt=it),it>=bt&&!ot&&ui||it<=bt&&!ot&&!ui?(ot=!0,cr(ot),rr&&wi.play()):(it<bt&&ot&&ui||it>bt&&ot&&!ui)&&(ot=!1,cr(ot),rr&&wi.pause()),this.repaint()),this},this.getValue=function(){return it},this.setOdoValue=function(n){n=parseFloat(n);var t=n<0?0:n;return vr!==t&&(vr=t,this.repaint()),this},this.getOdoValue=function(){return vr},this.setValueAnimated=function(n,t){n=parseFloat(n);var r=n<y?y:n>k?k:n,u=this,i;return it!==r&&(undefined!==bi&&bi.isPlaying&&bi.stop(),i=ef*Math.abs(r-it)/(k-y),i=Math.max(i,ef/5),bi=new Tween({},"",Tween.regularEaseInOut,it,r,i),bi.onMotionChanged=function(n){it=n.target._pos;it>=bt&&!ot&&ui||it<=bt&&!ot&&!ui?(ot=!0,cr(ot),rr&&wi.play()):(it<bt&&ot&&ui||it>bt&&ot&&!ui)&&(ot=!1,cr(ot),rr&&wi.pause());it>gt&&(gt=it);it<dt&&(dt=it);ki||(ki=!0,s(u.repaint))},t&&typeof t=="function"&&(bi.onMotionFinished=t),bi.start()),this},this.resetMinMeasuredValue=function(){dt=it;this.repaint()},this.resetMaxMeasuredValue=function(){return gt=it,this.repaint(),this},this.setMinMeasuredValueVisible=function(n){return ou=!!n,this.repaint(),this},this.setMaxMeasuredValueVisible=function(n){return su=!!n,this.repaint(),this},this.setMaxMeasuredValue=function(n){n=parseFloat(n);var t=n<y?y:n>k?k:n;return gt=t,this.repaint(),this},this.setMinMeasuredValue=function(n){n=parseFloat(n);var t=n<y?y:n>k?k:n;return dt=t,this.repaint(),this},this.setTitleString=function(n){return vu=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setUnitString=function(n){return yu=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setMinValue=function(n){return y=parseFloat(n),at({background:!0}),ct({background:!0}),this.repaint(),this},this.getMinValue=function(){return y},this.setMaxValue=function(n){return k=parseFloat(n),at({background:!0}),ct({background:!0}),this.repaint(),this},this.getMaxValue=function(){return k},this.setThreshold=function(n){n=parseFloat(n);var t=n<y?y:n>k?k:n;return bt=t,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setArea=function(n){return vi=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setSection=function(n){return ai=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setThresholdVisible=function(n){return nf=!!n,this.repaint(),this},this.setThresholdRising=function(n){return ui=!!n,ot=!ot,cr(ot),this.repaint(),this},this.setLcdDecimals=function(n){return du=parseInt(n,10),this.repaint(),this},this.setFrameDesign=function(n){return at({frame:!0}),pu=n,ct({frame:!0}),this.repaint(),this},this.setBackgroundColor=function(n){return at({background:!0,pointer:hi.type==="type2"||hi.type==="type13"?!0:!1}),yi=n,ct({background:!0,pointer:hi.type==="type2"||hi.type==="type13"?!0:!1}),this.repaint(),this},this.setForegroundType=function(n){return at({foreground:!0}),tf=n,ct({foreground:!0}),this.repaint(),this},this.setPointerType=function(n){return at({pointer:!0,foreground:!0}),hi=n,ct({pointer:!0,foreground:!0}),this.repaint(),this},this.setPointerColor=function(n){return at({pointer:!0}),ku=n,ct({pointer:!0}),this.repaint(),this},this.setLedColor=function(n){return at({led:!0}),ru=n,ct({led:!0}),this.repaint(),this},this.setUserLedColor=function(n){return at({userLed:!0}),fu=n,ct({userLed:!0}),this.repaint(),this},this.toggleUserLed=function(){return ii=ii===si?ri:si,this.repaint(),this},this.setUserLedOnOff=function(n){return ii=!0===n?si:ri,this.repaint(),this},this.blinkUserLed=function(n){return n?yr||(yo(!0),yr=!0):yr&&(clearInterval(cu),yr=!1),this},this.setLedVisible=function(n){return uu=!!n,this.repaint(),this},this.setUserLedVisible=function(n){return eu=!!n,this.repaint(),this},this.setLcdColor=function(n){return di=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.setTrend=function(n){return hf=n,this.repaint(),this},this.setTrendVisible=function(n){return hu=!!n,this.repaint(),this},this.setFractionalScaleDecimals=function(n){return gu=parseInt(n,10),at({background:!0}),ct({background:!0}),this.repaint(),this},this.setLabelNumberFormat=function(n){return uf=n,at({background:!0}),ct({background:!0}),this.repaint(),this},this.repaint=function(){if(pf||ct({frame:!0,background:!0,led:!0,userLed:!0,pointer:!0,trend:!0,foreground:!0,odo:!0}),p.clearRect(0,0,l,l),wu&&p.drawImage(er,0,0),p.drawImage(or,0,0),iu&&(ar?(ce.setValue(ke?it:vr),p.drawImage(tu,vf,uo)):so(p,it)),uu&&p.drawImage(ir,de,ge),eu&&p.drawImage(ii,no,to),hu)switch(hf.state){case"up":p.drawImage(ee,wr,br);break;case"steady":p.drawImage(oe,wr,br);break;case"down":p.drawImage(se,wr,br);break;case"off":p.drawImage(he,wr,br)}ou&&(p.save(),p.translate(lt,vt),p.rotate(kt+i+(dt-y)*ti),p.translate(-lt,-vt),p.drawImage(ie,p.canvas.width*.4865,p.canvas.height*.105),p.restore());su&&(p.save(),p.translate(lt,vt),p.rotate(kt+i+(gt-y)*ti),p.translate(-lt,-vt),p.drawImage(re,p.canvas.width*.4865,p.canvas.height*.105),p.restore());lu=kt+i+(it-y)*ti;p.save();p.translate(lt,vt);p.rotate(lu);p.translate(-lt,-vt);p.shadowColor="rgba(0, 0, 0, 0.8)";p.shadowOffsetX=p.shadowOffsetY=yf;p.shadowBlur=yf*2;p.drawImage(sr,0,0);p.restore();rf&&p.drawImage(hr,0,0);ki=!1},this.repaint(),this},nr=function(n,c){var li;c=c||{};var hi=undefined===c.gaugeType?steelseries.GaugeType.TYPE4:c.gaugeType,p=undefined===c.size?0:c.size,l=undefined===c.minValue?0:c.minValue,a=undefined===c.maxValue?l+100:c.maxValue,re=undefined===c.niceScale?!0:c.niceScale,yt=undefined===c.threshold?(a-l)/2+l:c.threshold,ti=undefined===c.thresholdRising?!0:c.thresholdRising,ci=undefined===c.section?null:c.section,su=undefined===c.useSectionColors?!1:c.useSectionColors,hu=undefined===c.titleString?"":c.titleString,cu=undefined===c.unitString?"":c.unitString,lu=undefined===c.frameDesign?steelseries.FrameDesign.METAL:c.frameDesign,au=undefined===c.frameVisible?!0:c.frameVisible,yi=undefined===c.backgroundColor?steelseries.BackgroundColor.DARK_GRAY:c.backgroundColor,vu=undefined===c.backgroundVisible?!0:c.backgroundVisible,sr=undefined===c.valueColor?steelseries.ColorDef.RED:c.valueColor,pi=undefined===c.lcdColor?steelseries.LcdColor.STANDARD:c.lcdColor,yu=undefined===c.lcdVisible?!0:c.lcdVisible,pu=undefined===c.lcdDecimals?2:c.lcdDecimals,ue=undefined===c.digitalFont?!1:c.digitalFont,wu=undefined===c.fractionalScaleDecimals?1:c.fractionalScaleDecimals,fe=undefined===c.customLayer?null:c.customLayer,dr=undefined===c.ledColor?steelseries.LedColor.RED_LED:c.ledColor,gr=undefined===c.ledVisible?!0:c.ledVisible,nu=undefined===c.userLedColor?steelseries.LedColor.GREEN_LED:c.userLedColor,tu=undefined===c.userLedVisible?!1:c.userLedVisible,bu=undefined===c.labelNumberFormat?steelseries.LabelNumberFormat.STANDARD:c.labelNumberFormat,ku=undefined===c.foregroundType?steelseries.ForegroundType.TYPE1:c.foregroundType,du=undefined===c.foregroundVisible?!0:c.foregroundVisible,gi=undefined===c.playAlarm?!1:c.playAlarm,gu=undefined===c.alarmSound?!1:c.alarmSound,nr=undefined===c.valueGradient?null:c.valueGradient,nf=undefined===c.useValueGradient?!1:c.useValueGradient,ee=undefined===c.tickLabelOrientation?hi===steelseries.GaugeType.TYPE1?steelseries.TickLabelOrientation.TANGENT:steelseries.TickLabelOrientation.NORMAL:c.tickLabelOrientation,iu=undefined===c.trendVisible?!1:c.trendVisible,hr=undefined===c.trendColors?[steelseries.LedColor.RED_LED,steelseries.LedColor.GREEN_LED,steelseries.LedColor.CYAN_LED]:c.trendColors,tf=undefined===c.fullScaleDeflectionTime?2.5:c.fullScaleDeflectionTime,k=w(n);p===0&&(p=Math.min(k.canvas.width,k.canvas.height));k.canvas.width=p;k.canvas.height=p;gi&&gu!==!1&&(li=o.createElement("audio"),li.setAttribute("src",gu),li.setAttribute("preload","auto"));var it=l,bt=a-l,ft=!1,rf=0,cr=!1,ru=0,ai,uf=this,vi=!1,wt,ct,wi,ei,rt,ri,dt,oe,bi=[],lr=!1,uu=!1,y=p,lt=p,st=y/2,at=lt/2,fu=Math.floor(y/10),se=fu+"px "+e,he=fu+"px "+et,eu=lt*.13,tr=y*.4,ff=(y-tr)/2,ef=lt/2-eu/2,ce=y*.116822,le=y*.485981,b=Math.ceil(p*.093457),of=y*.53,sf=lt*.61,ae=hi===steelseries.GaugeType.TYPE3?.7*y:st-b/2,ve=hi===steelseries.GaugeType.TYPE3?.61*lt:.75*lt,hf=steelseries.TrendState.OFF,ar=p*.06,vr=p*.38,yr=p*.57;switch(hi.type){case"type1":wt=0;ct=f;wi=0;ei=i;rt=i;ri=rt*ii;dt=rt/bt;break;case"type2":wt=0;ct=f;wi=0;ei=i;rt=f;ri=rt*ii;dt=rt/bt;break;case"type3":wt=0;ct=i;wi=-i;ei=0;rt=1.5*f;ri=rt*ii;dt=rt/bt;break;case"type4":default:wt=60*u;ct=i+wt/2;wi=-r/6;ei=0;rt=r-wt;ri=rt*ii;dt=rt/bt}var ir=t(p,p),cf=ir.getContext("2d"),rr=t(p,p),oi=rr.getContext("2d"),lf,ur=t(Math.ceil(p*.060747),Math.ceil(p*.023364)),ou=ur.getContext("2d"),ki=t(b,b),af=ki.getContext("2d"),si=t(b,b),vf=si.getContext("2d"),di=si,ui=t(b,b),yf=ui.getContext("2d"),ni=t(b,b),pf=ni.getContext("2d"),kt=ni,ye,fr=t(p,p),wf=fr.getContext("2d"),bf,kf,df,gf,ne=!1,pr=l,wr=a,er=a-l;bt=wr-pr;var br=0,fi=0,kr=10,te=10,pe=function(){re?(er=v(a-l,!1),fi=v(er/(te-1),!0),pr=Math.floor(l/fi)*fi,wr=Math.ceil(a/fi)*fi,br=v(fi/(kr-1),!0),l=pr,a=wr,bt=a-l):(er=a-l,pr=l,wr=a,bt=er,fi=v(er/(te-1),!0),br=v(fi/(kr-1),!0));it=it<l?l:it>a?a:it;minMeasuredValue=minMeasuredValue<l?l:minMeasuredValue>a?a:minMeasuredValue;maxMeasuredValue=maxMeasuredValue<l?l:maxMeasuredValue>a?a:maxMeasuredValue;yt=yt<l?l:yt>a?a:yt;switch(hi.type){case"type1":wt=0;ct=f;ei=i;rt=i;dt=rt/bt;break;case"type2":wt=0;ct=f;ei=i;rt=f;dt=rt/bt;break;case"type3":wt=0;ct=i;ei=0;rt=1.5*f;dt=rt/bt;break;case"type4":default:wt=60*u;ct=i+wt/2;ei=0;rt=r-wt;dt=rt/bt}oe=ct+(it-l)*dt},ot=function(n){var t;n=n||{};var r=undefined===n.frame?!1:n.frame,i=undefined===n.background?!1:n.background,u=undefined===n.led?!1:n.led,f=undefined===n.userLed?!1:n.userLed,e=undefined===n.value?!1:n.value,o=undefined===n.foreground?!1:n.foreground,s=undefined===n.trend?!1:n.trend;if(ne=!0,pe(),r&&au&&d(cf,lu,st,at,y,lt),i&&vu&&(nt(oi,yi,st,at,y,lt),ht(oi,fe,st,at,y,lt)),u&&(af.drawImage(h(b,1,dr),0,0),vf.drawImage(h(b,0,dr),0,0),ye=oi.getImageData(of,sf,b,b)),f&&(yf.drawImage(h(Math.ceil(b),1,nu),0,0),pf.drawImage(h(Math.ceil(b),0,nu),0,0)),i&&we(oi),i&&vu&&(ke(oi,bu),pt(oi,y,lt,hu,cu,yi,!0,!0)),i&&yu&&(lf=tt(tr,eu,pi),oi.drawImage(lf,ff,ef)),lr=!1,su&&null!==ci&&0<ci.length){lr=!0;t=ci.length;bi=[];do t--,bi.push({start:(ci[t].start+Math.abs(l))/(a-l)*ri,stop:(ci[t].stop+Math.abs(l))/(a-l)*ri,color:gt(ci[t].color)});while(0<t)}uu=!1;nf&&nr!==null&&(lr=!1,uu=!0);e&&ie(ou,sr);o&&du&&g(wf,ku,y,lt,!1);s&&iu&&(bf=ut(ar,steelseries.TrendState.UP,hr),kf=ut(ar,steelseries.TrendState.STEADY,hr),df=ut(ar,steelseries.TrendState.DOWN,hr),gf=ut(ar,steelseries.TrendState.OFF,hr))},vt=function(n){n=n||{};var t=undefined===n.frame?!1:n.frame,i=undefined===n.background?!1:n.background,r=undefined===n.led?!1:n.led,u=undefined===n.userLed?!1:n.userLed,f=undefined===n.value?!1:n.value,e=undefined===n.foreground?!1:n.foreground;t&&(ir.width=p,ir.height=p,cf=ir.getContext("2d"));i&&(rr.width=p,rr.height=p,oi=rr.getContext("2d"));f&&(ur.width=Math.ceil(p*.060747),ur.height=Math.ceil(p*.023364),ou=ur.getContext("2d"));r&&(ki.width=Math.ceil(b),ki.height=Math.ceil(b),af=ki.getContext("2d"),si.width=Math.ceil(b),si.height=Math.ceil(b),vf=si.getContext("2d"),di=si);u&&(ui.width=Math.ceil(b),ui.height=Math.ceil(b),yf=ui.getContext("2d"),ni.width=Math.ceil(b),ni.height=Math.ceil(b),pf=ni.getContext("2d"),kt=ni);e&&(fr.width=p,fr.height=p,wf=fr.getContext("2d"))},we=function(n){var t,r,i;n.save();n.save();n.lineWidth=p*.085;n.beginPath();n.translate(st,at);n.rotate(ct-4*u);n.translate(-st,-at);n.arc(st,at,y*.35514,0,rt+8*u,!1);n.rotate(-ct);t=n.createLinearGradient(0,.107476*lt,0,.897195*lt);t.addColorStop(0,"#000000");t.addColorStop(.22,"#333333");t.addColorStop(.76,"#333333");t.addColorStop(1,"#cccccc");n.strokeStyle=t;n.stroke();n.restore();n.save();n.lineWidth=p*.075;n.beginPath();n.translate(st,at);n.rotate(ct-4*u);n.translate(-st,-at);n.arc(st,at,y*.35514,0,rt+8*u,!1);n.rotate(-ct);r=n.createLinearGradient(0,.112149*lt,0,.892523*lt);r.addColorStop(0,"#111111");r.addColorStop(1,"#333333");n.strokeStyle=r;n.stroke();n.restore();var e=(y*.116822+y*.060747)/2,o=(y*.485981+y*.023364)/2,f=n.createRadialGradient(e,o,0,e,o,.030373*y);for(f.addColorStop(0,"#3c3c3c"),f.addColorStop(1,"#323232"),i=0,i=0;i<=ri;i+=5)n.save(),n.translate(st,at),n.rotate(i*u+wi),n.translate(-st,-at),n.beginPath(),n.rect(y*.116822,y*.485981,y*.060747,y*.023364),n.closePath(),n.fillStyle=f,n.fill(),n.restore();n.restore()},ie=function(n,t){n.save();n.beginPath();n.rect(0,0,n.canvas.width,n.canvas.height);n.closePath();var r=n.canvas.width/2,u=n.canvas.height/2,i=k.createRadialGradient(r,u,0,r,u,n.canvas.width/2);i.addColorStop(0,t.light.getRgbaColor());i.addColorStop(1,t.dark.getRgbaColor());n.fillStyle=i;n.fill();n.restore()},be=function(n,t){n.save();n.textAlign="right";n.strokeStyle=pi.textColor;n.fillStyle=pi.textColor;(pi===steelseries.LcdColor.STANDARD||pi===steelseries.LcdColor.STANDARD_GREEN)&&(n.shadowColor="gray",n.shadowOffsetX=y*.007,n.shadowOffsetY=y*.007,n.shadowBlur=y*.007);n.font=ue?he:se;n.fillText(t.toFixed(pu),ff+tr-tr*.05,ef+eu*.5+fu*.38,tr*.9);n.restore()},ke=function(n,t){var o=ct,r=dt*br,u,w=Math.ceil(y*.04),s=l,c=kr-1,p=y*.28,h=y*.1,b=parseFloat(a.toFixed(2)),v;for(yi.labelColor.setAlpha(1),n.save(),n.textAlign="center",n.textBaseline="middle",n.font=w+"px "+e,n.strokeStyle=yi.labelColor.getRgbaColor(),n.fillStyle=yi.labelColor.getRgbaColor(),n.translate(st,at),n.rotate(ct),(hi.type==="type1"||hi.type==="type2")&&(h=y*.0375),v=l;parseFloat(v.toFixed(2))<=b;v+=br){if(u=+r+i,c++,c===kr){n.save();n.translate(p,0);switch(ee.type){case"horizontal":u=-o;break;case"tangent":u=o<=i+f?f:0;break;case"normal":default:u=i}n.rotate(u);switch(t.format){case"fractional":n.fillText(s.toFixed(wu),0,0,h);break;case"scientific":n.fillText(s.toPrecision(2),0,0,h);break;case"standard":default:n.fillText(s.toFixed(0),0,0,h)}n.translate(-p,0);n.restore();s+=fi;c=0;n.rotate(r);o+=r;continue}n.rotate(r);o+=r}n.translate(-st,-at);n.restore()},or=function(n){n?rf=setInterval(ge,1e3):(clearInterval(rf),di=si)},de=function(n){n?ru=setInterval(no,1e3):(clearInterval(ru),kt=ni)},ge=function(){gr&&(di=di===ki?si:ki,vi||(vi=!0,s(uf.repaint)))},no=function(){tu&&(kt=kt===ui?ni:ui,vi||(vi=!0,s(uf.repaint)))};return this.setValue=function(n){n=parseFloat(n);var t=n<l?l:n>a?a:n;return it!==t&&(it=t,it>=yt&&!ft&&ti||it<=yt&&!ft&&!ti?(ft=!0,or(ft),gi&&li.play()):(it<yt&&ft&&ti||it>yt&&ft&&!ti)&&(ft=!1,or(ft),gi&&li.pause()),this.repaint()),this},this.getValue=function(){return it},this.setValueAnimated=function(n,t){n=parseFloat(n);var r=n<l?l:n>a?a:n,u=this,i;return it!==r&&(undefined!==ai&&ai.isPlaying&&ai.stop(),i=tf*Math.abs(r-it)/(a-l),i=Math.max(i,tf/5),ai=new Tween({},"",Tween.regularEaseInOut,it,r,i),ai.onMotionChanged=function(n){it=n.target._pos;it>=yt&&!ft&&ti||it<=yt&&!ft&&!ti?(ft=!0,or(ft),gi&&li.play()):(it<yt&&ft&&ti||it>yt&&ft&&!ti)&&(ft=!1,or(ft),gi&&li.pause());vi||(vi=!0,s(u.repaint))},t&&typeof t=="function"&&(ai.onMotionFinished=t),ai.start()),this},this.setFrameDesign=function(n){return vt({frame:!0}),lu=n,ot({frame:!0}),this.repaint(),this},this.setBackgroundColor=function(n){return vt({background:!0,led:!0}),yi=n,ot({background:!0,led:!0}),this.repaint(),this},this.setForegroundType=function(n){return vt({foreground:!0}),ku=n,ot({foreground:!0}),this.repaint(),this},this.setValueColor=function(n){return vt({value:!0}),sr=n,ot({value:!0}),this.repaint(),this},this.setLedColor=function(n){return vt({led:!0}),dr=n,ot({led:!0}),this.repaint(),this},this.setUserLedColor=function(n){return vt({userLed:!0}),nu=n,ot({userLed:!0}),this.repaint(),this},this.toggleUserLed=function(){return kt=kt===ui?ni:ui,this.repaint(),this},this.setUserLedOnOff=function(n){return kt=!0===n?ui:ni,this.repaint(),this},this.blinkUserLed=function(n){return n?cr||(de(!0),cr=!0):cr&&(clearInterval(ru),cr=!1),this},this.setLedVisible=function(n){return gr=!!n,this.repaint(),this},this.setUserLedVisible=function(n){return tu=!!n,this.repaint(),this},this.setLcdColor=function(n){return pi=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.setLcdDecimals=function(n){return pu=parseInt(n,10),this.repaint(),this},this.setSection=function(n){return ci=n,ot(),this.repaint(),this},this.setSectionActive=function(n){return su=n,ot(),this.repaint(),this},this.setGradient=function(n){return nr=n,ot(),this.repaint(),this},this.setGradientActive=function(n){return nf=n,ot(),this.repaint(),this},this.setMinValue=function(n){return l=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.getMinValue=function(){return l},this.setMaxValue=function(n){return a=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.getMaxValue=function(){return a},this.setThreshold=function(n){n=parseFloat(n);var t=n<l?l:n>a?a:n;return yt=t,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.setThresholdRising=function(n){return ti=!!n,ft=!ft,or(ft),this.repaint(),this},this.setTitleString=function(n){return hu=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.setUnitString=function(n){return cu=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.setTrend=function(n){return hf=n,this.repaint(),this},this.setTrendVisible=function(n){return iu=!!n,this.repaint(),this},this.setFractionalScaleDecimals=function(n){wu=parseInt(n,10);vt({background:!0});ot({background:!0});this.repaint()},this.setLabelNumberFormat=function(n){return bu=n,vt({background:!0}),ot({background:!0}),this.repaint(),this},this.repaint=function(){var s=(it-l)/(a-l)*ri,t,f=sr,n,i,e,o,r;for(ne||ot({frame:!0,background:!0,led:!0,userLed:!0,value:!0,trend:!0,foreground:!0}),k.clearRect(0,0,p,p),au&&k.drawImage(ir,0,0),k.drawImage(rr,0,0),n=0;n<=s;n+=5){if(t=sr,uu)e=l+n/ri*(a-l),o=nr.getEnd()-nr.getStart(),r=(e-l)/o,r=Math.max(Math.min(r,1),0),t=gt(nr.getColorAt(r).getRgbaColor());else if(lr)for(i=0;i<bi.length;i++)if(n>=bi[i].start&&n<bi[i].stop){t=bi[i].color;break}f.medium.getHexColor()!==t.medium.getHexColor()&&(ie(ou,t),f=t);k.save();k.translate(st,at);k.rotate(n*u+wi);k.translate(-st,-at);k.drawImage(ur,ce,le);k.restore()}if(yu&&be(k,it),gr&&k.drawImage(di,of,sf),tu&&k.drawImage(kt,ae,ve),iu)switch(hf.state){case"up":k.drawImage(bf,vr,yr);break;case"steady":k.drawImage(kf,vr,yr);break;case"down":k.drawImage(df,vr,yr);break;case"off":k.drawImage(gf,vr,yr)}du&&k.drawImage(fr,0,0);vi=!1},this.repaint(),this},tr=function(n,r){var ni;r=r||{};var ft=undefined===r.orientation?steelseries.Orientation.NORTH:r.orientation,l=undefined===r.size?0:r.size,y=undefined===r.minValue?0:r.minValue,tt=undefined===r.maxValue?y+100:r.maxValue,hu=undefined===r.niceScale?!0:r.niceScale,et=undefined===r.threshold?(tt-y)/2+y:r.threshold,ri=undefined===r.section?null:r.section,ui=undefined===r.area?null:r.area,ur=undefined===r.titleString?"":r.titleString,fr=undefined===r.unitString?"":r.unitString,er=undefined===r.frameDesign?steelseries.FrameDesign.METAL:r.frameDesign,or=undefined===r.frameVisible?!0:r.frameVisible,yt=undefined===r.backgroundColor?steelseries.BackgroundColor.DARK_GRAY:r.backgroundColor,sr=undefined===r.backgroundVisible?!0:r.backgroundVisible,pt=undefined===r.pointerType?steelseries.PointerType.TYPE1:r.pointerType,hr=undefined===r.pointerColor?steelseries.ColorDef.RED:r.pointerColor,cu=undefined===r.knobType?steelseries.KnobType.STANDARD_KNOB:r.knobType,gt=undefined===r.knobStyle?steelseries.KnobStyle.SILVER:r.knobStyle,gi=undefined===r.ledColor?steelseries.LedColor.RED_LED:r.ledColor,nr=undefined===r.ledVisible?!0:r.ledVisible,cr=undefined===r.thresholdVisible?!0:r.thresholdVisible,lt=undefined===r.thresholdRising?!0:r.thresholdRising,tr=undefined===r.minMeasuredValueVisible?!1:r.minMeasuredValueVisible,ir=undefined===r.maxMeasuredValueVisible?!1:r.maxMeasuredValueVisible,lr=undefined===r.foregroundType?steelseries.ForegroundType.TYPE1:r.foregroundType,ar=undefined===r.foregroundVisible?!0:r.foregroundVisible,lu=undefined===r.labelNumberFormat?steelseries.LabelNumberFormat.STANDARD:r.labelNumberFormat,si=undefined===r.playAlarm?!1:r.playAlarm,vr=undefined===r.alarmSound?!1:r.alarmSound,yr=undefined===r.fullScaleDeflectionTime?2.5:r.fullScaleDeflectionTime,c=w(n);l===0&&(l=Math.min(c.canvas.width,c.canvas.height));c.canvas.width=l;c.canvas.height=l;si&&vr!==!1&&(ni=o.createElement("audio"),ni.setAttribute("src",vr),ni.setAttribute("preload","auto"));var pr=steelseries.GaugeType.TYPE5,au=this,k=y,ot=tt,ht=y,it=l,rt=l,ut=!1,wr=0,ti,hi=!1,wi=y,bi=tt,ki=tt-y,ii=bi-wi,di=0,wt=0,ci=10,vu=10,yu=0,at=1.25*f,pu=1.25*f,fi=i,bt=fi/ii,br=it*.006,kr=it*1.17/2,dr=!1,rr=at+(k-y)*bt,u=it/2,ct=rt*.733644,wu=.455*it,bu=.51*rt,ku=function(){hu?(ki=v(tt-y,!1),wt=v(ki/(vu-1),!0),wi=Math.floor(y/wt)*wt,bi=Math.ceil(tt/wt)*wt,di=v(wt/(ci-1),!0),y=wi,tt=bi,ii=tt-y):(ki=tt-y,wi=y,bi=tt,ii=ki,di=1,wt=10);k=k<y?y:k>tt?tt:k;ot=ot<y?y:ot>tt?tt:ot;ht=ht<y?y:ht>tt?tt:ht;et=et<y?y:et>tt?tt:et;yu=0;at=1.25*f;pu=1.25*f;fi=i;bt=fi/ii;rr=at+(k-y)*bt},li=t(l,l),gr=li.getContext("2d"),ai=t(l,l),p=ai.getContext("2d"),ei=t(l*.093457,l*.093457),nu=ei.getContext("2d"),kt=t(l*.093457,l*.093457),tu=kt.getContext("2d"),oi=kt,iu=t(Math.ceil(l*.028037),Math.ceil(l*.028037)),ru=iu.getContext("2d"),uu=t(Math.ceil(l*.028037),Math.ceil(l*.028037)),fu=uu.getContext("2d"),vi=t(l,l),eu=vi.getContext("2d"),yi=t(l,l),ou=yi.getContext("2d"),du=function(n){"type5"===pr.type&&(n.save(),ft.type==="west"?(n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.44,rt*.8),n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.44,rt*.16)):ft.type==="east"?(n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.52,rt*.8),n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.52,rt*.16)):(n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.2-rt*.037383,rt*.446666),n.drawImage(a(Math.ceil(rt*.037383),steelseries.KnobType.STANDARD_KNOB,gt),it*.8,rt*.446666)),n.restore())},gu=function(){var t=o.createElement("canvas"),n,i;return t.width=Math.ceil(l*.046728),t.height=Math.ceil(t.width*.9),n=t.getContext("2d"),n.save(),i=n.createLinearGradient(0,.1,0,t.height*.9),i.addColorStop(0,"#520000"),i.addColorStop(.3,"#fc1d00"),i.addColorStop(.59,"#fc1d00"),i.addColorStop(1,"#520000"),n.fillStyle=i,n.beginPath(),n.moveTo(t.width*.5,.1),n.lineTo(t.width*.9,t.height*.9),n.lineTo(t.width*.1,t.height*.9),n.lineTo(t.width*.5,.1),n.closePath(),n.fill(),n.strokeStyle="#FFFFFF",n.stroke(),n.restore(),t},su=function(n,t,i,r,f){n.save();n.strokeStyle=r;n.fillStyle=r;n.lineWidth=it*.035;var e=fi/ii*t-fi/ii*y,o=e+(i-t)/(ii/fi);n.translate(u,ct);n.rotate(at);n.beginPath();f?(n.moveTo(0,0),n.arc(0,0,it*.365-n.lineWidth/2,e,o,!1)):n.arc(0,0,it*.365,e,o,!1);f?(n.moveTo(0,0),n.fill()):n.stroke();n.translate(-u,-ct);n.restore()},nf=function(n){var t,i;n.save();n.textAlign="left";n.textBaseline="middle";n.strokeStyle=yt.labelColor.getRgbaColor();n.fillStyle=yt.labelColor.getRgbaColor();n.font=.046728*it+"px "+e;t=n.measureText(ur).width;n.fillText(ur,(it-t)/2,rt*.4,it*.3);i=n.measureText(fr).width;n.fillText(fr,(it-i)/2,rt*.47,it*.2);n.restore()},tf=function(n,t){var l;yt.labelColor.setAlpha(1);n.save();steelseries.Orientation.WEST===ft&&(n.translate(u,u),n.rotate(-i),n.translate(-u,-u));steelseries.Orientation.EAST===ft&&(n.translate(u,u),n.rotate(i),n.translate(-u,-u));n.textAlign="center";n.textBaseline="middle";l=Math.ceil(it*.04);n.font=l+"px "+e;n.strokeStyle=yt.labelColor.getRgbaColor();n.fillStyle=yt.labelColor.getRgbaColor();n.translate(u,ct);n.rotate(at);for(var o=bt*di,a,r=y,f=ci-1,s=it*.44,p=it*.41,w=it*.415,b=it*.42,v=it*.48,h=it*.04,k=ci/2,d=parseFloat(tt.toFixed(2)),c=y;parseFloat(c.toFixed(2))<=d;c+=di){if(a=+o+i,f++,f===ci){n.lineWidth=1.5;n.beginPath();n.moveTo(s,0);n.lineTo(p,0);n.closePath();n.stroke();n.save();n.translate(v,0);n.rotate(a);switch(t.format){case"fractional":n.fillText(r.toFixed(2),0,0,h);break;case"scientific":n.fillText(r.toPrecision(2),0,0,h);break;case"standard":default:n.fillText(r.toFixed(0),0,0,h)}n.translate(-v,0);n.restore();r+=wt;f=0;n.rotate(o);continue}0==ci%2&&f===k?(n.lineWidth=1,n.beginPath(),n.moveTo(s,0),n.lineTo(w,0),n.closePath(),n.stroke()):(n.lineWidth=.5,n.beginPath(),n.moveTo(s,0),n.lineTo(b,0),n.closePath(),n.stroke());n.rotate(o)}n.translate(-u,-ct);n.restore()},vt=function(n){var t,r,e;n=n||{};var o=undefined===n.frame?!1:n.frame,f=undefined===n.background?!1:n.background,s=undefined===n.led?!1:n.led,c=undefined===n.pointer?!1:n.pointer,a=undefined===n.foreground?!1:n.foreground;if(dr=!0,ku(),o&&or&&d(gr,er,u,l/2,it,rt),f&&sr&&nt(p,yt,u,l/2,it,rt),s&&(nu.drawImage(h(Math.ceil(l*.093457),1,gi),0,0),tu.drawImage(h(Math.ceil(l*.093457),0,gi),0,0)),tr&&(ru.drawImage(b(Math.ceil(l*.028037),steelseries.ColorDef.BLUE.dark.getRgbaColor(),!0,!0),0,0),ru.restore()),ir&&(fu.drawImage(b(Math.ceil(l*.028037),steelseries.ColorDef.RED.medium.getRgbaColor(),!0),0,0),fu.restore()),f&&sr){if(du(p),null!==ri&&0<ri.length){p.save();steelseries.Orientation.WEST===ft?(p.translate(u,u),p.rotate(-i),p.translate(-u,-u)):steelseries.Orientation.EAST===ft&&(p.translate(u,u),p.rotate(i),p.translate(-u,-u));t=ri.length;do t--,su(p,ri[t].start,ri[t].stop,ri[t].color,!1);while(0<t);p.restore()}if(null!==ui&&0<ui.length){steelseries.Orientation.WEST===ft&&(p.translate(u,u),p.rotate(-i),p.translate(-u,-u));steelseries.Orientation.EAST===ft&&(p.translate(u,u),p.rotate(i),p.translate(-u,-u));r=ui.length;do r--,su(p,ui[r].start,ui[r].stop,ui[r].color,!0);while(0<r);p.restore()}tf(p,lu);nf(p)}cr&&(p.save(),steelseries.Orientation.WEST===ft&&(p.translate(u,u),p.rotate(-i),p.translate(-u,-u)),steelseries.Orientation.EAST===ft&&(p.translate(u,u),p.rotate(i),p.translate(-u,-u)),p.translate(u,ct),p.rotate(at+(et-y)*bt+i),p.translate(-u,-ct),p.drawImage(gu(),it*.475,rt*.32),p.restore());c&&st(eu,it*1.17,pt,hr,yt.labelColor);a&&ar&&(e=pt.type==="type15"||pt.type==="type16"?!1:!0,g(ou,lr,it,rt,e,cu,gt,pr,ft))},dt=function(n){n=n||{};var t=undefined===n.frame?!1:n.frame,i=undefined===n.background?!1:n.background,r=undefined===n.led?!1:n.led,u=undefined===n.pointer?!1:n.pointer,f=undefined===n.foreground?!1:n.foreground;t&&(li.width=l,li.height=l,gr=li.getContext("2d"));i&&(ai.width=l,ai.height=l,p=ai.getContext("2d"));r&&(ei.width=Math.ceil(l*.093457),ei.height=Math.ceil(l*.093457),nu=ei.getContext("2d"),kt.width=Math.ceil(l*.093457),kt.height=Math.ceil(l*.093457),tu=kt.getContext("2d"),oi=kt);u&&(vi.width=l,vi.height=l,eu=vi.getContext("2d"));f&&(yi.width=l,yi.height=l,ou=yi.getContext("2d"))},pi=function(n){n?wr=setInterval(rf,1e3):(clearInterval(wr),oi=kt)},rf=function(){nr&&(oi=oi===ei?kt:ei,hi||(hi=!0,s(au.repaint)))};return this.setValue=function(n){n=parseFloat(n);var t=n<y?y:n>tt?tt:n;return k!==t&&(k=t,k>ht&&(ht=k),k<ot&&(ot=k),k>=et&&!ut&&lt||k<=et&&!ut&&!lt?(ut=!0,pi(ut),si&&ni.play()):(k<et&&ut&&lt||k>et&&ut&&!lt)&&(ut=!1,pi(ut),si&&ni.pause()),this.repaint()),this},this.getValue=function(){return k},this.setValueAnimated=function(n,t){n=parseFloat(n);var r=n<y?y:n>tt?tt:n,u=this,i;return k!==r&&(undefined!==ti&&ti.isPlaying&&ti.stop(),i=yr*Math.abs(r-k)/(tt-y),i=Math.max(i,yr/5),ti=new Tween({},"",Tween.regularEaseInOut,k,r,i),ti.onMotionChanged=function(n){k=n.target._pos;k>=et&&!ut&&lt||k<=et&&!ut&&!lt?(ut=!0,pi(ut),si&&ni.play()):(k<et&&ut&&lt||k>et&&ut&&!lt)&&(ut=!1,pi(ut),si&&ni.pause());k>ht&&(ht=k);k<ot&&(ot=k);hi||(hi=!0,s(u.repaint))},t&&typeof t=="function"&&(ti.onMotionFinished=t),ti.start()),this},this.setMinValue=function(n){return y=parseFloat(n),dt({background:!0}),vt({background:!0}),this.repaint(),this},this.getMinValue=function(){return y},this.setMaxValue=function(n){return tt=parseFloat(n),dt({background:!0}),vt({background:!0}),this.repaint(),this},this.getMaxValue=function(){return tt},this.setMaxMeasuredValue=function(n){n=parseFloat(n);var t=n<y?y:n>tt?tt:n;return ht=t,this.repaint(),this},this.setMinMeasuredValue=function(n){n=parseFloat(n);var t=n<y?y:n>tt?tt:n;return ot=t,this.repaint(),this},this.resetMinMeasuredValue=function(){return ot=k,this.repaint(),this},this.resetMaxMeasuredValue=function(){return ht=k,this.repaint(),this},this.setMinMeasuredValueVisible=function(n){return tr=!!n,this.repaint(),this},this.setMaxMeasuredValueVisible=function(n){return ir=!!n,this.repaint(),this},this.setThresholdVisible=function(n){return cr=!!n,this.repaint(),this},this.setThresholdRising=function(n){return lt=!!n,ut=!ut,pi(ut),this.repaint(),this},this.setFrameDesign=function(n){return dt({frame:!0}),er=n,vt({frame:!0}),this.repaint(),this},this.setBackgroundColor=function(n){return dt({background:!0,pointer:pt.type==="type2"||pt.type==="type13"?!0:!1}),yt=n,vt({background:!0,pointer:pt.type==="type2"||pt.type==="type13"?!0:!1}),this.repaint(),this},this.setForegroundType=function(n){return dt({foreground:!0}),lr=n,vt({foreground:!0}),this.repaint(),this},this.setPointerType=function(n){return dt({pointer:!0,foreground:!0}),pt=n,vt({pointer:!0,foreground:!0}),this.repaint(),this},this.setPointerColor=function(n){return dt({pointer:!0}),hr=n,vt({pointer:!0}),this.repaint(),this},this.setLedColor=function(n){return dt({led:!0}),gi=n,vt({led:!0}),this.repaint(),this},this.setLedVisible=function(n){return nr=!!n,this.repaint(),this},this.repaint=function(){dr||vt({frame:!0,background:!0,led:!0,pointer:!0,foreground:!0});c.clearRect(0,0,l,l);c.save();or&&c.drawImage(li,0,0);c.drawImage(ai,0,0);nr&&c.drawImage(oi,wu,bu);steelseries.Orientation.WEST===ft&&(c.translate(u,u),c.rotate(-i),c.translate(-u,-u));steelseries.Orientation.EAST===ft&&(c.translate(u,u),c.rotate(i),c.translate(-u,-u));tr&&(c.save(),c.translate(u,ct),c.rotate(at+i+(ot-y)*bt),c.translate(-u,-ct),c.drawImage(iu,c.canvas.width*.4865,c.canvas.height*.27),c.restore());ir&&(c.save(),c.translate(u,ct),c.rotate(at+i+(ht-y)*bt),c.translate(-u,-ct),c.drawImage(uu,c.canvas.width*.4865,c.canvas.height*.27),c.restore());rr=at+i+(k-y)*bt;c.save();c.translate(u,ct);c.rotate(rr);c.shadowColor="rgba(0, 0, 0, 0.8)";c.shadowOffsetX=c.shadowOffsetY=br;c.shadowBlur=br*2;c.translate(-kr,-kr);c.drawImage(vi,0,0);c.restore();ar&&(steelseries.Orientation.WEST===ft?(c.translate(u,u),c.rotate(i),c.translate(-u,-u)):steelseries.Orientation.EAST===ft&&(c.translate(u,u),c.rotate(-i),c.translate(-u,-u)),c.drawImage(yi,0,0));c.restore();hi=!1},this.repaint(),this},ir=function(n,r){var c,u,gt;r=r||{};var p=undefined===r.gaugeType?steelseries.GaugeType.TYPE1:r.gaugeType,g=undefined===r.width?0:r.width,nt=undefined===r.height?0:r.height,f=undefined===r.minValue?0:r.minValue,l=undefined===r.maxValue?f+100:r.maxValue,fu=undefined===r.niceScale?!0:r.niceScale,it=undefined===r.threshold?(l-f)/2+f:r.threshold,gi=undefined===r.titleString?"":r.titleString,nr=undefined===r.unitString?"":r.unitString,ar=undefined===r.frameDesign?steelseries.FrameDesign.METAL:r.frameDesign,vr=undefined===r.frameVisible?!0:r.frameVisible,rt=undefined===r.backgroundColor?steelseries.BackgroundColor.DARK_GRAY:r.backgroundColor,yr=undefined===r.backgroundVisible?!0:r.backgroundVisible,ti=undefined===r.valueColor?steelseries.ColorDef.RED:r.valueColor,dt=undefined===r.lcdColor?steelseries.LcdColor.STANDARD:r.lcdColor,yi=undefined===r.lcdVisible?!0:r.lcdVisible,pr=undefined===r.lcdDecimals?2:r.lcdDecimals,eu=undefined===r.digitalFont?!1:r.digitalFont,ui=undefined===r.ledColor?steelseries.LedColor.RED_LED:r.ledColor,tr=undefined===r.ledVisible?!0:r.ledVisible,wr=undefined===r.thresholdVisible?!0:r.thresholdVisible,wt=undefined===r.thresholdRising?!0:r.thresholdRising,ir=undefined===r.minMeasuredValueVisible?!1:r.minMeasuredValueVisible,rr=undefined===r.maxMeasuredValueVisible?!1:r.maxMeasuredValueVisible,ou=undefined===r.labelNumberFormat?steelseries.LabelNumberFormat.STANDARD:r.labelNumberFormat,br=undefined===r.foregroundVisible?!0:r.foregroundVisible,fi=undefined===r.playAlarm?!1:r.playAlarm,kr=undefined===r.alarmSound?!1:r.alarmSound,dr=undefined===r.fullScaleDeflectionTime?2.5:r.fullScaleDeflectionTime,d=w(n);g===0&&(g=d.canvas.width);nt===0&&(nt=d.canvas.height);d.canvas.width=g;d.canvas.height=nt;c=g;u=nt;fi&&kr!==!1&&(gt=o.createElement("audio"),gt.setAttribute("src",kr),gt.setAttribute("preload","auto"));var su=this,y=f,ft=l,ot=f;p.type!=="type1"&&p.type!=="type2"&&(p=steelseries.GaugeType.TYPE1);var ni,k=!1,ei=!1,gr=0,a=g<=nt,ur,fr,ct=Math.round((a?nt:g)*.05),st=Math.round((a?g:nt)*.05),er,or;a?(ur=c/2-ct/2,fr=(p.type==="type1"?.053:.038)*u,er=Math.floor(u/22)+"px "+e,or=Math.floor(u/22)+"px "+et):(ur=.89*c,fr=u/2-ct/2,er=Math.floor(u/10)+"px "+e,or=Math.floor(u/10)+"px "+et);var nu=!1,pi=f,wi=l,bi=l-f,tu=wi-pi,ki=0,bt=0,oi=10,hu=10,cu=function(){fu?(bi=v(l-f,!1),bt=v(bi/(hu-1),!0),pi=Math.floor(f/bt)*bt,wi=Math.ceil(l/bt)*bt,ki=v(bt/(oi-1),!0),f=pi,l=wi,tu=l-f):(bi=l-f,pi=f,wi=l,tu=bi,ki=1,bt=10);y=y<f?f:y>l?l:y;ft=ft<f?f:ft>l?l:ft;ot=ot<f?f:ot>l?l:ot;it=it<f?f:it>l?l:it},si=t(g,nt),iu=si.getContext("2d"),hi=t(g,nt),ut=hi.getContext("2d"),di,ii=t(ct,ct),sr=ii.getContext("2d"),kt=t(ct,ct),hr=kt.getContext("2d"),ri=kt,ci=t(st,st),ru=ci.getContext("2d"),li=t(st,st),uu=li.getContext("2d"),ai=t(g,nt),cr=ai.getContext("2d"),lu=function(n,t,i){n.save();n.textAlign="right";n.textBaseline="middle";n.strokeStyle=dt.textColor;n.fillStyle=dt.textColor;(dt===steelseries.LcdColor.STANDARD||dt===steelseries.LcdColor.STANDARD_GREEN)&&(n.shadowColor="gray",i?(n.shadowOffsetX=u*.003,n.shadowOffsetY=u*.003,n.shadowBlur=u*.004):(n.shadowOffsetX=u*.007,n.shadowOffsetY=u*.007,n.shadowBlur=u*.009));var r,f,e;n.font=eu?or:er;i?(r=(c-c*.571428)/2+c*.571428-2,f=u*.88+1+(u*.055-2)/2,e=c*.7-2):(r=c*.695+c*.18-2,f=u*.22+1+(u*.15-2)/2,e=u*.22-2);n.fillText(t.toFixed(pr),r,f,e);n.restore()},au=function(n){var i=o.createElement("canvas"),t=i.getContext("2d"),r;return i.height=i.width=st,t.save(),r=t.createLinearGradient(0,.1,0,i.height*.9),r.addColorStop(0,"#520000"),r.addColorStop(.3,"#fc1d00"),r.addColorStop(.59,"#fc1d00"),r.addColorStop(1,"#520000"),t.fillStyle=r,n?(t.beginPath(),t.moveTo(.1,i.height*.5),t.lineTo(i.width*.9,.1),t.lineTo(i.width*.9,i.height*.9),t.closePath()):(t.beginPath(),t.moveTo(.1,.1),t.lineTo(i.width*.9,.1),t.lineTo(i.width*.5,i.height*.9),t.closePath()),t.fill(),t.strokeStyle="#FFFFFF",t.stroke(),t.restore(),i},vu=function(n,t,i){var e,ut;rt.labelColor.setAlpha(1);n.save();n.textBaseline="middle";e=c*.1;n.strokeStyle=rt.labelColor.getRgbaColor();n.fillStyle=rt.labelColor.getRgbaColor();var o=f,h=oi-1,a,r,s,b,v,y,w=1,k,d,g,nt,tt,it;for(i?(k=.34*c,d=.36*c,g=.33*c,nt=.36*c,tt=.32*c,it=.36*c,n.textAlign="right",s=0,b=u*.12864,v=0,y=p.type==="type1"?u*.856796-u*.12864:u*.7475-u*.12864,w=y/(l-f)):(k=.65*u,d=.63*u,g=.66*u,nt=.63*u,tt=.67*u,it=