Notes:
Two (TNT)Points make a line, right? Good ole Geometry! Two examples of a TNTLine are shown above. A quick peek at the source code (tntLine.js) reveals we first created a custom TNTColor (tangerine), followed by a custom TNTStroke (tangerineStroke). Then, we had all the ingredients we needed to make a TNTLine: a couple of TNTPoints and a TNTStroke.
TNTLine Features and Usage:
| Primary Attributes: | 2 TNTPoints and a TNTStroke |
|---|---|
| To Create: | The example above was created by:
//designer colors
var tangerine = new TNTColor(250, 50, 5, "tangerine");
//requires rtint(int), gtint(int), btint(int) and name(String)
//designer strokes
//default strokes are .2 in thickness
var tangerineStroke = new TNTStroke(tangerine, .5);
//requires a color(TNTStroke) and thickness(double)
pinkStroke.lineWidth = 1;
//special points/components
var ptA = new TNTPoint(-15, 3);
var ptB = new TNTPoint(9, -10);
var ptC = new TNTPoint(3, 12);
//TNTGraphic Objects
var lineAB = new TNTLine(ptA, ptB, tangerineStroke);
lineAB.drawTNTLine(context);
var lineAC = new TNTLine(ptA, ptC, pinkStroke);
lineAC.accentColor = black; //can change accentColor property to show points
lineAC.showPoints = true;
lineAC.drawTNTLine(context);
|
| To Draw: | lineAB.drawTNTLine(context); |
| Comments: | The TNTStroke attribute of a TNTLine is an object that contains both the thickness and the color of the line. A common mistake when creating a TNTLine is to provide merely a TNTColor rather than a TNTStroke. Notice in the example code above how we used the 'lineWidth' attribute to change the thickness of the 'pinkStroke' |
| Even More: | When drawing a TNTLine as well as most other library shapes with the exception of TNTPoint, you just have to provide 'context' as a parameter for the drawing function. That 'context' is like providing the proper, scaled graph paper for the graphical object. The TNTPoints used to make the TNTLine may be shown or hidden by using the 'showPoints' attribute (set to either true or false). Accent colors are those used for showing the points when you wish them shown. |
