diff options
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-x | js/lib/geom/line.js | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index aa27fa87..a706eb93 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js | |||
@@ -159,7 +159,14 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
159 | rtnStr += "xAdj: " + this._xAdj + "\n"; | 159 | rtnStr += "xAdj: " + this._xAdj + "\n"; |
160 | rtnStr += "yAdj: " + this._yAdj + "\n"; | 160 | rtnStr += "yAdj: " + this._yAdj + "\n"; |
161 | rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; | 161 | rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; |
162 | rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; | 162 | |
163 | if(this._strokeColor.gradientMode) { | ||
164 | rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n"; | ||
165 | rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n"; | ||
166 | } else { | ||
167 | rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; | ||
168 | } | ||
169 | |||
163 | rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; | 170 | rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; |
164 | rtnStr += "slope: " + String(this._slope) + "\n"; | 171 | rtnStr += "slope: " + String(this._slope) + "\n"; |
165 | 172 | ||
@@ -192,7 +199,15 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
192 | 199 | ||
193 | var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); | 200 | var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); |
194 | this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); | 201 | this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); |
195 | this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); | 202 | |
203 | if(importStr.indexOf("strokeGradientMode: ") < 0) | ||
204 | { | ||
205 | this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); | ||
206 | } else { | ||
207 | this._strokeColor = {}; | ||
208 | this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr ); | ||
209 | this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr )); | ||
210 | } | ||
196 | 211 | ||
197 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 212 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); |
198 | if (!strokeMat) { | 213 | if (!strokeMat) { |
@@ -395,16 +410,46 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
395 | if (!ctx) return; | 410 | if (!ctx) return; |
396 | 411 | ||
397 | // set up the stroke style | 412 | // set up the stroke style |
398 | var lineWidth = this._strokeWidth; | 413 | var lineWidth = this._strokeWidth, |
414 | w = this._width, | ||
415 | h = this._height; | ||
416 | |||
417 | var c, | ||
418 | gradient, | ||
419 | colors, | ||
420 | len, | ||
421 | n, | ||
422 | position, | ||
423 | cs; | ||
424 | |||
399 | ctx.beginPath(); | 425 | ctx.beginPath(); |
400 | ctx.lineWidth = lineWidth; | 426 | ctx.lineWidth = lineWidth; |
401 | if (this._strokeColor) { | 427 | if (this._strokeColor) { |
402 | var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; | 428 | if(this._strokeColor.gradientMode) { |
403 | ctx.strokeStyle = c; | 429 | if(this._strokeColor.gradientMode === "radial") { |
430 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)); | ||
431 | } else { | ||
432 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); | ||
433 | } | ||
434 | colors = this._strokeColor.color; | ||
435 | |||
436 | len = colors.length; | ||
437 | |||
438 | for(n=0; n<len; n++) { | ||
439 | position = colors[n].position/100; | ||
440 | cs = colors[n].value; | ||
441 | gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")"); | ||
442 | } | ||
443 | |||
444 | ctx.strokeStyle = gradient; | ||
445 | |||
446 | } else { | ||
447 | c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; | ||
448 | ctx.strokeStyle = c; | ||
449 | } | ||
404 | 450 | ||
405 | // get the points | 451 | // get the points |
406 | var p0, p1; | 452 | var p0, p1; |
407 | var w = this._width, h = this._height; | ||
408 | if(this._slope === "vertical") { | 453 | if(this._slope === "vertical") { |
409 | p0 = [0.5*w, 0]; | 454 | p0 = [0.5*w, 0]; |
410 | p1 = [0.5*w, h]; | 455 | p1 = [0.5*w, h]; |