My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

Turtle geometry in jQuery.

This jQuery extension adds $(elt).turn(), turnto, move, moveto, mirror, touches, encloses, center, direction, pen, and dot to jquery. Any element can be turned and walked around the screen using turtle geometry and hit-tested for overlap or geometric containment with any other element. The extension brings the spirit of LOGO to Javascript.

This extension is designed for education, but it is robust and efficient enough for professional use. The library allows you to write simple sprite-based games and graphics that use relative or absolute motion in a few dozen lines of code and without having to deal with cartesian coordinates and without having to debug a variety of browser quirks.

Key features of this extension that avoid learning barriers for beginning programmers:

  • No need to understand cartesian coordinates. Trigonometry of turtle graphics is handled.
  • Plays nicely with css: turtle heading is css rotation, and position is set using css attributes.
  • Mouse events are easy: move to the location of a mouse event by $(elt).moveto(event).
  • Hit testing is easy: pixel-precise rotated-rectangle hit testing is implemented by $(elt).touches(otherelt).
  • Objects are positioned by their center, which simplifies most game calculations.
  • Fractional positions are remembered, avoiding roundoff problems at small steps or angles.
  • Pen and fill paint on a full-document canvas created on-demand.
  • Turning towards another object is implemented by $(elt).turnto(otherelt), an alternative to $(elt).turnto(degrees).
  • Window scrolling is also easy and is done by $(window).moveto(pos).

Powered by Google Project Hosting