# HG changeset patch # User cavaliet # Date 1414492432 -3600 # Node ID 129281e4bc2a07862572a86aeb62837b0b97ee5f # Parent bdcc964b3c01a5e2e9cded5e418a86fa103a8483# Parent 2a6590aeac15be434a376ba2a6674dde5b0a8e10 Merge with 2a6590aeac15be434a376ba2a6674dde5b0a8e10 diff -r 2a6590aeac15 -r 129281e4bc2a annot-server/static/js/pianoroll.js --- a/annot-server/static/js/pianoroll.js Mon Oct 27 18:09:39 2014 +0100 +++ b/annot-server/static/js/pianoroll.js Tue Oct 28 11:33:52 2014 +0100 @@ -40,8 +40,8 @@ stage.addChild(uberContainer); -function PianoRoll(parentContainer, xInit, yInit, height, linesDown, pixelsPerSecond){ - +function PianoRoll(parentContainer, xInit, yInit, height, linesDown, pixelsPerSecond, width){ + var _this = this; this.container = new PIXI.DisplayObjectContainer(); this.container.position.x = xInit; this.container.position.y = yInit; @@ -50,6 +50,7 @@ this.linesDown = linesDown; this.height = height; this.pixelsPerSecond = pixelsPerSecond; + this.width = width; this.addNote = function(note, startTime, duration, velocity, canal){ //console.log("coucou 1", note, timeFromZero, ts, velocity, pixelsPerSecond, container, prHeight); @@ -60,8 +61,9 @@ //console.log("beginX = ", beginX, "canal = ", canal, "color = ", noteColor[canal], "width = ", width, "note = ", note, "velocity = ", velocity); graphics.beginFill(noteColor[canal], (velocity / 128)); var y = (128-note) * this.height / 128; // (128-note) because y = 0 is for note = 128 and y = 128 for note = 0 - graphics.drawRect(beginX, Math.floor(y - (noteHeight/2) + ((this.height / 128)/2)), width, noteHeight); + graphics.drawRect(0, Math.floor(y - (noteHeight/2) + ((this.height / 128)/2)), width, noteHeight); graphics.endFill(); + graphics.x = beginX; this.container.addChild(graphics); }; @@ -86,17 +88,35 @@ t.x = x + 2; t.y = this.linesDown ? this.height - 15 : 2; this.container.addChild(t); - } + }; this.moveTo = function(diffTime){ this.container.x = Math.floor(diffTime*this.pixelsPerSecond); }; + this.removePassedObjets = function(){ + var nbChilds = _this.container.children.length; + var i = 0, childIsNowDisplayed = false; + while(i