()
| 759 | class Player { |
| 760 | |
| 761 | constructor() { |
| 762 | this.playing = false; |
| 763 | this.scrubbing = false; |
| 764 | this.layers = []; |
| 765 | this.selected_layer = null; |
| 766 | this.onend_callback = null; |
| 767 | this.update = null; |
| 768 | this.width = 1280; |
| 769 | this.height = 720; |
| 770 | this.total_time = 0; |
| 771 | this.last_step = null; |
| 772 | this.time = 0; |
| 773 | this.last_paused = Number.MAX_SAFE_INTEGER; |
| 774 | // for preview |
| 775 | this.aux_time = 0; |
| 776 | this.canvas = document.createElement('canvas'); |
| 777 | this.ctx = this.canvas.getContext('2d'); |
| 778 | this.audio_ctx = new AudioContext(); |
| 779 | this.canvas_holder = document.getElementById('canvas'); |
| 780 | this.canvas_holder.appendChild(this.canvas); |
| 781 | this.time_scale = 1.0; |
| 782 | this.time_holder = document.getElementById('time'); |
| 783 | this.time_canvas = document.createElement('canvas'); |
| 784 | this.time_canvas.addEventListener('pointerdown', this.scrubStart.bind(this)); |
| 785 | this.time_canvas.addEventListener('pointermove', this.scrubMove.bind(this), {passive:false}); |
| 786 | this.time_canvas.addEventListener('pointerleave', this.scrubEnd.bind(this)); |
| 787 | this.time_ctx = this.time_canvas.getContext('2d'); |
| 788 | this.time_holder.appendChild(this.time_canvas); |
| 789 | this.cursor_preview = document.getElementById('cursor_preview'); |
| 790 | this.cursor_canvas = this.cursor_preview.querySelector('canvas'); |
| 791 | this.cursor_ctx = this.cursor_canvas.getContext('2d'); |
| 792 | this.cursor_text = this.cursor_preview.querySelector('div'); |
| 793 | window.requestAnimationFrame(this.loop.bind(this)); |
| 794 | |
| 795 | this.setupPinchHadler(this.canvas_holder, |
| 796 | (function(scale, rotation) { |
| 797 | this.update = { |
| 798 | scale: scale, |
| 799 | rotation: rotation |
| 800 | }; |
| 801 | }).bind(this)); |
| 802 | this.setupPinchHadler(this.time_holder, |
| 803 | (function(scale, rotation) { |
| 804 | let new_x = (this.time_holder.clientWidth * scale - this.time_holder.clientWidth); |
| 805 | let old_x = this.time_holder.scrollLeft; |
| 806 | this.time_scale = Math.max(1, this.time_scale * scale); |
| 807 | this.resize_time(); |
| 808 | this.time_holder.scroll(Math.round(old_x + new_x), 0); |
| 809 | }).bind(this)); |
| 810 | this.setupDragHandler(); |
| 811 | this.resize(); |
| 812 | } |
| 813 | |
| 814 | dumpToJson() { |
| 815 | let out = []; |
nothing calls this directly
no test coverage detected