diff options
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-x | js/lib/geom/circle.js | 1576 |
1 files changed, 788 insertions, 788 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index 2cd5a21f..53847631 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -31,60 +31,60 @@ POSSIBILITY OF SUCH DAMAGE. | |||
31 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; | 31 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; |
32 | var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; | 32 | var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; |
33 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 33 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; |
34 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; | 34 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; |
35 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 35 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
36 | 36 | ||
37 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
38 | // Class GLCircle | 38 | // Class GLCircle |
39 | // GL representation of a circle. | 39 | // GL representation of a circle. |
40 | // Derived from class GLGeomObj | 40 | // Derived from class GLGeomObj |
41 | // The position and dimensions of the stroke, fill, and inner Radius should be in pixels | 41 | // The position and dimensions of the stroke, fill, and inner Radius should be in pixels |
42 | /////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////// |
43 | exports.Circle = Object.create(GeomObj, { | 43 | exports.Circle = Object.create(GeomObj, { |
44 | 44 | ||
45 | /////////////////////////////////////////////////////////////////////// | 45 | /////////////////////////////////////////////////////////////////////// |
46 | // Instance variables | 46 | // Instance variables |
47 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
48 | _width: { value : 2.0, writable: true }, | 48 | _width: { value : 2.0, writable: true }, |
49 | _height: { value : 2.0, writable: true }, | 49 | _height: { value : 2.0, writable: true }, |
50 | _xOffset: { value : 0, writable: true }, | 50 | _xOffset: { value : 0, writable: true }, |
51 | _yOffset: { value : 0, writable: true }, | 51 | _yOffset: { value : 0, writable: true }, |
52 | 52 | ||
53 | _radius: { value : 2.0, writable: true }, | 53 | _radius: { value : 2.0, writable: true }, |
54 | _strokeWidth: { value : 0.25, writable: true }, | 54 | _strokeWidth: { value : 0.25, writable: true }, |
55 | _innerRadius: { value : 0, writable: true }, | 55 | _innerRadius: { value : 0, writable: true }, |
56 | _ovalHeight: { value : 4.0, writable: true }, | 56 | _ovalHeight: { value : 4.0, writable: true }, |
57 | _strokeStyle: { value : "Solid", writable: true }, | 57 | _strokeStyle: { value : "Solid", writable: true }, |
58 | _aspectRatio: { value : 1.0, writable: true }, | 58 | _aspectRatio: { value : 1.0, writable: true }, |
59 | 59 | ||
60 | init: { | 60 | init: { |
61 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { | 61 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { |
62 | if(arguments.length > 0) { | 62 | if(arguments.length > 0) { |
63 | this._width = width; | 63 | this._width = width; |
64 | this._height = height; | 64 | this._height = height; |
65 | this._xOffset = xOffset; | 65 | this._xOffset = xOffset; |
66 | this._yOffset = yOffset; | 66 | this._yOffset = yOffset; |
67 | this._ovalHeight = 2.0 * this._radius; | 67 | this._ovalHeight = 2.0 * this._radius; |
68 | 68 | ||
69 | this._strokeWidth = strokeSize; | 69 | this._strokeWidth = strokeSize; |
70 | this._innerRadius = innerRadius; | 70 | this._innerRadius = innerRadius; |
71 | this._strokeColor = strokeColor; | 71 | this._strokeColor = strokeColor; |
72 | this._fillColor = fillColor; | 72 | this._fillColor = fillColor; |
73 | 73 | ||
74 | this._strokeStyle = strokeStyle; | 74 | this._strokeStyle = strokeStyle; |
75 | 75 | ||
76 | this._matrix = Matrix.I(4); | 76 | this._matrix = Matrix.I(4); |
77 | //this._matrix[12] = xOffset; | 77 | //this._matrix[12] = xOffset; |
78 | //this._matrix[13] = yOffset; | 78 | //this._matrix[13] = yOffset; |
79 | } | 79 | } |
80 | 80 | ||
81 | this.m_world = world; | 81 | this.m_world = world; |
82 | 82 | ||
83 | if(strokeMaterial) { | 83 | if(strokeMaterial) { |
84 | this._strokeMaterial = strokeMaterial.dup(); | 84 | this._strokeMaterial = strokeMaterial.dup(); |
85 | } else { | 85 | } else { |
86 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 86 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
87 | } | 87 | } |
88 | 88 | ||
89 | if(strokeColor) { | 89 | if(strokeColor) { |
90 | if(this._strokeMaterial.hasProperty("color")) { | 90 | if(this._strokeMaterial.hasProperty("color")) { |
@@ -94,135 +94,135 @@ exports.Circle = Object.create(GeomObj, { | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | if(fillMaterial) { | 97 | if(fillMaterial) { |
98 | this._fillMaterial = fillMaterial.dup(); | 98 | this._fillMaterial = fillMaterial.dup(); |
99 | } else { | 99 | } else { |
100 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 100 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
101 | } | 101 | } |
102 | 102 | ||
103 | if(fillColor) { | 103 | if(fillColor) { |
104 | if(this._fillMaterial.hasProperty("color")) { | 104 | if(this._fillMaterial.hasProperty("color")) { |
105 | this._fillMaterial.setProperty( "color", this._fillColor ); | 105 | this._fillMaterial.setProperty( "color", this._fillColor ); |
106 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { | 106 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { |
107 | this._fillMaterial.setGradientData(this._fillColor.color); | 107 | this._fillMaterial.setGradientData(this._fillColor.color); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | }, | 111 | }, |
112 | 112 | ||
113 | /////////////////////////////////////////////////////////////////////// | 113 | /////////////////////////////////////////////////////////////////////// |
114 | // Property Accessors | 114 | // Property Accessors |
115 | /////////////////////////////////////////////////////////////////////// | 115 | /////////////////////////////////////////////////////////////////////// |
116 | // TODO - Use getters/setters in the future | 116 | // TODO - Use getters/setters in the future |
117 | getStrokeWidth: { | 117 | getStrokeWidth: { |
118 | value: function() { | 118 | value: function() { |
119 | return this._strokeWidth; | 119 | return this._strokeWidth; |
120 | } | 120 | } |
121 | }, | 121 | }, |
122 | 122 | ||
123 | setStrokeWidth: { | 123 | setStrokeWidth: { |
124 | value: function(w) { | 124 | value: function(w) { |
125 | this._strokeWidth = w; | 125 | this._strokeWidth = w; |
126 | } | 126 | } |
127 | }, | 127 | }, |
128 | 128 | ||
129 | getStrokeMaterial: { | 129 | getStrokeMaterial: { |
130 | value: function() { | 130 | value: function() { |
131 | return this._strokeMaterial; | 131 | return this._strokeMaterial; |
132 | } | 132 | } |
133 | }, | 133 | }, |
134 | 134 | ||
135 | setStrokeMaterial: { | 135 | setStrokeMaterial: { |
136 | value: function(m) { | 136 | value: function(m) { |
137 | this._strokeMaterial = m; | 137 | this._strokeMaterial = m; |
138 | } | 138 | } |
139 | }, | 139 | }, |
140 | 140 | ||
141 | getFillMaterial: { | 141 | getFillMaterial: { |
142 | value: function() { | 142 | value: function() { |
143 | return this._fillMaterial; | 143 | return this._fillMaterial; |
144 | } | 144 | } |
145 | }, | 145 | }, |
146 | 146 | ||
147 | setFillMaterial: { | 147 | setFillMaterial: { |
148 | value: function(m) { | 148 | value: function(m) { |
149 | this._fillMaterial = m; | 149 | this._fillMaterial = m; |
150 | } | 150 | } |
151 | }, | 151 | }, |
152 | 152 | ||
153 | getRadius: { | 153 | getRadius: { |
154 | value: function() { | 154 | value: function() { |
155 | return this._radius; | 155 | return this._radius; |
156 | } | 156 | } |
157 | }, | 157 | }, |
158 | 158 | ||
159 | setRadius: { | 159 | setRadius: { |
160 | value: function(r) { | 160 | value: function(r) { |
161 | this._radius = r; | 161 | this._radius = r; |
162 | } | 162 | } |
163 | }, | 163 | }, |
164 | 164 | ||
165 | getInnerRadius: { | 165 | getInnerRadius: { |
166 | value: function() { | 166 | value: function() { |
167 | return this._innerRadius; | 167 | return this._innerRadius; |
168 | } | 168 | } |
169 | }, | 169 | }, |
170 | 170 | ||
171 | setInnerRadius: { | 171 | setInnerRadius: { |
172 | value: function(r) { | 172 | value: function(r) { |
173 | this._innerRadius = r; | 173 | this._innerRadius = r; |
174 | } | 174 | } |
175 | }, | 175 | }, |
176 | 176 | ||
177 | getStrokeStyle: { | 177 | getStrokeStyle: { |
178 | value: function() { | 178 | value: function() { |
179 | return this._strokeStyle; | 179 | return this._strokeStyle; |
180 | } | 180 | } |
181 | }, | 181 | }, |
182 | 182 | ||
183 | setStrokeStyle: { | 183 | setStrokeStyle: { |
184 | value: function(s) { | 184 | value: function(s) { |
185 | this._strokeStyle = s; | 185 | this._strokeStyle = s; |