atome 0.5.7.5.9 → 0.5.7.6.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.5.9
4
+ version: 0.5.7.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Eric Godard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -248,20 +248,6 @@ dependencies:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
250
  version: 2.2.0
251
- - !ruby/object:Gem::Dependency
252
- name: ruby2js
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
256
- - !ruby/object:Gem::Version
257
- version: '5.0'
258
- type: :runtime
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - "~>"
263
- - !ruby/object:Gem::Version
264
- version: '5.0'
265
251
  - !ruby/object:Gem::Dependency
266
252
  name: rufus-scheduler
267
253
  requirement: !ruby/object:Gem::Requirement
@@ -668,6 +654,7 @@ files:
668
654
  - vendor/assets/application/examples/text.rb
669
655
  - vendor/assets/application/examples/text_align.rb
670
656
  - vendor/assets/application/examples/tick.rb
657
+ - vendor/assets/application/examples/timeline.rb
671
658
  - vendor/assets/application/examples/to_percent.rb
672
659
  - vendor/assets/application/examples/to_px.rb
673
660
  - vendor/assets/application/examples/tools.rb
@@ -781,6 +768,7 @@ files:
781
768
  - vendor/assets/src/js/third_parties/Three/build/three.module.min.js
782
769
  - vendor/assets/src/js/third_parties/Three/build/three.webgpu.min.js
783
770
  - vendor/assets/src/js/third_parties/Three/jsm/controls/OrbitControls.js
771
+ - vendor/assets/src/js/third_parties/a_pianoroll.js
784
772
  - vendor/assets/src/js/third_parties/browser.script.iife.min.js
785
773
  - vendor/assets/src/js/third_parties/codemirror.min.js
786
774
  - vendor/assets/src/js/third_parties/fabric.min.js
@@ -800,7 +788,6 @@ files:
800
788
  - vendor/assets/src/js/third_parties/w3color.js
801
789
  - vendor/assets/src/js/third_parties/wad.min.js
802
790
  - vendor/assets/src/js/third_parties/wavesurfer.min.js
803
- - vendor/assets/src/js/third_parties/webaudio-pianoroll.min.js
804
791
  - vendor/assets/src/js/third_parties/zim.min.js
805
792
  - vendor/assets/src/medias/audios/audio_missing.wav
806
793
  - vendor/assets/src/medias/audios/clap.wav
@@ -944,6 +931,7 @@ files:
944
931
  - vendor/assets/src/medias/images/utils/full_keyboard.svg
945
932
  - vendor/assets/src/medias/images/utils/keyboard.svg
946
933
  - vendor/assets/src/medias/images/utils/notes.svg
934
+ - vendor/assets/src/medias/images/waveform.png
947
935
  - vendor/assets/src/medias/texts/lorem.txt
948
936
  - vendor/assets/src/medias/utils/infos/color.rb
949
937
  - vendor/assets/src/medias/utils/infos/width.rb
@@ -1,66 +0,0 @@
1
- customElements.define("webaudio-pianoroll",class t extends HTMLElement{constructor(){super()}defineprop(){let t=this.module.properties;for(let e in t){let i=t[e];this["_"+e]=this.getAttr(e,i.value),Object.defineProperty(this,e,{get:()=>this["_"+e],set:t=>{this["_"+e]=t,"function"==typeof this[i.observer]&&this[i.observer]()}})}}connectedCallback(){let t;t=this,this.module={is:"webaudio-pianoroll",properties:{width:{type:Number,value:640,observer:"layout"},height:{type:Number,value:320,observer:"layout"},timebase:{type:Number,value:16,observer:"layout"},editmode:{type:String,value:"dragpoly"},xrange:{type:Number,value:16,observer:"layout"},yrange:{type:Number,value:16,observer:"layout"},xoffset:{type:Number,value:0,observer:"layout"},yoffset:{type:Number,value:60,observer:"layout"},grid:{type:Number,value:4},snap:{type:Number,value:1},wheelzoom:{type:Number,value:0},wheelzoomx:{type:Number,value:0},wheelzoomy:{type:Number,value:0},xscroll:{type:Number,value:0},yscroll:{type:Number,value:0},gridnoteratio:{type:Number,value:.5,observer:"updateTimer"},xruler:{type:Number,value:24,observer:"layout"},yruler:{type:Number,value:24,observer:"layout"},octadj:{type:Number,value:-1},cursor:{type:Number,value:0,observer:"redrawMarker"},markstart:{type:Number,value:0,observer:"redrawMarker"},markend:{type:Number,value:16,observer:"redrawMarker"},defvelo:{type:Number,value:100},collt:{type:String,value:"#ccc"},coldk:{type:String,value:"#aaa"},colgrid:{type:String,value:"#666"},colnote:{type:String,value:"#f22"},colnotesel:{type:String,value:"#0f0"},colnoteborder:{type:String,value:"#000"},colnoteselborder:{type:String,value:"#fff"},colrulerbg:{type:String,value:"#666"},colrulerfg:{type:String,value:"#fff"},colrulerborder:{type:String,value:"#000"},colselarea:{type:String,value:"rgba(0,0,0,0.3)"},bgsrc:{type:String,value:null,observer:"layout"},cursorsrc:{type:String,value:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj4NCjxwYXRoIGZpbGw9InJnYmEoMjU1LDEwMCwxMDAsMC44KSIgZD0iTTAsMSAyNCwxMiAwLDIzIHoiLz4NCjwvc3ZnPg0K"},cursoroffset:{type:Number,value:0},markstartsrc:{type:String,value:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4NCjxwYXRoIGZpbGw9IiMwYzAiIGQ9Ik0wLDEgMjQsMSAwLDIzIHoiLz4NCjwvc3ZnPg0K"},markstartoffset:{type:Number,value:0},markendsrc:{type:String,value:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4NCjxwYXRoIGZpbGw9IiMwYzAiIGQ9Ik0wLDEgMjQsMSAyNCwyMyB6Ii8+DQo8L3N2Zz4NCg=="},markendoffset:{type:Number,value:-24},kbsrc:{type:String,value:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSI0ODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cGF0aCBmaWxsPSIjZmZmIiBzdHJva2U9IiMwMDAiIGQ9Ik0wLDAgaDI0djQ4MGgtMjR6Ii8+CjxwYXRoIGZpbGw9IiMwMDAiIGQ9Ik0wLDQwIGgxMnY0MGgtMTJ6IE0wLDEyMCBoMTJ2NDBoLTEyeiBNMCwyMDAgaDEydjQwaC0xMnogTTAsMzIwIGgxMnY0MGgtMTJ6IE0wLDQwMCBoMTJ2NDBoLTEyeiIvPgo8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIGQ9Ik0wLDYwIGgyNCBNMCwxNDAgaDI0IE0wLDIyMCBoMjQgTTAsMjgwIGgyNCBNMCwzNDAgaDI0IE0wLDQyMCBoMjQiLz4KPC9zdmc+Cg==",observer:"layout"},kbwidth:{type:Number,value:40},loop:{type:Number,value:0},preload:{type:Number,value:1},tempo:{type:Number,value:120,observer:"updateTimer"},enable:{type:Boolean,value:!0}}},this.defineprop(),t.innerHTML=`<style>
2
- .pianoroll{
3
- background:#ccc;
4
- }
5
- :host {
6
- user-select: none;
7
- display: inline-block;
8
- font-family: sans-serif;
9
- font-size: 11px;
10
- padding:0;
11
- margin:0;
12
- }
13
- #wac-body {
14
- position: relative;
15
- margin:0;
16
- padding:0;
17
- width: 100%;
18
- height: 100%;
19
- overflow: hidden;
20
- }
21
- #wac-pianoroll {
22
- cursor: pointer;
23
- margin:0;
24
- padding:0;
25
- width: 100%;
26
- height: 100%;
27
- background-size:100% calc(100%*12/16);
28
- background-position:left bottom;
29
- }
30
- #wac-menu {
31
- display:none;
32
- position:absolute;
33
- top:0px;
34
- left:0px;
35
- background:#eef;
36
- color:#000;
37
- padding:2px 10px;
38
- border:1px solid #66f;
39
- border-radius: 4px;
40
- cursor:pointer;
41
- }
42
- .marker{
43
- position: absolute;
44
- left:0px;
45
- top:0px;
46
- cursor:ew-resize;
47
- }
48
- #wac-kb{
49
- position:absolute;
50
- left:0px;
51
- top:0px;
52
- width:100px;
53
- height:100%;
54
- background: repeat-y;
55
- background-size:100% calc(100%*12/16);
56
- background-position:left bottom;
57
- }
58
- </style>
59
- <div class="wac-body" id="wac-body" touch-action="none">
60
- <canvas id="wac-pianoroll" touch-action="none" tabindex="0"></canvas>
61
- <div id="wac-kb"></div>
62
- <img id="wac-markstart" class="marker" src="${this.markstartsrc}"/>
63
- <img id="wac-markend" class="marker" src="${this.markendsrc}"/>
64
- <img id="wac-cursor" class="marker" src="${this.cursorsrc}"/>
65
- <div id="wac-menu">Delete</div>
66
- </div>`,this.sortSequence=function(){this.sequence.sort((t,e)=>t.t-e.t)},this.findNextEv=function(t){for(let e=0;e<this.sequence.length;++e){let i=this.sequence[e];if(i.t>=this.markend)return{t1:t,n2:this.markend,dt:this.markend-t,i:-1};if(i.t>=t)return{t1:t,t2:i.t,dt:i.t-t,i:e}}return{t1:t,t2:this.markend,dt:this.markend-t,i:-1}},this.locate=function(t){this.cursor=t},this.updateTimer=function(){this.tick2time=240/this.tempo/this.timebase},this.play=function(t,e,i){if(void 0!==i&&this.locate(i),null!=this.timer)return;this.actx=t,this.playcallback=e,this.timestack=[],this.time0=this.time1=this.actx.currentTime+.1,this.tick0=this.tick1=this.cursor,this.tick2time=240/this.tempo/this.timebase;let s=this.findNextEv(this.cursor);this.index1=s.i,this.timestack.push([0,this.cursor,0]),this.timestack.push([this.time0,this.cursor,this.tick2time]),this.time1+=s.dt*this.tick2time,s.i<0?this.timestack.push([this.time1,this.markstart,this.tick2time]):this.timestack.push([this.time1,s.t1,this.tick2time]),this.timer=setInterval((function t(){let e=this.actx.currentTime;for(;this.timestack.length>1&&e>=this.timestack[1][0];)this.timestack.shift();for(this.cursor=this.timestack[0][1]+(e-this.timestack[0][0])/this.timestack[0][2],this.redrawMarker();e+this.preload>=this.time1;){this.time0=this.time1,this.tick0=this.tick1;let i=this.sequence[this.index1];if(!i||i.t>=this.markend){this.timestack.push([this.time1,this.markstart,this.tick2time]);let s=this.findNextEv(this.markstart);this.time1+=s.dt*this.tick2time,this.index1=s.i}else{this.tick1=i.t,this.timestack.push([this.time1,i.t,this.tick2time]);let h=Math.min(i.t+i.g,this.markend)-i.t;("gridmono"==this.editmode||"gridpoly"==this.editmode)&&(h*=this.gridnoteratio);let r={t:this.time1,g:this.time1+h*this.tick2time,n:i.n};if(this.playcallback&&this.playcallback(r),(i=this.sequence[++this.index1])&&!(i.t>=this.markend))this.time1+=(i.t-this.tick1)*this.tick2time;else{this.time1+=(this.markend-this.tick1)*this.tick2time;let n=this.findNextEv(this.markstart);this.timestack.push([this.time1,this.markstart,this.tick2time]),this.time1+=n.dt*this.tick2time,this.index1=n.i}}}}).bind(this),25)},this.stop=function(){this.timer&&clearInterval(this.timer),this.timer=null},this.setMMLString=function(t){this.sequence=[];let e,i,s,h,r,n,a,o,l={s:t,i:e,tb:this.timebase};function c(t){for(var e=0;t.s[t.i]>="0"&&t.s[t.i]<="9";)e=10*e+parseInt(t.s[t.i]),++t.i;return e}function d(t){var e=c(t);0==e&&(e=n);for(var i=e=t.tb/e;"."==t.s[t.i];)++t.i,e+=i>>=1;return e}function g(t){switch(t.s[t.i]){case"c":case"C":s=0;break;case"d":case"D":s=2;break;case"e":case"E":s=4;break;case"f":case"F":s=5;break;case"g":case"G":s=7;break;case"a":case"A":s=9;break;case"b":case"B":s=11;break;default:s=-1}if(++t.i,s<0)return -1;for(;;){switch(t.s[t.i]){case"-":--s;break;case"+":case"#":++s;break;default:return s}++t.i}}for(r=4,n=8,h=0,a=0,o=null,l.i=0;l.i<l.s.length;){switch(l.s[l.i]){case">":++l.i,++r,s=-1,i=0;break;case"<":++l.i,--r,s=-1,i=0;break;case"&":case"^":++l.i,a=1,s=-1,i=0;break;case"t":case"T":++l.i,s=-1,i=0,this.tempo=c(l);break;case"o":case"O":++l.i,s=-1,i=0,r=c(l);break;case"l":case"L":++l.i,s=-1,i=0,n=c(l);break;case"r":case"R":++l.i,s=-1,i=d(l);break;default:i=(s=g(l))>=0?d(l):0}s>=0&&(s=(r-this.octadj)*12+s,a&&o&&o.n==s?(o.g+=i,a=0):this.sequence.push(o={t:h,n:s,g:i,f:0})),h+=i}this.redraw()},this.getMMLString=function(){function t(t,e,i){console.log("*****> "+t+" : "+e+" : "+i+" : ");var s="",h=[[960,"1"],[840,"2.."],[720,"2."],[480,"2"],[420,"4.."],[360,"4."],[240,"4"],[210,"8.."],[180,"8."],[120,""],[105,"16.."],[90,"16."],[60,"16"],[45,"32."],[30,"32"],[16,"60"],[15,"64"],[8,"120"],[4,"240"],[2,"480"],[1,"960"]];for(e=960*e/i;e>0;)for(let r=0;r<h.length;++r)for(;e>=h[r][0];)e-=h[r][0],s+="&"+t+h[r][1];return s.substring(1)}var e,i="t"+this.tempo+"o4l8",s=0,h=5,r=["c","d-","d","e-","e","f","g-","g","a-","a","b-","b"];for(let n=0;n<this.sequence.length;++n){var a=this.sequence[n];if(a.t>s){var o=a.t-s;i+=t("r",o,this.timebase),s=a.t}var e=a.n;(e<12*h||e>=12*h+12)&&(i+="o"+((h=e/12|0)+this.octadj)),e=r[e%12];var o=a.g;if(n+1<this.sequence.length){var l=this.sequence[n+1];l.t<a.t+o?(o=l.t-a.t,s=l.t):s=a.t+a.g}else s=a.t+a.g;i+=t(e,o,this.timebase)}return i},this.hitTest=function(t){let e={t:0,n:0,i:-1,m:" "},i=this.sequence.length;if(t.t==this.menu)return e.m="m",e;if(e.t=this.xoffset+(t.x-this.yruler-this.kbwidth)/this.swidth*this.xrange,e.n=this.yoffset-(t.y-this.height)/this.steph,t.y>=this.height||t.x>=this.width)return e;if(t.y<this.xruler)return e.m="x",e;if(t.x<this.yruler+this.kbwidth)return e.m="y",e;for(let s=0;s<i;++s){let h=this.sequence[s];if((0|e.n)==h.n){if(h.f&&Math.abs(h.t-e.t)*this.stepw<8)return e.m="B",e.i=s,e;if(h.f&&Math.abs(h.t+h.g-e.t)*this.stepw<8)return e.m="E",e.i=s,e;if(e.t>=h.t&&e.t<h.t+h.g)return e.i=s,this.sequence[s].f?e.m="N":e.m="n",e}}return e.m="s",e},this.addNote=function(t,e,i,s,h){if(t>=0&&e>=0&&e<128){let r={t:t,c:144,n:e,g:i,v:s,f:h};return this.sequence.push(r),this.sortSequence(),this.redraw(),r}return null},this.selAreaNote=function(t,e,i,s){let h,r=0,n=this.sequence[r];for(i>s&&(h=i,i=s,s=h),t>e&&(h=t,t=e,e=h);n;)n.t>=t&&n.t<e&&n.n>=i&&n.n<=s?n.f=1:n.f=0,n=this.sequence[++r]},this.delNote=function(t){this.sequence.splice(t,1),this.redraw()},this.delAreaNote=function(t,e,i){let s=this.sequence.length;for(let h=s-1;h>=0;--h){let r=this.sequence[h];void 0!==i&&i!=h&&(t<=r.t&&t+e>=r.t+r.g?this.sequence.splice(h,1):t<=r.t&&t+e>r.t&&t+e<r.t+r.g?(r.g=r.t+r.g-(t+e),r.t=t+e):t>=r.t&&t<r.t+r.g&&t+e>=r.t+r.g?r.g=t-r.t:t>r.t&&t+e<r.t+r.g&&(this.addNote(t+e,r.n,r.t+r.g-t-e,this.defvelo),r.g=t-r.t))}},this.delSelectedNote=function(){let t=this.sequence.length;for(let e=t-1;e>=0;--e){let i=this.sequence[e];i.f&&this.sequence.splice(e,1)}},this.moveSelectedNote=function(t,e){let i=this.sequence.length;for(let s=0;s<i;++s){let h=this.sequence[s];h.f&&h.ot+t<0&&(t=-h.ot)}for(let r=0;r<i;++r){let n=this.sequence[r];n.f&&(n.t=((n.ot+t)/this.snap+.5|0)*this.snap,n.n=n.on+e)}},this.clearSel=function(){let t=this.sequence.length;for(let e=0;e<t;++e)this.sequence[e].f=0},this.selectedNotes=function(){let t=[];for(let e=this.sequence.length-1;e>=0;--e){let i=this.sequence[e];i.f&&t.push({i:e,ev:i,t:i.t,g:i.g})}return t},this.editDragDown=function(t){let e=this.hitTest(t),i;if("N"==e.m){i=this.sequence[e.i],this.dragging={o:"D",m:"N",i:e.i,t:e.t,n:i.n,dt:e.t-i.t};for(let s=0,h=this.sequence.length;s<h;++s)(i=this.sequence[s]).f&&(i.on=i.n,i.ot=i.t,i.og=i.g);this.redraw()}else if("n"==e.m)i=this.sequence[e.i],this.clearSel(),i.f=1,this.redraw();else if("E"==e.m){let r=this.sequence[e.i];this.dragging={o:"D",m:"E",i:e.i,t:r.t,g:r.g,ev:this.selectedNotes()}}else if("B"==e.m){let n=this.sequence[e.i];this.dragging={o:"D",m:"B",i:e.i,t:n.t,g:n.g,ev:this.selectedNotes()}}else if("s"==e.m&&e.t>=0){this.clearSel();var a=(e.t/this.snap|0)*this.snap;this.sequence.push({t:a,n:0|e.n,g:1,f:1}),this.dragging={o:"D",m:"E",i:this.sequence.length-1,t:a,g:1,ev:[{t:a,g:1,ev:this.sequence[this.sequence.length-1]}]},this.redraw()}},this.editDragMove=function(t){let e=this.hitTest(t),i;if("D"==this.dragging.o)switch(this.dragging.m){case"E":if(this.dragging.ev){let s=(Math.max(0,e.t)/this.snap+.9|0)*this.snap-this.dragging.t-this.dragging.g,h=this.dragging.ev;for(let r=h.length-1;r>=0;--r){let n=h[r].ev;n.g=h[r].g+s,n.g<=0&&(n.g=1),"dragmono"==this.editmove&&this.delAreaNote(n.t,n.g)}}this.redraw();break;case"B":if(this.dragging.ev){let a=(Math.max(0,e.t)/this.snap+.9|0)*this.snap-this.dragging.t,o=this.dragging.ev;for(let l=o.length-1;l>=0;--l){let c=o[l].ev;c.t=o[l].t+a,c.g=o[l].g-a,c.g<=0&&(c.g=1),"dragmono"==this.editmove&&this.delAreaNote(c.t,c.g)}}this.redraw();break;case"N":i=this.sequence[this.dragging.i],this.moveSelectedNote(e.t-this.dragging.t|0,(0|e.n)-this.dragging.n),this.redraw()}},this.editGridDown=function(t){let e=this.hitTest(t);if("n"==e.m)this.delNote(e.i),this.dragging={o:"G",m:"0"};else if("s"==e.m&&e.t>=0){let i=Math.floor(e.t);"gridmono"==this.editmode&&this.delAreaNote(i,1,e.i),this.addNote(i,0|e.n,1,this.defvelo),this.dragging={o:"G",m:"1"}}},this.editGridMove=function(t){let e=this.hitTest(t);if("G"==this.dragging.o)switch(this.dragging.m){case"1":let i=Math.floor(e.t);"s"==e.m&&("gridmono"==this.editmode&&this.delAreaNote(i,1,e.i),this.addNote(i,0|e.n,1,this.defvelo));break;case"0":"n"==e.m&&this.delNote(e.i)}},this.setListener=function(t,e){this.bindcontextmenu=this.contextmenu.bind(this),this.bindpointermove=this.pointermove.bind(this),this.bindcancel=this.cancel.bind(this),t.addEventListener("mousedown",this.pointerdown.bind(this),!0),t.addEventListener("touchstart",this.pointerdown.bind(this),!1),e&&(t.addEventListener("mouseover",this.pointerover.bind(this),!1),t.addEventListener("mouseout",this.pointerout.bind(this),!1))},this.ready=function(){this.body=t.children[1],this.elem=t.childNodes[2],this.proll=this.elem.children[0],this.canvas=this.elem.children[0],this.kb=this.elem.children[1],this.ctx=this.canvas.getContext("2d"),this.kbimg=this.elem.children[1],this.markstartimg=this.elem.children[2],this.markendimg=this.elem.children[3],this.cursorimg=this.elem.children[4],this.menu=this.elem.children[5],this.rcMenu={x:0,y:0,width:0,height:0},this.lastx=0,this.lasty=0,this.canvas.addEventListener("mousemove",this.mousemove.bind(this),!1),this.canvas.addEventListener("keydown",this.keydown.bind(this),!1),this.canvas.addEventListener("DOMMouseScroll",this.wheel.bind(this),!1),this.canvas.addEventListener("mousewheel",this.wheel.bind(this),!1),this.setListener(this.canvas,!0),this.setListener(this.markendimg,!0),this.setListener(this.markstartimg,!0),this.setListener(this.cursorimg,!0),this.setListener(this.menu,!1),this.sequence=[],this.dragging={o:null},this.kbimg.style.height=this.sheight+"px",this.kbimg.style.backgroundSize=12*this.steph+"px",this.layout(),this.initialized=1,this.redraw()},this.setupImage=function(){},this.preventScroll=function(t){t.preventDefault&&t.preventDefault()},this.getPos=function(t){let e=null;return t&&(e=t.target,this.lastx=t.clientX-this.rcTarget.left,this.lasty=t.clientY-this.rcTarget.top),this.lastx>=this.rcMenu.x&&this.lastx<this.rcMenu.x+this.rcMenu.width&&this.lasty>=this.rcMenu.y&&this.lasty<this.rcMenu.y+this.rcMenu.height&&(e=this.menu),{t:e,x:this.lastx,y:this.lasty}},this.contextmenu=function(t){return t.stopPropagation(),t.preventDefault(),window.removeEventListener("contextmenu",this.bindcontextmenu),!1},this.keydown=function(t){46===t.keyCode&&(this.delSelectedNote(),this.redraw())},this.popMenu=function(t){let e=this.menu.style;e.display="block",e.top=t.y+8+"px",e.left=t.x+8+"px",this.rcMenu=this.menu.getBoundingClientRect()},this.longtapcountup=function(){if(++this.longtapcount>=18)switch(clearInterval(this.longtaptimer),this.downht.m){case"N":case"B":case"E":this.popMenu(this.downpos),this.dragging={o:"m"}}},this.pointerdown=function(t){let e;if(this.enable){if(e=t.touches?t.touches[0]:t,this.rcTarget=this.canvas.getBoundingClientRect(),this.downpos=this.getPos(e),this.downht=this.hitTest(this.downpos),console.log("======> "+this.downht),this.longtapcount=0,this.longtaptimer=setInterval(this.longtapcountup.bind(this),100),window.addEventListener("touchmove",this.bindpointermove,!1),window.addEventListener("mousemove",this.bindpointermove,!1),window.addEventListener("touchend",this.bindcancel),window.addEventListener("mouseup",this.bindcancel),window.addEventListener("contextmenu",this.bindcontextmenu),2==e.button||e.ctrlKey){switch(this.downht.m){case"N":case"B":case"E":this.popMenu(this.downpos),this.dragging={o:"m"};break;default:("dragmono"==this.editmode||"dragpoly"==this.editmode)&&(this.dragging={o:"A",p:this.downpos,p2:this.downpos,t1:this.downht.t,n1:this.downht.n})}return t.preventDefault(),t.stopPropagation(),this.canvas.focus(),!1}switch(e.target){case this.markendimg:return this.dragging={o:"E",x:this.downpos.x,m:this.markend},t.preventDefault(),t.stopPropagation(),!1;case this.markstartimg:return this.dragging={o:"S",x:this.downpos.x,m:this.markstart},t.preventDefault(),t.stopPropagation(),!1;case this.cursorimg:return this.dragging={o:"P",x:this.downpos.x,m:this.cursor},t.preventDefault(),t.stopPropagation(),!1}switch(this.dragging={o:null,x:this.downpos.x,y:this.downpos.y,offsx:this.xoffset,offsy:this.yoffset},this.canvas.focus(),this.editmode){case"gridpoly":case"gridmono":this.editGridDown(this.downpos);break;case"dragpoly":case"dragmono":this.editDragDown(this.downpos)}return this.press=1,t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1}},this.mousemove=function(t){if(null==this.dragging.o){this.rcTarget=this.canvas.getBoundingClientRect();let e=this.getPos(t),i=this.hitTest(e);switch(i.m){case"E":this.canvas.style.cursor="e-resize";break;case"B":this.canvas.style.cursor="w-resize";break;case"N":this.canvas.style.cursor="move";break;case"n":case"s":this.canvas.style.cursor="pointer"}}},this.pointermove=function(t){let e;this.rcTarget=this.canvas.getBoundingClientRect(),e=t.touches?t.touches[0]:t,this.longtaptimer&&clearInterval(this.longtaptimer);let i=this.getPos(e),s=this.hitTest(i);switch(this.dragging.o){case null:this.xscroll&&(this.xoffset=this.dragging.offsx+(this.dragging.x-i.x)*(this.xrange/this.width)),this.yscroll&&(this.yoffset=this.dragging.offsy+(i.y-this.dragging.y)*(this.yrange/this.height));break;case"m":"m"==s.m?this.menu.style.background="#ff6":this.menu.style.background="#eef";break;case"A":this.dragging.p2=i,this.dragging.t2=s.t,this.dragging.n2=s.n,this.redraw();break;case"E":var h=Math.max(1,this.dragging.m+(i.x-this.dragging.x)/this.stepw+.5|0);this.markstart>=h&&(this.markstart=h-1),this.markend=h;break;case"S":var h=Math.max(0,this.dragging.m+(i.x-this.dragging.x)/this.stepw+.5|0);this.markend<=h&&(this.markend=h+1),this.markstart=h;break;case"P":this.cursor=Math.max(0,this.dragging.m+(i.x-this.dragging.x)/this.stepw+.5|0)}switch(this.editmode){case"gridpoly":case"gridmono":this.editGridMove(i);break;case"dragpoly":case"dragmono":this.editDragMove(i)}return t.stopPropagation(),!1},this.cancel=function(t){let e;e=t.touches?null:t,this.longtaptimer&&clearInterval(this.longtaptimer);let i=this.getPos(e);if("m"==this.dragging.o&&(this.menu.style.display="none",this.rcMenu={x:0,y:0,width:0,height:0},i.t==this.menu&&this.delSelectedNote(),this.redraw()),"A"==this.dragging.o&&(this.selAreaNote(this.dragging.t1,this.dragging.t2,this.dragging.n1,this.dragging.n2),this.dragging={o:null},this.redraw()),"dragmono"==this.editmode)for(let s=this.sequence.length-1;s>=0;--s){let h=this.sequence[s];h&&h.f&&this.delAreaNote(h.t,h.g,s)}return this.redraw(),this.dragging={o:null},this.press&&this.sortSequence(),this.press=0,window.removeEventListener("touchstart",this.preventScroll,!1),window.removeEventListener("mousemove",this.bindpointermove,!1),window.removeEventListener("touchend",this.bindcancel,!1),window.removeEventListener("mouseup",this.bindcancel,!1),t.preventDefault(),t.stopPropagation(),!1},this.pointerover=function(t){},this.pointerout=function(t){},this.wheel=function(t){let e=0,i=this.getPos(t);t||(t=window.event),t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3);let s=this.hitTest(i);(this.wheelzoomx||this.wheelzoom)&&"x"==s.m&&(e>0?(this.xoffset=s.t-(s.t-this.xoffset)/1.2,this.xrange/=1.2):(this.xoffset=s.t-(s.t-this.xoffset)*1.2,this.xrange*=1.2)),(this.wheelzoomy||this.wheelzoom)&&"y"==s.m&&(e>0?(this.yoffset=s.n-(s.n-this.yoffset)/1.2,this.yrange/=1.2):(this.yoffset=s.n-(s.n-this.yoffset)*1.2,this.yrange*=1.2)),t.preventDefault()},this.layout=function(){if(void 0===this.kbwidth)return;let t=this.proll,e=this.body.style;this.bgsrc&&(t.style.background="url('"+this.bgsrc+"')"),this.kbimg.style.background="url('"+this.kbsrc+"')",this.width&&(t.width=this.width,e.width=t.style.width=this.width+"px"),this.height&&(t.height=this.height,e.height=t.style.height=this.height+"px"),this.swidth=t.width-this.yruler,this.swidth-=this.kbwidth,this.sheight=t.height-this.xruler,this.redraw()},this.redrawMarker=function(){if(!this.initialized)return;let t=(this.cursor-this.xoffset)*this.stepw+this.yruler+this.kbwidth;this.cursorimg.style.left=t+this.cursoroffset+"px";let e=(this.markstart-this.xoffset)*this.stepw+this.yruler+this.kbwidth;this.markstartimg.style.left=e+this.markstartoffset+"px";let i=(this.markend-this.xoffset)*this.stepw+this.yruler+this.kbwidth;this.markendimg.style.left=i+this.markendoffset+"px"},this.redrawGrid=function(){for(let t=0;t<128;++t){1&this.semiflag[t%12]?this.ctx.fillStyle=this.coldk:this.ctx.fillStyle=this.collt;let e=this.height-(t-this.yoffset)*this.steph;this.ctx.fillRect(this.yruler+this.kbwidth,0|e,this.swidth,-this.steph),this.ctx.fillStyle=this.colgrid,this.ctx.fillRect(this.yruler+this.kbwidth,0|e,this.swidth,1)}for(let i=0;;i+=this.grid){let s=this.stepw*(i-this.xoffset)+this.yruler+this.kbwidth;if(this.ctx.fillRect(0|s,this.xruler,1,this.sheight),s>=this.width)break}},this.semiflag=[6,1,0,1,0,2,1,0,1,0,1,0],this.redrawXRuler=function(){if(this.xruler){this.ctx.textAlign="left",this.ctx.font=this.xruler/2+"px 'sans-serif'",this.ctx.fillStyle=this.colrulerbg,this.ctx.fillRect(0,0,this.width,this.xruler),this.ctx.fillStyle=this.colrulerborder,this.ctx.fillRect(0,0,this.width,1),this.ctx.fillRect(0,0,1,this.xruler),this.ctx.fillRect(0,this.xruler-1,this.width,1),this.ctx.fillRect(this.width-1,0,1,this.xruler),this.ctx.fillStyle=this.colrulerfg;for(let t=0;;t+=this.timebase){let e=(t-this.xoffset)*this.stepw+this.yruler+this.kbwidth;if(this.ctx.fillRect(e,0,1,this.xruler),this.ctx.fillText(t/this.timebase+1,e+4,this.xruler-8),e>=this.width)break}}},this.redrawYRuler=function(){if(this.yruler){this.ctx.textAlign="right",this.ctx.font=this.steph/2+"px 'sans-serif'",this.ctx.fillStyle=this.colrulerbg,this.ctx.fillRect(0,this.xruler,this.yruler,this.sheight),this.ctx.fillStyle=this.colrulerborder,this.ctx.fillRect(0,this.xruler,1,this.sheight),this.ctx.fillRect(this.yruler,this.xruler,1,this.sheight),this.ctx.fillRect(0,this.height-1,this.yruler,1),this.ctx.fillStyle=this.colrulerfg;for(let t=0;t<128;t+=12){let e=this.height-this.steph*(t-this.yoffset);this.ctx.fillRect(0,0|e,this.yruler,-1),this.ctx.fillText("C"+((t/12|0)+this.octadj),this.yruler-4,e-4)}}this.kbimg.style.top=this.xruler+"px",this.kbimg.style.left=this.yruler+"px",this.kbimg.style.width=this.kbwidth+"px",this.kbimg.style.backgroundSize="100% "+12*this.steph+"px",this.kbimg.style.backgroundPosition="0px "+(this.sheight+this.steph*this.yoffset)+"px"},this.redrawKeyboard=function(){if(this.yruler){for(this.ctx.textAlign="right",this.ctx.font=this.steph/2+"px 'sans-serif'",this.ctx.fillStyle=this.colortab.kbwh,this.ctx.fillRect(1,this.xruler,this.yruler,this.sheight),this.ctx.fillStyle=this.colortab.kbbk,y=0;y<128;++y){let t=this.height-this.steph*(y-this.yoffset),e=y%12,i=this.semiflag[e];1&i&&(this.ctx.fillRect(0,t,this.yruler/2,-this.steph),this.ctx.fillRect(0,t-this.steph/2|0,this.yruler,-1)),2&i&&this.ctx.fillRect(0,0|t,this.yruler,-1),4&i&&this.ctx.fillText("C"+((y/12|0)+this.octadj),this.yruler-4,t-4)}this.ctx.fillRect(this.yruler,this.xruler,1,this.sheight)}},this.redrawAreaSel=function(){this.dragging&&"A"==this.dragging.o&&(this.ctx.fillStyle=this.colselarea,this.ctx.fillRect(this.dragging.p.x,this.dragging.p.y,this.dragging.p2.x-this.dragging.p.x,this.dragging.p2.y-this.dragging.p.y))},this.redraw=function(){let t,e,i,s,h;if(!this.ctx)return;this.ctx.clearRect(0,0,this.width,this.height),this.stepw=this.swidth/this.xrange,this.steph=this.sheight/this.yrange,this.redrawGrid();let r=this.sequence.length;for(let n=0;n<r;++n){let a=this.sequence[n];a.f?this.ctx.fillStyle=this.colnotesel:this.ctx.fillStyle=this.colnote,e=a.g*this.stepw,s=(t=(a.t-this.xoffset)*this.stepw+this.yruler+this.kbwidth)+e|0,t|=0,h=(i=this.height-(a.n-this.yoffset)*this.steph)-this.steph|0,i|=0,this.ctx.fillRect(t,i,s-t,h-i),a.f?this.ctx.fillStyle=this.colnoteselborder:this.ctx.fillStyle=this.colnoteborder,this.ctx.fillRect(t,i,1,h-i),this.ctx.fillRect(s,i,1,h-i),this.ctx.fillRect(t,i,s-t,1),this.ctx.fillRect(t,h,s-t,1)}this.redrawYRuler(),this.redrawXRuler(),this.redrawMarker(),this.redrawAreaSel()},this.ready()}sendEvent(t){let e;(e=document.createEvent("HTMLEvents")).initEvent(t,!1,!0),this.dispatchEvent(e)}getAttr(t,e){let i=this.getAttribute(t);if(""==i||null==i)return e;if("number"==typeof e){if("true"==i)return 1;if(isNaN(i=+i))return 0}return i}disconnectedCallback(){}});