diff -r 2e2414765a59 -r b4bd49f01837 client/annotviz/app/js/main.js --- a/client/annotviz/app/js/main.js Thu Jan 15 17:56:57 2015 +0100 +++ b/client/annotviz/app/js/main.js Thu Jan 15 17:59:41 2015 +0100 @@ -11,16 +11,27 @@ var PIXI = require('pixi'); // Config vars +var horizontalView = false; var logger = false; var sceneWidth = 1920; -var prHeight1 = 435; -var prHeight2 = 645; -var sceneHeight = prHeight1 + prHeight2; +var sceneHeight = 1080; +var prSize1 = 435; +var prSize2 = 435; +var prSize3 = 300; var sceneBgColor = 0xFFFFFF; var lineColor = 0x444444; -var pixelsPerSecond1 = Math.floor(sceneWidth / 10); // nb of pixels per second +if (horizontalView){ + var pixelsPerSecond1 = Math.floor(sceneWidth / 10); // nb of pixels per second +} else{ + var pixelsPerSecond1 = Math.floor(sceneHeight / 10); // nb of pixels per second +} var manualFramerate = pixelsPerSecond1 / 4; -var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second +if (horizontalView){ + var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second +} else { + var pixelsPerSecond2 = Math.floor(sceneHeight / 60); // nb of pixels per second +} +var pixelsPerSecond3 = Math.floor(sceneHeight / 60); // nb of pixels per second var lineInterval = 5000; // means line every 5 seconds var nbLines = -1; var noteHeight = 110; @@ -32,7 +43,6 @@ var timePageLoaded = Date.now(); var offsetMusic = false; - //create an new instance of a pixi stage var stage = new PIXI.Stage(sceneBgColor); @@ -43,36 +53,48 @@ document.getElementById('canvasContainer').appendChild(renderer.view); var uberContainer = new PIXI.DisplayObjectContainer(); -uberContainer.position.x = Math.floor(sceneWidth*9/10); -uberContainer.position.y = 0; +if (horizontalView){ + uberContainer.position.x = Math.floor(sceneWidth*9/10); + uberContainer.position.y = 0; +} else { + uberContainer.position.x = 0; + uberContainer.position.y = Math.floor(sceneHeight*9/10);; +} stage.addChild(uberContainer); +/* ---------------------------------------------------------------- */ +/* ------------------- Init Pianoroll containers ------------------ */ +/* ---------------------------------------------------------------- */ + var PianoRoll = require('./pianoroll.js') -// Init containers var containerList = []; -containerList.push(new PianoRoll(uberContainer, 0, 0, prHeight1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prHeight1 / 128)); -containerList.push(new PianoRoll(uberContainer, 0, prHeight1, prHeight2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prHeight2 / 128)); + +if (horizontalView){ + containerList.push(new PianoRoll(uberContainer, 0, 0, prSize1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView)); + containerList.push(new PianoRoll(uberContainer, 0, prSize1, prSize2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); +} else { +// containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, true, pixelsPerSecond1, prSize1, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView)); +// containerList.push(new PianoRoll(uberContainer, sceneWidth - (prSize1 + prSize2), 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); + containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); +} // Line between two containers var graphics = new PIXI.Graphics(); graphics.beginFill(0xFFFF00); graphics.lineStyle(1, lineColor); -graphics.moveTo(0, prHeight1); -graphics.lineTo(sceneWidth, prHeight1); +if (horizontalView){ + graphics.moveTo(0, prSize1); + graphics.lineTo(sceneWidth, prSize1); +} else { + graphics.moveTo(sceneWidth - prSize1, 0); + graphics.lineTo(sceneWidth - prSize1, sceneHeight); + graphics.moveTo(sceneWidth - (prSize1 + prSize3), 0); + graphics.lineTo(sceneWidth - (prSize1 + prSize3), sceneHeight); +} graphics.endFill(); stage.addChild(graphics); - -function replaceContainers(){ - var diff = (Date.now() - timePageLoaded)/1000;// nb of seconds since page loaded - //console.log("replace ! diff1 = ", container1.x - Math.floor(-diff*pixelsPerSecond1), ", diff 2 = ", container2.x - Math.floor(-diff*pixelsPerSecond2)); - for(var i=0;i