This is a demo on how JavaScript can be used for drawing graphics objects
like lines and circles. The objects are drawn by adding points to the drawing
area. For lines we use the classic
Bresenham's algorithm.
For circles we just
use its equation. The origin of the coordinate system is in the top left
corner of the area below. Only a part of a line/circle inside the drawing
area is displayed. The previously plotted line/circle is erased.
The script is designed for a W3C compliant browser, e.g.
Firefox.
Input the coordinates:
| Lines (x1,y1,x2,y2) | Circles (x,y,r) |
|---|---|