From 8a02a585f2840ab539c548431fc790478547660c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 26 Apr 2016 11:23:05 -0700 Subject: [PATCH] use array of colors --- scripts/default/libraries/gridTool.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/default/libraries/gridTool.js b/scripts/default/libraries/gridTool.js index bebad84e1e..c002aec3b1 100644 --- a/scripts/default/libraries/gridTool.js +++ b/scripts/default/libraries/gridTool.js @@ -3,7 +3,14 @@ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); Grid = function(opts) { var that = {}; - var gridColor = { red: 255, green: 255, blue: 255 }; + var colors = [ + { red: 0, green: 0, blue: 0 }, + { red: 255, green: 255, blue: 255 }, + { red: 255, green: 0, blue: 0 }, + { red: 0, green: 255, blue: 0 }, + { red: 0, green: 0, blue: 255 }, + ]; + var colorIndex = 0; var gridAlpha = 0.6; var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 }; var scale = 500; @@ -21,7 +28,7 @@ Grid = function(opts) { position: origin, visible: false, drawInFront: false, - color: gridColor, + color: colors[0], alpha: gridAlpha, minorGridEvery: minorGridEvery, majorGridEvery: majorGridEvery, @@ -45,6 +52,12 @@ Grid = function(opts) { updateGrid(); }; + that.getColorIndex = function() { return colorIndex; }; + that.setColorIndex = function(value) { + colorIndex = value; + updateGrid(); + }; + that.getSnapToGrid = function() { return snapToGrid; }; that.setSnapToGrid = function(value) { snapToGrid = value; @@ -162,8 +175,8 @@ Grid = function(opts) { majorGridEvery = data.majorGridEvery; } - if (data.gridColor !== undefined) { - gridColor = data.gridColor; + if (data.colorIndex !== undefined) { + colorIndex = data.colorIndex; } if (data.gridSize) { @@ -183,7 +196,7 @@ Grid = function(opts) { visible: that.visible && that.enabled, minorGridEvery: minorGridEvery, majorGridEvery: majorGridEvery, - color: gridColor, + color: colors[colorIndex], alpha: gridAlpha, });