From affafafc4db16e5f918c74dfc919025d4c563cc6 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 17:30:53 -0800 Subject: Updated color code to handle shapes. Signed-off-by: Nivesh Rajbhandari --- js/models/color-model.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/models') diff --git a/js/models/color-model.js b/js/models/color-model.js index 7e5fee1f..b06281f8 100644 --- a/js/models/color-model.js +++ b/js/models/color-model.js @@ -415,8 +415,10 @@ exports.ColorModel = Montage.create(Component, { colorEvent.alpha = this.alpha.value; if (this.hsl) colorEvent.hsla = {h: this.hsl.h, s: this.hsl.s, l: this.hsl.l, a: this.alpha.value, css: 'hsla('+this.hsl.h+', '+this.hsl.s+'%, '+this.hsl.l+'%, '+this.alpha.value+')'}; - if (this.rgb) + if (this.rgb) { colorEvent.rgba = {r: this.rgb.r, g: this.rgb.g, b: this.rgb.b, a: this.alpha.value, css: 'rgba('+ this.rgb.r +', '+this.rgb.g+', '+this.rgb.b+', '+this.alpha.value+')'}; + colorEvent.webGlColor = [this.rgb.r/255, this.rgb.g/255, this.rgb.b/255, this.alpha.value]; + } if (this.hex) colorEvent.hex = this.hex; //Standard values that apply to any event -- cgit v1.2.3 From 830b011d94d728882286d72e129f7405134957c7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 1 Feb 2012 17:05:07 -0800 Subject: Updated color code in the PI to go through element mediator. Signed-off-by: Nivesh Rajbhandari --- js/models/color-model.js | 39 ++++++++++++++++++++++++++++++++++++++- js/models/element-model.js | 8 +++++++- js/models/shape-model.js | 2 ++ 3 files changed, 47 insertions(+), 2 deletions(-) (limited to 'js/models') diff --git a/js/models/color-model.js b/js/models/color-model.js index b06281f8..2c86422f 100644 --- a/js/models/color-model.js +++ b/js/models/color-model.js @@ -562,7 +562,44 @@ exports.ColorModel = Montage.create(Component, { //Returning RGB object return {r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255)}; } - } + }, + //////////////////////////////////////////////////////////////////// + //Returns WebGL color array in [r, g, b, a] format where the values are [0,1] given a color object + colorToWebGl: { + enumerable: true, + value: function (color) { + var temp; + if (color) { + if(color.l !== undefined) { + temp = this.hslToRgb(color.h/360, color.s/100, color.l/100); + } else if (color.r !== undefined) { + temp = color; + } + temp.a = color.a; + } + //WebGL uses array + if (temp) { + return [temp.r/255, temp.g/255, temp.b/255, temp.a]; + } else { + return null; + } + } + }, + //////////////////////////////////////////////////////////////////// + //Returns CSS string given a WebGL color array in [r, g, b, a] format where the values are [0,1] + webGlToCss: { + enumerable: true, + value: function (color) { + if(color && (color.length === 4)) + { + return 'rgba(' + color[0]*255 + ', ' + color[1]*255 + ', ' + color[2]*255 + ', ' + color[3] +')'; + } + else + { + return null; + } + } + } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/js/models/element-model.js b/js/models/element-model.js index 6e1ac07a..831e8b1e 100644 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -37,6 +37,12 @@ exports.ElementModel = Montage.create(Montage, { /** * SnapManager 2d Snap Cache Info */ - isIn2DSnapCache : { value: false } + isIn2DSnapCache : { value: false }, + + /** + * Color info + */ + fill: { value: null }, + stroke: { value: null } }); \ No newline at end of file diff --git a/js/models/shape-model.js b/js/models/shape-model.js index 9d4fff6f..b643a7b5 100644 --- a/js/models/shape-model.js +++ b/js/models/shape-model.js @@ -20,10 +20,12 @@ exports.ShapeModel = Montage.create(Component, { strokeMaterialIndex: { value: null }, strokeStyle: { value: null }, strokeStyleIndex: { value: null }, + border: { value: null }, // Store css value for ColorController fill: { value: null }, fillMaterial: { value: null }, fillMaterialIndex: { value: null }, + background: { value: null }, // Store css value for ColorController // Line-specific slope: { value: null }, -- cgit v1.2.3 From 486d9a31a85dd833a1c798049a00403756703034 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 6 Feb 2012 11:35:49 -0800 Subject: Support use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari --- js/models/shape-model.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/models') diff --git a/js/models/shape-model.js b/js/models/shape-model.js index b643a7b5..1175538f 100644 --- a/js/models/shape-model.js +++ b/js/models/shape-model.js @@ -10,6 +10,7 @@ var Montage = require("montage/core/core").Montage, exports.ShapeModel = Montage.create(Component, { shapeCount: { value: 0 }, + useWebGl: { value: false }, GLWorld: { value: null }, GLGeomObj: { value: null }, -- cgit v1.2.3 From 486842239c71e7964f38a09aacda4970f2a82e1a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 7 Feb 2012 10:58:14 -0800 Subject: Updated tools and PI to get/set materials by binding to appModel's materials property. This requires us to add FlatMaterial to the list of materials in the MaterialsLibrary. Signed-off-by: Nivesh Rajbhandari --- js/models/shape-model.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/models') diff --git a/js/models/shape-model.js b/js/models/shape-model.js index 1175538f..58a88fd0 100644 --- a/js/models/shape-model.js +++ b/js/models/shape-model.js @@ -18,14 +18,12 @@ exports.ShapeModel = Montage.create(Component, { strokeSize: { value: null }, stroke: { value: null }, strokeMaterial: { value: null }, - strokeMaterialIndex: { value: null }, strokeStyle: { value: null }, strokeStyleIndex: { value: null }, border: { value: null }, // Store css value for ColorController fill: { value: null }, fillMaterial: { value: null }, - fillMaterialIndex: { value: null }, background: { value: null }, // Store css value for ColorController // Line-specific -- cgit v1.2.3