[As Functional code Tutorial 06] As drawing Summary and supplement

Source: Internet
Author: User
Tags cos sin

This course, the previous study of the line method to give a summary, but also to be supplemented

Summarize:

Round:

_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 60;
MC.moveTo(R*Math.cos(0),R*Math.sin(0));
MC.lineStyle(2);
for (n=1; n < 360; n++) {
 var angle = n*Math.PI/180;
 var tox = R*Math.cos(angle);
 var toy = R*Math.sin(angle);
 MC.lineTo(tox,toy);
}

Elliptic:

_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var W = 50;
var H = 30;
MC.moveTo(W*Math.cos(0),H*Math.sin(0));
MC.lineStyle(2);
for (n=1; n < 360; n++) {
 var angle = n*Math.PI/180;
 var tox = W*Math.cos(angle);
 var toy = H*Math.sin(angle);
 MC.lineTo(tox,toy);
}

Spiral:

_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 10;
var A = 3;
MC.moveTo(0,0);
MC.lineStyle(2);
for (n=1; n < 360; n++) {
 var angle = A*n*Math.PI/180;
 var tox = angle*R*Math.cos(angle);
 var toy = angle*R*Math.sin(angle);
 MC.lineTo(tox,toy);
}

Multilateral type:

_root.createEmptyMovieClip("MC",1);
MC._x = 200;
MC._y = 150;
var R = 50;
var sides = 5;
var angle = (360*Math.PI/180)/sides;
var MA:Array = new Array();
for (i=0; i <= sides; i++) {
 MA[i] = i*angle;
}
MC.moveTo(R*Math.cos(MA[0]),R*Math.sin(MA[0]));
MC.lineStyle(2);
for (n=1; n <= sides; n++) {
 var tox = R*Math.cos(MA[n]);
 var toy = R*Math.sin(MA[n]);
 MC.lineTo(tox,toy);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.