Notes:
You, too, can be a big wheel with this shape. See its relation to a TNTPie? Or is it just a TNTDisk with a bunch of equally-spaced TNTLines? The green image shows that drawing the 'rim' of the wheel is optional.
Features and Usage:
| Primary Attributes: |
5 parameters: The showRim property can be used to show/hide the wheel rim; the lineCapStyle property can be set to change the endcap shapes of the lines ("butt", "beveled", "round") |
|---|---|
| To Create: |
var baylorGold = new TNTColor(253, 192, 0); |
| To Draw: |
myWheel.drawTNTWheel(context); |
| Comments: | The lineCapStyle property can be adjusted to make the spoke ends smooth or rectangular. See the code for details. |
| Even More: |
For giggles and grins we thought you'd like to see how these suckers are drawn. Here is a snippet from the graphics engine:
function drawTNTWheel(context) {
var myRimStroke = new TNTStroke(this.rimColor, this.rimThickness);
//in case center was changed in code, reset the h,k
this.h = this.center.x;
this.k = this.center.y;
var myCircle = new TNTDisk(this.center, this.r, null, myRimStroke);
if (this.showRim) myCircle.drawTNTDisk(context);
var delta = 2 * Math.PI / this.numSpokes;
var trad = 0;
var rotnRad = this.rotn * Math.PI / 180;
var p2, lineSeg;
//setLineCapStyle(this.lineCapStyle);
for (var i = 1; i <= this.numSpokes; i++) {
p2 = new TNTPoint(this.h + this.r * Math.cos(trad + rotnRad), this.k + this.r * Math.sin(trad + rotnRad));
lineSeg = new TNTLine(this.center, p2, this.stroke);
lineSeg.lineCapStyle = this.lineCapStyle;
lineSeg.drawTNTLine(context);
trad += delta;
}
}//end function drawTNTWheel
Who woulda thought we used SohCahToa here?! |
