aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/line.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-xjs/lib/geom/line.js38
1 files changed, 34 insertions, 4 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index da63b21c..eaa26cf0 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -348,16 +348,46 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
348 if (!ctx) return; 348 if (!ctx) return;
349 349
350 // set up the stroke style 350 // set up the stroke style
351 var lineWidth = this._strokeWidth; 351 var lineWidth = this._strokeWidth,
352 w = this._width,
353 h = this._height;
354
355 var c,
356 gradient,
357 colors,
358 len,
359 n,
360 position,
361 cs;
362
352 ctx.beginPath(); 363 ctx.beginPath();
353 ctx.lineWidth = lineWidth; 364 ctx.lineWidth = lineWidth;
354 if (this._strokeColor) { 365 if (this._strokeColor) {
355 var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; 366 if(this._strokeColor.gradientMode) {
356 ctx.strokeStyle = c; 367 if(this._strokeColor.gradientMode === "radial") {
368 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, h/2);
369 } else {
370 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
371 }
372 colors = this._strokeColor.color;
373
374 len = colors.length;
375
376 for(n=0; n<len; n++) {
377 position = colors[n].position/100;
378 cs = colors[n].value;
379 gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")");
380 }
381
382 ctx.strokeStyle = gradient;
383
384 } else {
385 c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";
386 ctx.strokeStyle = c;
387 }
357 388
358 // get the points 389 // get the points
359 var p0, p1; 390 var p0, p1;
360 var w = this._width, h = this._height;
361 if(this._slope === "vertical") { 391 if(this._slope === "vertical") {
362 p0 = [0.5*w, 0]; 392 p0 = [0.5*w, 0];
363 p1 = [0.5*w, h]; 393 p1 = [0.5*w, h];