index-396cef66.js 3.3 KB

1
  1. import{O as v,V as c}from"./TransposeCalculator-bb4225f8.js";import{d as y,A as C,c as o,M as n}from"./runtime-core.esm-bundler-8a997806.js";import"./_commonjsHelpers-edff4021.js";var e=C({});let f=null;const E=y({name:"VelFlowTest",data(){return{xml:"https://ks3-cn-beijing.ksyuncs.com/cloud-coach/1661242248370尤克里里-测试-音阶.xml"}},computed:{isHidden(){return e&&e.cursor&&e.cursor.Hidden}},async mounted(){e=new v(document.querySelector("#container1"),{backend:"svg",drawTitle:!0,coloringSetCustom:["#00ff00"],cursorsOptions:[{type:0,color:"green",alpha:1,follow:!0}]}),e.EngravingRules.StaffLineColor="rgba(238,128,196,1)",e.EngravingRules.DefaultColorCursor="rgba(238,128,196,1)",this.handleJianpu(this.xml);var r=document.getElementById("glyphs"),t=0,i=0;for(var s in c.Flow.Font.glyphs)c.Flow.Font.glyphs[s]=c.Flow.Font.glyphs[s],i++;var h=(i+1)/(800/(120*2))*60;r.height=h,r.width=800;var l=r.getContext("2d");l.font="14pt Courier";var a=60;for(var s in c.Flow.Font.glyphs){if(l.fillStyle="#222",l.fillText(s,t,a),t+=60,l.fillStyle="green",c.Flow.Font.glyphs[s].o){let u=new c.Flow.Glyph(s,45);u.render(l,t,a),l.save(),l.font="6pt Arial",u.getMetrics(),l.restore()}t+=60,t>=800&&(t=0,a+=120)}},methods:{async handleJianpu(r="",t="staff"){e.EngravingRules.DYMusicScoreType=t,await e.load(r),e.render(),console.log(e),this.getAllNote(),e.cursor.reset()},getAllNote(){var h,l,a;var r=[];e.cursor.reset();const t=e.cursor.Iterator;for(;!t.EndReached;){const m=(h=t.CurrentVoiceEntries)!=null&&h[0]?[(l=t.CurrentVoiceEntries)==null?void 0:l[0]]:[],u=(a=t.CurrentVoiceEntries)==null?void 0:a[1];for(var i=0;i<m.length;i++){const d=m[i].Notes;for(var s=0;s<d.length;s++){const p=d[s];p!=null&&p.halfTone!=0&&!p.isRest()&&r.push({note:p.halfTone+12,time:t.currentTimeStamp.RealValue*4,halfTone1:d.map(g=>g.halfTone+12).filter(Boolean),halfTone2:u&&Array.isArray(u.notes)?u.notes.map(g=>g.halfTone+12).filter(Boolean):[]})}}t.moveToNext()}console.log(r)},onNext(){e.cursor.next(),console.log(e.cursor)},onReset(){e.cursor.reset()},onToggle(){e.cursor.Hidden?e.cursor.show():e.cursor.hide()},autoPlay(){clearTimeout(f);let r=0;f=setInterval(()=>{console.log(e.cursor.cursorElement.style.display),new Date().getTime()-r>2e3&&e.cursor.next(),r=new Date().getTime(),console.log(e.cursor.cursorElement.style.display)},1e3)}},render(){return o("div",null,[o("button",{onClick:()=>this.handleJianpu(this.xml,"jianpu")},[n("简谱")]),o("button",{onClick:()=>this.handleJianpu("/jianpu/四二拍-案例0629.xml","jianpu")},[n("四二")]),o("button",{onClick:()=>this.handleJianpu("/jianpu/四三拍-案例0629.xml","jianpu")},[n("四三")]),o("button",{onClick:()=>this.handleJianpu("/jianpu/四四拍-案例0629.xml","jianpu")},[n("四四")]),o("button",{onClick:()=>this.handleJianpu("/jianpu/八三拍-案例0629_jp.xml","jianpu")},[n("八三")]),o("button",{onClick:()=>this.handleJianpu("/jianpu/八六拍-案例0629.xml","jianpu")},[n("八六")]),o("div",null,[o("button",{onClick:this.onNext},[n("next")]),o("button",{onClick:this.onReset},[n("reset")]),o("button",{onClick:this.onToggle},[n("隐藏cursor")]),o("button",{onClick:this.onToggle},[n("显示cursorsh")]),o("button",{onClick:this.autoPlay},[n("自动")])]),o("div",{id:"container1"},null),o("canvas",{id:"glyphs",width:"800",height:"1600"},[n("HTML5 Canvas not supported on this browser.")])])}});export{E as default};