File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,12 @@ function dataMappingGuide(canvas,src){
7979 return [ cvs . color , cvs . alpha ] ;
8080 } ;
8181 //### 3) focus area ###
82- //
82+ //it puts focus on a area that is specified using integer coordinates
8383 cvs . xy = function ( x , y ) {
8484 // - x: a positive integer index for horizontal division
8585 // - y: a positive integer index for vertical division
86+ x = ! x ?1 :x ;
87+ y = ! y ?1 :y ;
8688 x = + x < 1 ?1 :Math . floor ( + x ) ;
8789 y = + y < 1 ?1 :Math . floor ( + y ) ;
8890 cvs . X = x > cvs . Nx ?cvs . Nx :x ;
@@ -100,19 +102,24 @@ function dataMappingGuide(canvas,src){
100102 ctx = null ;
101103 return [ cvs . X , cvs . Y ] ;
102104 } ;
103- //it clears canvas element
105+ //it clears canvas
104106 cvs . clear = function ( ) {
105107 var ctx = canvas . getContext ( '2d' ) ;
106108 ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
107109 ctx = null ;
108110 return [ canvas . width , canvas . height ] ;
109111 } ;
110- //
111- cvs . next = function ( ) { } ;
112- //
112+ //it returns coordinates for the next focus area as form of [x,y]
113+ cvs . next = function ( ) {
114+ var x2 = cvs . X + 1 , y2 = ( x2 < cvs . Nx + 1 ) ?cvs . Y :cvs . Y + 1 ;
115+ y2 = ( y2 < cvs . Ny + 1 ) ?y2 :1 ;
116+ x2 = ( x2 < cvs . Nx + 1 ) ?x2 :1 ;
117+ return [ x2 , y2 ] ;
118+ } ;
119+ //it returns the current state of sampling
113120 cvs . info = function ( ) {
114121 return {
115- area :canvas . width + 'x' + canvas . height + 'pixels' ,
122+ area :canvas . width + 'x' + canvas . height + ' pixels' ,
116123 divisions :cvs . Nx + 'x' + cvs . Ny
117124 } ;
118125 } ;
You can’t perform that action at this time.
0 commit comments