@@ -14,21 +14,20 @@ function DialDisplay(options) {
1414 } , options ) ;
1515
1616 this . value = 0 ;
17- this . reset ( ) ;
17+ this . isFullDraw = true ;
1818}
1919
20- DialDisplay . prototype . reset = function ( ) {
21- this . isFirstDraw = true ;
20+ DialDisplay . prototype . queueRedraw = function ( ) {
21+ this . isFullDraw = true ;
22+ this . prevDrawnValue = null ;
2223} ;
2324
2425DialDisplay . prototype . set = function ( value ) {
25- this . prevValue = this . value ;
2626 this . value = value ;
2727} ;
2828
2929DialDisplay . prototype . step = function ( step ) {
3030 "ram" ;
31- let prevValue = this . prevValue != null ? this . prevValue : this . value ;
3231 this . value += step ;
3332 //g.setFont("Vector:30");
3433 //g.drawString(this.value);
@@ -47,22 +46,22 @@ DialDisplay.prototype.step = function(step) {
4746 if ( ! isFill ) g . drawCircle ( x , y , rad ) ;
4847 if ( isFill ) g . fillCircle ( x , y , rad ) ;
4948 }
50- if ( this . isFirstDraw ) {
49+ if ( this . isFullDraw ) {
5150 g . setColor ( 0 , 0 , 0 ) . fillCircle ( CENTER . x , CENTER . y , 25 ) ;
5251 g . setColor ( 1 , 1 , 1 ) . drawCircle ( CENTER . x , CENTER . y , 25 ) ;
5352 for ( let i = 0 ; i < this . options . stepsPerWholeTurn ; i ++ ) {
5453 drawCircle ( i , 1 , 1 , 1 , 1 , true ) ;
5554 }
56- this . isFirstDraw = false ;
55+ this . isFullDraw = false ;
5756 }
5857
5958 //drawCircle(this.value, 1, 1, 1, 2, false);
6059 //drawCircle(prevValue, 0, 0, 0, 2, false);
61- g . setColor ( 0 , 0 , 0 ) . drawLine ( CENTER . x , CENTER . y , CENTER . x + 23 * Math . sin ( prevValue * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) , CENTER . y - 23 * Math . cos ( prevValue * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) ) ;
60+ g . setColor ( 0 , 0 , 0 ) . drawLine ( CENTER . x , CENTER . y , CENTER . x + 23 * Math . sin ( this . prevDrawnValue * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) , CENTER . y - 23 * Math . cos ( this . prevDrawnValue * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) ) ;
6261 g . setColor ( 1 , 1 , 1 ) . drawLine ( CENTER . x , CENTER . y , CENTER . x + 23 * Math . sin ( this . value * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) , CENTER . y - 23 * Math . cos ( this . value * ( 2 * Math . PI / this . options . stepsPerWholeTurn ) ) ) ;
6362 g . setColor ( 0 , 0 , 0 ) . fillCircle ( CENTER . x , CENTER . y , 9 ) ;
6463
65- delete this . prevValue ;
64+ this . prevDrawnValue = this . value ;
6665} ;
6766
6867exports = DialDisplay ;
0 commit comments