Drawing "flat" waves is easy, but I want to draw the wave between two points x1,y1 x2,y2
Here is the "flat" code:
package display
{
import flash.display.Sprite;
import flash.events.Event;
public class SineWave extends Sprite
{
private var angle:Number = 0;
private var centerY:Number = 200;
private var range:Number = 50;
private var xspeed:Number = 2;
private var yspeed:Number = .1;
private var xpos:Number
private var ypos:Number
public function SineWave()
{
init()
}
protected function init():void
{
var sinWavePosition = 100;
var cosWavePosition = 200;
var sinWaveColor:uint = 0xFF0000;
var cosWaveColor:uint = 0x00FF00;
var waveMultiplier:Number = 10;
var waveStretcher:Number = 5;
var i:uint;
for(i = 1; i < 500; i++)
{
var sinPosY:Number = Math.sin(i / waveStretcher) * waveMultiplier;
var cosPosY:Number = Math.cos(i / waveStretcher) * waveMultiplier;
graphics.beginFill(sinWaveColor);
graphics.drawRect(i, sinWavePosition + sinPosY, 2, 2);
graphics.beginFill(cosWaveColor);
graphics.drawRect(i, cosWavePosition + cosPosY, 2, 2);
}
}
}
}