diff -r 9be99c2fb279 -r d7c5bffdd2d8 client/pianoroll/app/js/main.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/pianoroll/app/js/main.js Mon Jan 12 17:23:05 2015 +0100 @@ -0,0 +1,198 @@ +/** + * scripts/main.js + * + * This is the starting point for your application. + * Take a look at http://browserify.org/ for more info + */ + +'use strict'; + + +var PIXI = require('pixi'); + +// Config vars +var logger = false; +var sceneWidth = 1920; +var prHeight1 = 435; +var prHeight2 = 645; +var sceneHeight = prHeight1 + prHeight2; +var sceneBgColor = 0xFFFFFF; +var lineColor = 0x444444; +var pixelsPerSecond1 = Math.floor(sceneWidth / 10); // nb of pixels per second +var manualFramerate = pixelsPerSecond1 / 4; +var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second +var lineInterval = 5000; // means line every 5 seconds +var nbLines = -1; +var noteHeight = 110; +var noteColors = [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991]; +var colorsReg = {}; +// Vars +var noteDict = []; +// Timecode method +var timePageLoaded = Date.now(); +var offsetMusic = false; + + +//create an new instance of a pixi stage +var stage = new PIXI.Stage(sceneBgColor); + +//create a renderer instance. +var renderer = PIXI.autoDetectRenderer(sceneWidth, sceneHeight); + +//add the renderer view element to the DOM +document.getElementById('canvasContainer').appendChild(renderer.view); + +var uberContainer = new PIXI.DisplayObjectContainer(); +uberContainer.position.x = Math.floor(sceneWidth*9/10); +uberContainer.position.y = 0; +stage.addChild(uberContainer); + +var PianoRoll = require('./pianoroll.js') + +// Init containers +var containerList = []; +containerList.push(new PianoRoll(uberContainer, 0, 0, prHeight1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval)); +containerList.push(new PianoRoll(uberContainer, 0, prHeight1, prHeight2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval)); + +// Line between two containers +var graphics = new PIXI.Graphics(); +graphics.beginFill(0xFFFF00); +graphics.lineStyle(1, lineColor); +graphics.moveTo(0, prHeight1); +graphics.lineTo(sceneWidth, prHeight1); +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