Wrong placement of CanvasGadget(?)

Just starting out? Need help? Post your questions and find answers here.
es_91
Posts: 56
Joined: Sat Aug 29, 2015 10:25 pm

Wrong placement of CanvasGadget(?)

Post by es_91 »

The coordinates of this canvas should cover exactly the whole window. It seems it doesn't.

Code: Select all


enableExplicit

define  gadget
define  window

declare  sizing  (  )
declare  drawToCanvas  (  )


procedure  drawToCanvas  (  )
	
	shared  gadget
	
	if  (  startDrawing  (  canvasOutput  (   gadget  )  )  )
		
		box  (  #null,  
		        #null,  
		        gadgetWidth  (  gadget  ),  
		        gadgetHeight  (  gadget  ),  
		        #black  )
		
		stopDrawing  (  )
		
	endIf
	
endProcedure


procedure  sizing  (  )
	
	shared  gadget
	shared  window
	
	resizeGadget  (  gadget,  
	                 #null,  
	                 #null,  
	                 windowWidth  (  window  ),  
	                 windowHeight  (  window  )  )
	
	drawToCanvas  (  )
	
endProcedure


window  =  openWindow  (  #pb_any,  
                          #null,  
                          #null,  
                          #null,  
                          #null,  
                          "Everything black? Try zooming!",  
                          #pb_window_background  )

gadget  =  canvasGadget  (  #pb_any,  
                            #null,  
                            #null,  
                            #null,  
                            #null  )

bindEvent  (  #pb_event_sizeWindow,  
              @  sizing  (  )  )

sizing  (  )

disableExplicit


Using latest Chrome 67% zoom factor and maximized window on Windows 10 x86, white borders are visible.


PLEASE MAKE SURE THIS IMAGE IS DISPLAYED AT FULL SIZE
Image


Supersizing the canvas or over-enlarging the box ( ) function's position parameters won't solve all of the problem. A thin line of blue background still shines through at the bottom.

Code: Select all


enableExplicit

define  gadget
define  window

declare  sizing  (  )
declare  drawToCanvas  (  )


procedure  drawToCanvas  (  )
	
	shared  gadget
	
	if  (  startDrawing  (  canvasOutput  (   gadget  )  )  )
		
		box  (  #null,  
		        #null,  
		        gadgetWidth  (  gadget  ),  
		        gadgetHeight  (  gadget  ),  
		        #black  )
		
		stopDrawing  (  )
		
	endIf
	
endProcedure


procedure  sizing  (  )
	
	shared  gadget
	shared  window
	
	; Try it! It helps... but it does not seem to be all-correct:
	resizeGadget  (  gadget,  
	                 -  20,  
	                 -  20,  
	                 windowWidth  (  window  )  +  
	                 40,  
	                 windowHeight  (  window  )  +  
	                 40  )
	
	drawToCanvas  (  )
	
endProcedure


window  =  openWindow  (  #pb_any,  
                          #null,  
                          #null,  
                          #null,  
                          #null,  
                          "Everything black? Try zooming!",  
                          #pb_window_background  )

gadget  =  canvasGadget  (  #pb_any,  
                            #null,  
                            #null,  
                            #null,  
                            #null  )

bindEvent  (  #pb_event_sizeWindow,  
              @  sizing  (  )  )

sizing  (  )

disableExplicit


PLEASE MAKE SURE THIS IMAGE IS DISPLAYED AT FULL SIZE
Image


In fact, if you proceed like in these code examples, the page zoom of a browser will propably always mess-up with a few pixels of the screen. The canvas should, however, fill the entire screen; everything should be black.

mfG
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Wrong placement of CanvasGadget(?)

Post by Fred »

It's more likely a zoom issue in Chrome, the HTML itself doesn't change when zooming. It doesn't happen in Firefox for example.
Post Reply