Your browser does not support HTML5 Canvas

Notes:

This little ghost has really gotten around! It started out as a JavaScript entity in CodeHS and was adopted into the Python Turtle world in a Tracy the Turtle application.

It was featured in a novice's Processing application, and found it's place in the JSGS Shapes Library!

Click the 'Reload' button to see our Aggie TNTGhost's eyes reposition.

TNTGhost Features and Usage:
Primary Attributes:

4 Parameters:

  • head: TNTDisk; this sets the width and position of the TNTGhost
  • bodyLength: a positive real number; the distance from the center of the head to the feet interface. It is designed to be no less than the radius of the ghost's head
  • numFeet: an integer in [0, 8]
  • eyeInfo: an Array of various parts that contribute to the design of the eyes
    1. pupilFactor (fraction of base TNTDisk)
    2. pupilPlacement (distance from eyeCenter to pupilCenter)
    3. shouldRandomlyPlacePupil (boolean)
    4. shouldPupilBeTangent(boolean)
    5. dirn(direction of eyes, degrees; positive: ccw)
    6. eyeColors(Array of TNTColors (base, pupil))
    7. eyeStrokes (Array of TNTStrokes (base, pupil))
To Create:

The example above was created by:

//designer colors/strokes
var aggieMaroon = new TNTColor(170, 0, 65, "aggieMaroon");
var aggieGray = new TNTColor(218, 217, 216, "aggieGray");
var aggieMaroonStroke = new TNTStroke(aggieMaroon, .5);

//ghost head
var center = new TNTPoint(-1, 5);
var radius = 4;
var ghostHead = new TNTDisk(center, radius, aggieMaroon, null);

//special points/components
var pupilFactor = .5;
//eyeInfo: pupilFactor, pupilPlacement, shouldRandomlyPlacePupil, 
shouldPupilBeTangent, dirn, eyeColors, eyeStrokes
var eyeColors = new Array(offWhite, black);
var eyeStrokes = new Array(lightGrayStroke, blueStroke);
var eyeInfo = new Array(pupilFactor, 1.2, true, false, 45, eyeColors, eyeStrokes);

var myGhost = new TNTGhost(ghostHead, 10, 5, eyeInfo);
myGhost.drawTNTGhost(context);
                                    
To Draw:
myGhost.drawTNTGhost(context);
Comments:

Note that the 'eyeInfo' parameter is itself a non-homogeneous Array: there are various datatypes in it, including two other Arrays!