The canvas 2d rendering context uses a flat Cartesian coordinate system.
Its origin (0, 0) is at the top left.
Moving to the right will increase the x value.
Moving downwards will increase the y value.
<!DOCTYPE html> <html> <head> <title>Learning the basics of canvas</title> <meta charset="utf-8"> // w ww.jav a 2 s.c om <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { let canvas = $("#myCanvas"); let context = canvas.get(0).getContext("2d"); context.fillRect(40, 40, 100, 100); }); </script> </head> <body> <canvas id="myCanvas" width="500" height="500"> Insert fallback content here </canvas> </body> </html>