I got this code from colin moocks book, Im think I understand most of it apart from the role that control distance and control points play
.. could some some please explain what it is... please
what does this do.. I drawing would be great. if not some simpler code and an explaination of the principles ?
PHP Code:
method draw circle..
// method draw circle..
// we must calulate the points on the circle and draw lines between them..
//
// moock pg 643 example r2
MovieClip.prototype.drawCircle = function(x, y, r, segments) {
// Varibles to hold the end and control points of each curve
var endX, endY, controlX, controlY;
// use 8 segments if not specified.
if (segments == undefined) {
segments = 8;
}
// caluculate how many degrees are in each segment
// (360/ segments) and convert to radians.
// yeah
var segmentAngle = (360/segments)/180*Math.PI;
// calculate the distanse to the control point of each curve.
var controlDist = r/Math.cos(segmentAngle/2);
//Start drawing on the circles positive x axis.
this.moveTo(x+r, y);
//Draw the circle segments
for (var i = 1; i<=segments; i++) {
// calculate the end point of this curve.
endX = x+r*Math.cos(i*segmentAngle);
endY = x+r*Math.sin(i*segmentAngle);
// calculate the control point of this curve
controlX = x+controlDist*Math.cos(i*segmentAngle-segmentAngle/2);
controlY = x+controlDist*Math.sin(i*segmentAngle-segmentAngle/2);
// Draw this curve.
this.curveTo(controlX, controlY, endX, endY);
}
};
this.lineStyle(1);
this.drawCircle(200, 200, 150);
//What is the control distance?
This part just confuses me.I need it drawn of a link to a tutorial..
PHP Code:
var controlDist = r/Math.cos(segmentAngle/2);
[/CODE]