Canvas size in pixels (Javascript)? -


enter image description herei 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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -