1+ var _wallColorSpeed = .1 ;
2+ var _wallColorPercent = 0 ;
3+ var _wallColorDirection = _wallColorSpeed ;
4+
15function drawGameBoard ( context )
26{
7+ _wallColorPercent += _wallColorDirection ;
8+ if ( _wallColorPercent > 1 )
9+ {
10+ _wallColorPercent = 1 ;
11+ _wallColorDirection = - _wallColorSpeed ;
12+ }
13+ else if ( _wallColorPercent < 0 )
14+ {
15+ _wallColorPercent = 0 ;
16+ _wallColorDirection = _wallColorSpeed ;
17+ }
18+ var wcp = _wallColorPercent ;
19+
320 context . save ( ) ;
421 context . globalAlpha = 1 ;
522 context . globalCompositeOperation = "source-over" ;
@@ -10,16 +27,14 @@ function drawGameBoard(context)
1027 context . closePath ( ) ;
1128 context . fill ( ) ;
1229
13- context . strokeStyle = "#eeeeee" ;
14- context . lineWidth = 3 ;
15- context . stroke ( ) ;
16-
1730 context . globalCompositeOperation = "source-atop" ;
18-
1931 context . fillStyle = "#000000" ;
2032 context . fillRect ( 0 , 0 , 800 , 800 ) ;
21-
22- context . strokeStyle = "#001111" ;
33+
34+ var lc1 = { r :0 , g :30 , b :30 } ;
35+ var lc2 = { r :0 , g :20 , b :20 } ;
36+ context . strokeStyle = "rgb(" + Math . ceil ( tween ( lc1 . r , lc2 . r , wcp ) ) + "," + Math . ceil ( tween ( lc1 . g , lc2 . g , wcp ) ) + "," + Math . ceil ( tween ( lc1 . b , lc2 . b , wcp ) ) + ")" ;
37+ context . lineWidth = 3 ;
2338 for ( var i = 0 ; i < 20 ; i ++ )
2439 {
2540 var d = i * ( 800 / 20 ) ;
@@ -34,6 +49,21 @@ function drawGameBoard(context)
3449 context . closePath ( ) ;
3550 context . stroke ( ) ;
3651 }
52+
53+ //Todo refactor this function so that it has it's own private space for variables
54+ var wc1 = { r :120 , g :160 , b :160 } ;
55+ var wc2 = { r :120 , g :255 , b :255 } ;
56+ context . strokeStyle = "rgb(" + Math . ceil ( tween ( wc1 . r , wc2 . r , wcp ) ) + "," + Math . ceil ( tween ( wc1 . g , wc2 . g , wcp ) ) + "," + Math . ceil ( tween ( wc1 . b , wc2 . b , wcp ) ) + ")" ;
57+ context . lineWidth = 5 ;
58+ context . beginPath ( ) ;
59+ context . arc ( 400 , 400 , 398 , 0 , Math . PI * 2 , true ) ;
60+ context . closePath ( ) ;
61+ context . stroke ( ) ;
3762
3863 context . restore ( ) ;
64+ }
65+
66+ function tween ( value1 , value2 , percent )
67+ {
68+ return ( value1 * percent ) + ( value2 * ( 1 - percent ) ) ;
3969 }
0 commit comments