Plotting graphics

This is a demo on how JavaScript can be used for drawing graphics objects like lines and circles with mouse. 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.
Click, drag, and release the mouse within the drawing area to draw. JavaScript is slooowww, wait several seconds for an object to appear before drawing the next one.
The script is designed for a W3C compliant browser, e.g. Firefox.

Input coordinates:

Lines (x1,y1,x2,y2)Circles (x,y,r)

Drawing area