Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-11-2004, 06:37 AM   #1
rabs
Registered User
 
Join Date: May 2004
Posts: 21
Default Drawing a circle in flash mx, help needed

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(xyrsegments) {

    
// Varibles to hold the end and control points of each curve
    
var endXendYcontrolXcontrolY;
    
// 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+ry);
    
//Draw the circle segments
    
for (var 1i<=segmentsi++) {
        
// 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(controlXcontrolYendXendY);
    }
};
this.lineStyle(1);
this.drawCircle(200200150); 
//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]

Last edited by rabs; 06-11-2004 at 06:40 AM. Reason: add text
rabs is offline   Reply With Quote
Old 06-11-2004, 08:03 AM   #2
pom
Allez les Bleus!!!
 
pom's Avatar
 
Join Date: Oct 2002
Location: Paname
Posts: 2,495
Default

Hi,

It's trigonometry. As you know, curbs drawn with curveTo don't reach the control points defined. Calculating the control point that you have to input to get a given curb is quite obscur, but it seems here that Colin found out which point you have to use.

Let's say you have a circle, and your segmentAngle = 10 degrees.
Then the fist control point will sit on a line l that crosses the center with an angle of segmentAngle/2 = 5 degrees, at a distance of r/Math.cos(segmentAngle/2), which is ni fact the point where that line l and the tangent to the circle at the point (r, segmentAngle).

It's actually quite hard to explain... :-/
pom is offline   Reply With Quote
Old 06-11-2004, 08:09 AM   #3
pom
Allez les Bleus!!!
 
pom's Avatar
 
Join Date: Oct 2002
Location: Paname
Posts: 2,495
Default

If I understood correctly, C is the control point on the attached graphic. Now, why is it that point is another question...
Attached Images
File Type: bmp circle.bmp (160.1 KB, 281 views)
pom is offline   Reply With Quote
Old 06-11-2004, 08:21 AM   #4
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

my gawd thats a huge image for such a small graphic

Here, Ill make one that should make it a little easier to understand....
__________________
(6)
senocular is offline   Reply With Quote
Old 06-11-2004, 08:41 AM   #5
pom
Allez les Bleus!!!
 
pom's Avatar
 
Join Date: Oct 2002
Location: Paname
Posts: 2,495
Default

MS Paint power!
pom is offline   Reply With Quote
Old 06-11-2004, 08:43 AM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,014
Default

Yay!!! MS Rules...

Just a dumb question to pom...
Did you not have Flash nearby when you needed to draw that???
(Um... I guess this quesiton goes more to your style since I draw pretty much anything in Flash... )
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 06-11-2004, 09:15 AM   #7
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

ok, this kind of shows what that code is refering to
Attached Images
File Type: gif circ_approx.gif (27.9 KB, 293 views)
__________________
(6)
senocular is offline   Reply With Quote
Old 06-11-2004, 09:23 AM   #8
rabs
Registered User
 
Join Date: May 2004
Posts: 21
Default

All I can say is wow... THANKYOU SO MUCH
rabs is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:30 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.