github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/website/source/assets/javascripts/app/Engine.Polygon.js (about) 1 (function( 2 Engine, 3 Vector 4 ){ 5 6 Engine.Polygon = function(a, b, c, color, strokeColor){ 7 this.a = a; 8 this.b = b; 9 this.c = c; 10 11 this.color = Engine.clone(color); 12 this.strokeColor = strokeColor ? Engine.clone(strokeColor) : Engine.clone(color); 13 14 if (strokeColor) { 15 this.strokeColor = Engine.clone(strokeColor); 16 } else { 17 this.strokeColor = Engine.clone(color); 18 } 19 20 this.strokeWidth = 0.25; 21 this.maxStrokeS = this.strokeColor.s; 22 this.maxStrokeL = this.strokeColor.l; 23 this.maxColorL = this.color.l; 24 25 this.strokeColor.s = 0; 26 this.strokeColor.l = 100; 27 this.color.l = 0; 28 29 this.fillStyle = this.hslaTemplate.substitute(this.color); 30 this.strokeStyle = this.hslaTemplate.substitute(this.strokeColor); 31 }; 32 33 Engine.Polygon.prototype = { 34 35 rgbaTemplate: 'rgba({r},{g},{b},{a})', 36 hslaTemplate: 'hsla({h},{s}%,{l}%,{a})', 37 38 hueShiftSpeed: 20, 39 duration: 2, 40 delay: 0, 41 start: 0, 42 43 // Determine color fill? 44 update: function(engine){ 45 var delta; 46 47 if (this.simple) { 48 return; 49 } 50 51 this.start += engine.tick; 52 53 delta = this.start; 54 55 if ( 56 delta > this.delay && 57 delta < this.delay + this.duration + 1 && 58 this.color.l < this.maxColorL 59 ) { 60 this.color.l = this.maxColorL * (delta - this.delay) / this.duration; 61 62 this.strokeColor.s = this.maxStrokeS * (delta - this.delay) / this.duration; 63 this.strokeColor.l = (this.maxStrokeL - 100) * (delta - this.delay) / this.duration + 100; 64 65 this.strokeWidth = 1.5 * (delta - this.delay) / this.duration + 0.25; 66 67 if (this.color.l > this.maxColorL) { 68 this.color.l = this.maxColorL; 69 this.strokeColor.l = this.maxStrokeL; 70 this.strokeWidth = 1.5; 71 } 72 73 this.strokeStyle = this.hslaTemplate.substitute(this.strokeColor); 74 this.fillStyle = this.hslaTemplate.substitute(this.color); 75 } 76 } 77 78 }; 79 80 })(window.Engine, window.Vector);