aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/circle.js19
-rwxr-xr-xjs/lib/geom/geom-obj.js388
-rwxr-xr-xjs/lib/geom/line.js10
-rwxr-xr-xjs/lib/geom/rectangle.js15
4 files changed, 245 insertions, 187 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 7fa78b12..1073c2db 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -42,8 +42,8 @@ var Circle = function GLCircle() {
42 42
43 this._strokeWidth = strokeSize; 43 this._strokeWidth = strokeSize;
44 this._innerRadius = innerRadius; 44 this._innerRadius = innerRadius;
45 if (strokeColor) this._strokeColor = strokeColor; 45 this._strokeColor = strokeColor;
46 if (fillColor) this._fillColor = fillColor; 46 this._fillColor = fillColor;
47 47
48 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 } 49 }
@@ -631,6 +631,21 @@ var Circle = function GLCircle() {
631 this._strokeStyle = jObj.strokeStyle; 631 this._strokeStyle = jObj.strokeStyle;
632 var strokeMaterialName = jObj.strokeMat; 632 var strokeMaterialName = jObj.strokeMat;
633 var fillMaterialName = jObj.fillMat; 633 var fillMaterialName = jObj.fillMat;
634
635 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
636 if (!strokeMat) {
637 console.log( "object material not found in library: " + strokeMaterialName );
638 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
639 }
640 this._strokeMaterial = strokeMat;
641
642 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
643 if (!fillMat) {
644 console.log( "object material not found in library: " + fillMaterialName );
645 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
646 }
647 this._fillMaterial = fillMat;
648
634 this.importMaterialsJSON( jObj.materials ); 649 this.importMaterialsJSON( jObj.materials );
635 }; 650 };
636 651
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index bb5b4a9a..56cf7c98 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -14,19 +14,19 @@ var GeomObj = function GLGeomObj() {
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 // Constants 15 // Constants
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 this.GEOM_TYPE_RECTANGLE = 1; 17 this.GEOM_TYPE_RECTANGLE = 1;
18 this.GEOM_TYPE_CIRCLE = 2; 18 this.GEOM_TYPE_CIRCLE = 2;
19 this.GEOM_TYPE_LINE = 3; 19 this.GEOM_TYPE_LINE = 3;
20 this.GEOM_TYPE_PATH = 4; 20 this.GEOM_TYPE_PATH = 4;
21 this.GEOM_TYPE_CUBIC_BEZIER = 5; 21 this.GEOM_TYPE_CUBIC_BEZIER = 5;
22 this.GEOM_TYPE_BRUSH_STROKE = 6; 22 this.GEOM_TYPE_BRUSH_STROKE = 6;
23 this.GEOM_TYPE_UNDEFINED = -1; 23 this.GEOM_TYPE_UNDEFINED = -1;
24 24
25 // Needed for calculating dashed/dotted strokes 25 // Needed for calculating dashed/dotted strokes
26 this.DASH_LENGTH = 0.15; 26 this.DASH_LENGTH = 0.15;
27 this.DOT_LENGTH = 0.05; 27 this.DOT_LENGTH = 0.05;
28 this.GAP_LENGTH = 0.05; 28 this.GAP_LENGTH = 0.05;
29 29
30 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
31 // Instance variables 31 // Instance variables
32 /////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////
@@ -40,74 +40,74 @@ var GeomObj = function GLGeomObj() {
40 this.m_world = null; 40 this.m_world = null;
41 41
42 // stroke and fill colors 42 // stroke and fill colors
43 this._strokeColor = [0, 0, 0, 0]; 43 this._strokeColor = [0,0,0,0];
44 this._fillColor = [0, 0, 0, 0]; 44 this._fillColor = [0,0,0,0];
45 45
46 // stroke and fill materials 46 // stroke and fill materials
47 this._fillMaterial = null; 47 this._fillMaterial = null;
48 this._strokeMaterial = null; 48 this._strokeMaterial = null;
49 49
50 // array of primitives - used in RDGE 50 // array of primitives - used in RDGE
51 this._primArray = []; 51 this._primArray = [];
52 this._materialNodeArray = []; 52 this._materialNodeArray = [];
53 this._materialArray = []; 53 this._materialArray = [];
54 this._materialTypeArray = []; 54 this._materialTypeArray = [];
55 55
56 // the transform node used by RDGE 56 // the transform node used by RDGE
57 this._trNode = null; 57 this._trNode = null;
58 58
59 /////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////
60 // Property accessors 60 // Property accessors
61 /////////////////////////////////////////////////////////////////////// 61 ///////////////////////////////////////////////////////////////////////
62 this.setWorld = function (world) { 62 this.setWorld = function( world ) {
63 this.m_world = world; 63 this.m_world = world;
64 }; 64 };
65 65
66 this.getWorld = function () { 66 this.getWorld = function() {
67 return this.m_world; 67 return this.m_world;
68 }; 68 };
69 69
70 this.getMatrix = function () { 70 this.getMatrix = function() {
71 return this._matrix.slice(0); 71 return this._matrix.slice(0);
72 }; 72 };
73 73
74 this.setMatrix = function (m) { 74 this.setMatrix = function(m) {
75 this._matrix = m.slice(0); 75 this._matrix = m.slice(0);
76 }; 76 };
77 77
78 this.setNext = function (next) { 78 this.setNext = function( next ) {
79 this._next = next; 79 this._next = next;
80 }; 80 };
81 81
82 this.getNext = function () { 82 this.getNext = function() {
83 return this._next; 83 return this._next;
84 }; 84 };
85 85
86 this.setPrev = function (prev) { 86 this.setPrev = function( prev ) {
87 this._prev = prev; 87 this._prev = prev;
88 }; 88 };
89 89
90 this.getPrev = function () { 90 this.getPrev = function() {
91 return this._prev; 91 return this._prev;
92 }; 92 };
93 93
94 this.setChild = function (child) { 94 this.setChild = function( child ) {
95 this._child = child; 95 this._child = child;
96 }; 96 };
97 97
98 this.getChild = function () { 98 this.getChild = function() {
99 return this._child; 99 return this._child;
100 }; 100 };
101 101
102 this.setParent = function (parent) { 102 this.setParent = function( parent ) {
103 this._parent = parent; 103 this._parent = parent;
104 }; 104 };
105 105
106 this.getParent = function () { 106 this.getParent = function() {
107 return this._parent; 107 return this._parent;
108 }; 108 };
109 109
110 this.geomType = function () { 110 this.geomType = function() {
111 return this.GEOM_TYPE_UNDEFINED; 111 return this.GEOM_TYPE_UNDEFINED;
112 }; 112 };
113 113
@@ -115,7 +115,7 @@ var GeomObj = function GLGeomObj() {
115 return this._primArray; 115 return this._primArray;
116 }; 116 };
117 117
118 this.getMaterialNodeArray = function () { 118 this.getMaterialNodeArray = function() {
119 return this._materialNodeArray; 119 return this._materialNodeArray;
120 }; 120 };
121 121
@@ -123,110 +123,130 @@ var GeomObj = function GLGeomObj() {
123 return this._materialArray; 123 return this._materialArray;
124 }; 124 };
125 125
126 this.getTransformNode = function () { 126 this.getTransformNode = function() {
127 return this._trNode; 127 return this._trNode;
128 }; 128 };
129 129
130 this.setTransformNode = function (t) { 130 this.setTransformNode = function(t) {
131 this._trNode = t; 131 this._trNode = t;
132 }; 132 };
133 133
134 this.setFillColor = function (c) { 134 this.setFillColor = function(c) {
135 this.setMaterialColor(c, "fill"); 135 this.setMaterialColor(c, "fill");
136 }; 136 };
137 137
138 this.setStrokeColor = function (c) { 138 this.setStrokeColor = function(c) {
139 this.setMaterialColor(c, "stroke"); 139 this.setMaterialColor(c, "stroke");
140 }; 140 };
141 /////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////
142 // Methods 142 // Methods
143 /////////////////////////////////////////////////////////////////////// 143 ///////////////////////////////////////////////////////////////////////
144 this.setMaterialColor = function (c, type) { 144 this.setMaterialColor = function(c, type) {
145 var i = 0, 145 var i = 0,
146 nMats = 0; 146 nMats = 0;
147 if (c.gradientMode) { 147 if(c) {
148 // Gradient support 148 if(c.gradientMode) {
149 if (this._materialArray && this._materialTypeArray) { 149 // Gradient support
150 nMats = this._materialArray.length; 150 if (this._materialArray && this._materialTypeArray) {
151 } 151 nMats = this._materialArray.length;
152 152 }
153 var stops = [],
154 colors = c.color;
155