diff options
author | Jose Antonio Marquez Russo | 2012-02-01 17:11:21 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-01 17:11:21 -0800 |
commit | 83ac41dd75ec551cdb03252e0bf3081182517d05 (patch) | |
tree | 75781b24936e90c815f13dd5d2158c65fef643e3 /js/models | |
parent | 9c317ebb46e82a00b83eb732c73ae39ce9ef46b9 (diff) | |
parent | 830b011d94d728882286d72e129f7405134957c7 (diff) | |
download | ninja-83ac41dd75ec551cdb03252e0bf3081182517d05.tar.gz |
Merge pull request #2 from mqg734/NiveshColor
Updated PI color code to go through mediator. Also enabled getting/setting color support for shapes.
Diffstat (limited to 'js/models')
-rw-r--r-- | js/models/color-model.js | 39 | ||||
-rw-r--r-- | js/models/element-model.js | 8 | ||||
-rw-r--r-- | js/models/shape-model.js | 2 |
3 files changed, 47 insertions, 2 deletions
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, { | |||
562 | //Returning RGB object | 562 | //Returning RGB object |
563 | return {r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255)}; | 563 | return {r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255)}; |
564 | } | 564 | } |
565 | } | 565 | }, |
566 | //////////////////////////////////////////////////////////////////// | ||
567 | //Returns WebGL color array in [r, g, b, a] format where the values are [0,1] given a color object | ||
568 | colorToWebGl: { | ||
569 | enumerable: true, | ||
570 | value: function (color) { | ||
571 | var temp; | ||
572 | if (color) { | ||
573 | if(color.l !== undefined) { | ||
574 | temp = this.hslToRgb(color.h/360, color.s/100, color.l/100); | ||
575 | } else if (color.r !== undefined) { | ||
576 | temp = color; | ||
577 | } | ||
578 | temp.a = color.a; | ||
579 | } | ||
580 | //WebGL uses array | ||
581 | if (temp) { | ||
582 | return [temp.r/255, temp.g/255, temp.b/255, temp.a]; | ||
583 | } else { | ||
584 | return null; | ||
585 | } | ||
586 | } | ||
587 | }, | ||
588 | //////////////////////////////////////////////////////////////////// | ||
589 | //Returns CSS string given a WebGL color array in [r, g, b, a] format where the values are [0,1] | ||
590 | webGlToCss: { | ||
591 | enumerable: true, | ||
592 | value: function (color) { | ||
593 | if(color && (color.length === 4)) | ||
594 | { | ||
595 | return 'rgba(' + color[0]*255 + ', ' + color[1]*255 + ', ' + color[2]*255 + ', ' + color[3] +')'; | ||
596 | } | ||
597 | else | ||
598 | { | ||
599 | return null; | ||
600 | } | ||
601 | } | ||
602 | } | ||
566 | //////////////////////////////////////////////////////////////////// | 603 | //////////////////////////////////////////////////////////////////// |
567 | //////////////////////////////////////////////////////////////////// | 604 | //////////////////////////////////////////////////////////////////// |
568 | //////////////////////////////////////////////////////////////////// | 605 | //////////////////////////////////////////////////////////////////// |
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, { | |||
37 | /** | 37 | /** |
38 | * SnapManager 2d Snap Cache Info | 38 | * SnapManager 2d Snap Cache Info |
39 | */ | 39 | */ |
40 | isIn2DSnapCache : { value: false } | 40 | isIn2DSnapCache : { value: false }, |
41 | |||
42 | /** | ||
43 | * Color info | ||
44 | */ | ||
45 | fill: { value: null }, | ||
46 | stroke: { value: null } | ||
41 | 47 | ||
42 | }); \ No newline at end of file | 48 | }); \ 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, { | |||
20 | strokeMaterialIndex: { value: null }, | 20 | strokeMaterialIndex: { value: null }, |
21 | strokeStyle: { value: null }, | 21 | strokeStyle: { value: null }, |
22 | strokeStyleIndex: { value: null }, | 22 | strokeStyleIndex: { value: null }, |
23 | border: { value: null }, // Store css value for ColorController | ||
23 | 24 | ||
24 | fill: { value: null }, | 25 | fill: { value: null }, |
25 | fillMaterial: { value: null }, | 26 | fillMaterial: { value: null }, |
26 | fillMaterialIndex: { value: null }, | 27 | fillMaterialIndex: { value: null }, |
28 | background: { value: null }, // Store css value for ColorController | ||
27 | 29 | ||
28 | // Line-specific | 30 | // Line-specific |
29 | slope: { value: null }, | 31 | slope: { value: null }, |