diff -r d7c5bffdd2d8 -r eff9460bd4f2 client/pianoroll/app/js/pianoroll.js --- a/client/pianoroll/app/js/pianoroll.js Mon Jan 12 17:23:05 2015 +0100 +++ b/client/pianoroll/app/js/pianoroll.js Tue Jan 13 10:46:05 2015 +0100 @@ -10,7 +10,7 @@ var PIXI = require('pixi'); var randomColor = require('randomColor'); -function PianoRoll(parentContainer, xInit, yInit, height, linesDown, pixelsPerSecond, width, noteColors, colorsReg, lineColor, lineInterval){ +function PianoRoll(parentContainer, xInit, yInit, height, linesDown, pixelsPerSecond, width, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, noteHeight){ var _this = this; this.container = new PIXI.DisplayObjectContainer(); this.container.position.x = xInit; @@ -25,11 +25,17 @@ this.colorsReg = colorsReg || {}; this.lineColor = lineColor; this.lineInterval = lineInterval; + this.offsetMusic = offsetMusic || 0; + this.noteHeight = noteHeight; this.addNote = function(note, startTime, duration, velocity, canal){ //console.log("coucou 1", note, timeFromZero, ts, velocity, pixelsPerSecond, container, prHeight); - var beginX = (offsetMusic + startTime) * this.pixelsPerSecond / 1000; + var beginX = (this.offsetMusic + startTime) * this.pixelsPerSecond / 1000; var width = duration * this.pixelsPerSecond / 1000; + if((beginX+width) < Math.abs(this.container.x) - this.width) { + // not visible. do nothing + return; + } // We draw the rectangle var graphics = new PIXI.Graphics(); //console.log("beginX = ", beginX, "canal = ", canal, "color = ", noteColor[canal], "width = ", width, "note = ", note, "velocity = ", velocity); @@ -80,20 +86,25 @@ this.removePassedObjets = function(){ var nbChilds = _this.container.children.length; - var i = 0, childIsNowDisplayed = false; + var i = 0, childIsNowDisplayed = false, childrenToRemove = []; while(i