View Full Version : [Flash MX] how draw sine and other functions using the drawing api
The_shadow
September 17th, 2003, 03:31 PM
how draw sine and other functions using the drawing api ?
so far all my efforts have yielded amazing random designs but not the desired functions.
so somebody pls help !
ahmed
September 17th, 2003, 03:37 PM
try
i=0
scale = 3
createEmptyMovieClip("mc", 1);
mc.lineStyle(0);
mc.onEnterFrame = function()
{
this.lineTo(++i*scale,Math.sin(i)*scale);
}
senocular
September 17th, 2003, 03:41 PM
a little fast ahmed (I would think) ;)
though I guess it depends on how accurate you need to be
Jack_Knife
September 18th, 2003, 05:19 AM
just adjust how much i goes up by each frame and it becomes more accurate and slower.
The_shadow
September 18th, 2003, 12:12 PM
that works quite well ahmed but there is one problem..
if u increase the scaling factor then the lines become apparent...
u do not get any smooth curves.
so does anyone have any idea how to achieve the effect using curveTo() instead of lineTo()
also how to use moveTo() effectively to eliminate the line from the starting point when u draw such a curve
any help would be most welcome
thanx
The_shadow
September 18th, 2003, 12:32 PM
here is what i have been fiddling around with
the code should create something that looks like a leaf ;)
_root.createEmptyMovieClip("holder", 1);
_root.createEmptyMovieClip("holder1", 2);
holder.lineStyle(1, 0x999999, 45);
holder1.lineStyle(1, 0x999999, 50);
holder.moveTo(100,100);
holder1.moveTo(100, 100);
for (i=50; i<400; i += 10) {
//leaf
y = 10 * Math.log(Math.sin(i));
z= 10*Math.log(Math.sin(i));
q= 30*Math.sin(i);
holder.curveTo(i,y,i,i);
holder1.curveTo(z,i,i,i);
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.