I am trying to draw a continuous curved line in a flash. There are many methods, but not one of those that I have found so far meets my requirements. First of all, I want to use the flash api curveTo () method for flash graphics. I DO NOT want to simulate a curve with hundreds of lineTo () calls to a curved line segment . It is my experience and understanding that line segments are heavy processors. A quadratic Bezier curve flash should use less CPU power. Please dispute this assumption if you think that I am wrong.
I also do not want to use a ready-made method that takes the entire line as an argument (for example, mx.charts.chartClasses.GraphicsUtilities.drawPolyline ()). The reason is that I will need to eventually change the logic to add decorations to the line I draw, so I need something that I understand at the lowest level.
Currently, I have created a method that will draw a curve based on three points using the midpoint method found here .
Here is the image:

The problem is that the lines do not actually intersect through the "real" points of the line (gray circles). Is there a way to use the power of mathematics so that I can adjust the control point so that the curve really passes through the “real” point? Given only the current point and its previous / next point as arguments? Then comes the code to duplicate the above figure. It would be great if I could change it to meet this requirement (note the exception for the first and last point).
package { import flash.display.Shape; import flash.display.Sprite; import flash.display.Stage; import flash.geom.Point; [SWF(width="200",height="200")] public class TestCurves extends Sprite { public function TestCurves() { stage.scaleMode = "noScale"; var points:Array = [ new Point(10, 10), new Point(80, 80), new Point(80, 160), new Point(20, 160), new Point(20, 200), new Point(200, 100) ]; graphics.lineStyle(2, 0xFF0000); var point:Point = points[0]; var nextPoint:Point = points[1]; SplineMethod.drawSpline(graphics, point, null, nextPoint); var prevPoint:Point = point; var n:int = points.length; var i:int; for (i = 2; i < n + 1; i++) { point = nextPoint; nextPoint = points[i];
Later I will add arrows and things to the draw method.
jpwrunyan
source share