javascript - lineTo on HTML 5 canvas not working properly -


i'm trying learn canvas.

i trying draw lines using moveto() , lineto() on canvas.

the co-ordinates give , point rendered on canvas not matching

i have taken canvas of size 500px x 500px

for (0,0) coming fine.

for other points not matching co-ordinates

for (300, 150) painting @ (500,500).

i'm not getting why happening because if set canvas size t0 300px x 150px painting correctly

here js

    var context = document.getelementbyid("mycanvas").getcontext("2d");      context.moveto(0, 0);     context.lineto(100, 100);     context.lineto(100, 100);     context.lineto(200, 100);     context.lineto(300, 150);     context.stroke(); 

jsfiddle here

can 1 please tell me i'm wrong

set height , width of canvas element directly:
<canvas id="mycanvas" width="500" height="500"> </canvas>

fiddle: http://jsfiddle.net/nluex/2/


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

objective c - Ownership modifiers with manual reference counting -

python 3.x - Mapping specific letters onto a list of words -