Canvas size in pixels (Javascript)? -
i creating application web browsers. user clicks on position of screen. position stored x-value , y-value in pixels.
now draw rectangle on canvas method: ctx.rect(x,x,50,50); unfortunately these values not fit pixels in web browser.
do know how change pixel in webbrowser create rect @ right position?
your canvas size have match style size.
for ex. if canvas 100px x 100px must have
mycanvas.width = 100 mycanvas.height= 100 mycanvas.style.width = '100px' mycanvas.style.height = '100px'
only in case "your canvas bits size match screen bits size"
Comments
Post a Comment