aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/shapes-controller.js46
-rwxr-xr-xjs/tools/LineTool.js2
-rwxr-xr-xjs/tools/OvalTool.js4
-rwxr-xr-xjs/tools/RectTool.js4
4 files changed, 44 insertions, 12 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index acf3b63d..b2a7107b 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -142,7 +142,7 @@ exports.ShapesController = Montage.create(CanvasController, {
142 if(m) 142 if(m)
143 { 143 {
144 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(m); 144 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(m);
145 color = this.getMaterialColor(value); 145 color = this.getMaterialColor(m);
146 if(color) 146 if(color)
147 { 147 {
148 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(color); 148 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(color);
@@ -156,7 +156,7 @@ exports.ShapesController = Montage.create(CanvasController, {
156 if(m) 156 if(m)
157 { 157 {
158 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(m); 158 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(m);
159 color = this.getMaterialColor(value); 159 color = this.getMaterialColor(m);
160 if(color) 160 if(color)
161 { 161 {
162 el.elementModel.shapeModel.GLGeomObj.setFillColor(color); 162 el.elementModel.shapeModel.GLGeomObj.setFillColor(color);
@@ -750,14 +750,34 @@ exports.ShapesController = Montage.create(CanvasController, {
750 value: function(m) 750 value: function(m)
751 { 751 {
752 var css, 752 var css,
753 colorObj; 753 colorObj,
754 if(m === "LinearGradientMaterial") 754 c,
755 mName = m.getName();
756 if(mName === "LinearGradientMaterial")
755 { 757 {
756 css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))"; 758 css = "-webkit-gradient(linear, left top, right top, from(";
759 c = this.webGlColorToCss(m, 1);
760 css += c.rgb + ")";
761 c = this.webGlColorToCss(m, 2);
762 css += ", color-stop(" + c.stop + ", " + c.rgb + ")";
763 c = this.webGlColorToCss(m, 3);
764 css += ", color-stop(" + c.stop + ", " + c.rgb + ")";
765 c = this.webGlColorToCss(m, 4);
766 css += ", to(" + c.rgb + "))";
767// console.log(css);
757 } 768 }
758 else if(m === "RadialGradientMaterial") 769 else if(mName === "RadialGradientMaterial")
759 { 770 {
760 css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)"; 771 css = "-webkit-radial-gradient(50% 50%, ellipse cover, ";
772 c = this.webGlColorToCss(m, 1);
773 css += c.rgb + " " + c.stop*100 + "%";
774 c = this.webGlColorToCss(m, 2);
775 css += c.rgb + " " + c.stop*100 + "%";
776 c = this.webGlColorToCss(m, 3);
777 css += c.rgb + " " + c.stop*100 + "%";
778 c = this.webGlColorToCss(m, 4);
779 css += c.rgb + " " + c.stop*100 + "%)";
780// console.log(css);
761 } 781 }
762 782
763 if(css) 783 if(css)
@@ -771,6 +791,18 @@ exports.ShapesController = Montage.create(CanvasController, {
771 791
772 return null; 792 return null;
773 } 793 }
794 },
795
796 webGlColorToCss: {
797 value: function(m, index)
798 {
799 var color, rgba, cStop;
800 color = m["getColor" + index]();
801 rgba = 'rgba(' + color[0]*255 + ',' + color[1]*255 + ',' + color[2]*255 + ',' + color[3] + ')';
802 cStop = m["getColorStop" + index]();
803
804 return {rgb:rgba, stop: cStop};
805 }
774 } 806 }
775 807
776}); 808});
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 3e9167fd..61971c33 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -225,7 +225,7 @@ exports.LineTool = Montage.create(ShapeTool, {
225 { 225 {
226 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 226 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
227 } 227 }
228 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; 228 strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor;
229 } 229 }
230 230
231 var world = this.getGLWorld(canvas, this.options.use3D); 231 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 6edec811..f06fadb9 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -53,14 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, {
53 { 53 {
54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
55 } 55 }
56 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; 56 strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor;
57 57
58 var fillM = this.options.fillMaterial; 58 var fillM = this.options.fillMaterial;
59 if(fillM) 59 if(fillM)
60 { 60 {
61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
62 } 62 }
63 fillColor = ShapesController.getMaterialColor(fillM) || fillColor; 63 fillColor = ShapesController.getMaterialColor(fillMaterial) || fillColor;
64 } 64 }
65 65
66 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index 0c14a559..5865f00d 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -72,14 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, {
72 { 72 {
73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
74 } 74 }
75 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; 75 strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor;
76 76
77 var fillM = this.options.fillMaterial; 77 var fillM = this.options.fillMaterial;
78 if(fillM) 78 if(fillM)
79 { 79 {
80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
81 } 81 }
82 fillColor = ShapesController.getMaterialColor(fillM) || fillColor; 82 fillColor = ShapesController.getMaterialColor(fillMaterial) || fillColor;
83 } 83 }
84 84
85 var world = this.getGLWorld(canvas, this.options.use3D); 85 var world = this.getGLWorld(canvas, this.options.use3D);