To draw a line on a canvas, we need to:
moveTo
some starting point.lineTo
an end point.stroke
.Here is what it looks like using javascript:
First, try adding a second line.
Then, to do something a little more involved, click on the image
above to bring
the editor containing the code for the html window displayed on
the right. Then, change the value of the variable
explain
to true
to see the result.
Note that you should not expect to understand the rest of the code in
the html editor at this point, except to note that I added a function call,
clearRect()
, which erases everything that was previously on the
canvas. This way, you can modify the code and make sure that the drawing
only includes the code you executed that time.
[The following table has been adapted from Wikipedia.]
|
|
|
Keep your personal notes here. These notes are stored by your browser on your own computer, and will be available from any page on this site. You can choose to use html syntax for formatting.