66 * To change this template use File | Settings | File Templates.
77 */
88
9- var BRUSH_SIZE = 1 ,
9+ var BRUSH_SIZE = 3 ,
1010 BRUSH_PRESSURE = 1 ;
1111
1212function lightTrail ( context , color )
@@ -18,26 +18,28 @@ lightTrail.prototype =
1818{
1919 context : null ,
2020
21- mouseX : null , mouseY : null ,
21+ positionX : null , positionY : null ,
2222
2323 painters : null ,
2424
2525 interval : null ,
2626
2727 color :[ 0 , 0 , 0 ] ,
2828
29+ lightCycle : new Image ( ) ,
30+
2931 init : function ( context , color )
3032 {
3133 var scope = this ;
32-
34+ scope . lightCycle . src = "images/lightcycle.png" ;
3335 this . context = context ;
3436 this . context . globalCompositeOperation = 'source-over' ;
3537
36- this . mouseX = 400 ;
37- this . mouseY = 400 ;
38+ this . positionX = 400 ;
39+ this . positionY = 400 ;
3840
3941 if ( ! color && color . length != 0 ) {
40- this . color = color ;
42+ scope . color = color ;
4143 } // else defaults to RGB 0,0,0
4244
4345 this . painters = new Array ( ) ;
@@ -56,16 +58,18 @@ lightTrail.prototype =
5658 scope . context . lineWidth = BRUSH_SIZE ;
5759 scope . context . strokeStyle = "rgba(" + scope . color [ 0 ] + ", " + scope . color [ 1 ] + ", " + scope . color [ 2 ] + ", " + 0.05 * BRUSH_PRESSURE + ")" ;
5860
59- for ( i = 0 ; i < scope . painters . length ; i ++ )
61+ for ( i = 0 ; i < scope . painters . length ; i ++ )
6062 {
6163 scope . context . beginPath ( ) ;
6264 scope . context . moveTo ( scope . painters [ i ] . dx , scope . painters [ i ] . dy ) ;
6365
64- scope . painters [ i ] . dx -= scope . painters [ i ] . ax = ( scope . painters [ i ] . ax + ( scope . painters [ i ] . dx - scope . mouseX ) * scope . painters [ i ] . div ) * scope . painters [ i ] . ease ;
65- scope . painters [ i ] . dy -= scope . painters [ i ] . ay = ( scope . painters [ i ] . ay + ( scope . painters [ i ] . dy - scope . mouseY ) * scope . painters [ i ] . div ) * scope . painters [ i ] . ease ;
66+ scope . painters [ i ] . dx -= scope . painters [ i ] . ax = ( scope . painters [ i ] . ax + ( scope . painters [ i ] . dx - scope . positionX ) * scope . painters [ i ] . div ) * scope . painters [ i ] . ease ;
67+ scope . painters [ i ] . dy -= scope . painters [ i ] . ay = ( scope . painters [ i ] . ay + ( scope . painters [ i ] . dy - scope . positionY ) * scope . painters [ i ] . div ) * scope . painters [ i ] . ease ;
6668 scope . context . lineTo ( scope . painters [ i ] . dx , scope . painters [ i ] . dy ) ;
6769 scope . context . stroke ( ) ;
6870 }
71+
72+ scope . context . drawImage ( scope . lightCycle , scope . painters [ i - 1 ] . dx , scope . painters [ i - 1 ] . dy , 33.33 , 12.66 ) ;
6973 }
7074 } ,
7175
@@ -75,25 +79,25 @@ lightTrail.prototype =
7579 } ,
7680
7781 //coordinates where the player starts
78- strokeStart : function ( mouseX , mouseY )
82+ strokeStart : function ( positionX , positionY )
7983 {
80- this . mouseX = mouseX ;
81- this . mouseY = mouseY
84+ this . positionX = positionX ;
85+ this . positionY = positionY ;
8286
8387 for ( var i = 0 ; i < this . painters . length ; i ++ )
8488 {
85- this . painters [ i ] . dx = mouseX ;
86- this . painters [ i ] . dy = mouseY ;
89+ this . painters [ i ] . dx = positionX ;
90+ this . painters [ i ] . dy = positionY ;
8791 }
8892
8993 this . shouldDraw = true ;
9094 } ,
9195
9296 //new coordinates moved to
93- stroke : function ( mouseX , mouseY )
97+ stroke : function ( positionX , positionY )
9498 {
95- this . mouseX = mouseX ;
96- this . mouseY = mouseY ;
99+ this . positionX = positionX ;
100+ this . positionY = positionY ;
97101 } ,
98102
99103 //end
0 commit comments