[Solved]HTML canvas behaving abnormally | Sololearn: Learn to code for FREE!


[Solved]HTML canvas behaving abnormally

I have made a simple canvas code. But if I increase the height/width of the canvas the shapes changes their scale and behave abnormally. For example : I have a line ctx.moveTo(10, 10); ctx.lineTo(10, 20); This should create a straight line. Now if I increase the width of the canvas and re run the code the line gets longer.

4/24/2021 8:16:16 AM


6 Answers

New Answer


Got the answer by Tejas Buddy https://code.sololearn.com/Wqh98ALN0h42/?ref=app


Can you send your code?


Canvas size and canvas element size are two different properties See: https://www.sololearn.com/post/119555/?ref=app


Krish [less active] ๐Ÿ˜ƒGreat also go through posts .


I was just doing that Tejas ๐Ÿ˜Š๐Ÿ˜Š