Package org.apache.flex.utils

Examples of org.apache.flex.utils.Point


     * <p>
     * Creates an empty Flash Shape with the pen starting at [0.0, 0.0].
     */
    public ShapeBuilder(Styles styles)
    {
        this(styles, new Point());
    }
View Full Code Here


    public ShapeBuilder(Styles styles, Point origin)
    {
        shape = new Shape();

        if (origin == null)
            origin = new Point();

        this.start = new Point(origin.x, origin.y);
        this.lastMoveTo = new Point(origin.x, origin.y);
        this.pen = new Point(this.lastMoveTo.x, this.lastMoveTo.y);
        this.styles = styles;
    }
View Full Code Here

                    curved(coords[0], coords[1], coords[2], coords[3]);
                    break;
                }
                case IShapeIterator.CUBIC_TO:
                {
                    approximateCubicBezier(new Point(pen.x, pen.y),
                            new Point(coords[0], coords[1]),
                            new Point(coords[2], coords[3]),
                            new Point(coords[4], coords[5]));
                    break;
                }
                case IShapeIterator.CLOSE:
                {
                    closed = true;
View Full Code Here

     * Return a point on a segment [P0, P1] which distance from P0 is ratio of
     * the length [P0, P1]
     */
    public static Point getPointOnSegment(Point P0, Point P1, double ratio)
    {
        return new Point((P0.x + ((P1.x - P0.x) * ratio)), (P0.y + ((P1.y - P0.y) * ratio)));
    }
View Full Code Here

     * @see <a href="http://timotheegroleau.com/Flash/articles/cubic_bezier_in_flash.htm">Cubic Bezier in Flash</a>
     */
    private void approximateCubicBezier(final Point P0, final Point P1, final Point P2, final Point P3)
    {
        // calculates the useful base points
        Point PA = getPointOnSegment(P0, P1, 3.0 / 4.0);
        Point PB = getPointOnSegment(P3, P2, 3.0 / 4.0);

        // get 1/16 of the [P3, P0] segment
        double dx = (P3.x - P0.x) / 16.0;
        double dy = (P3.y - P0.y) / 16.0;

        // calculate control point 1
        Point c1 = getPointOnSegment(P0, P1, 3.0 / 8.0);

        // calculate control point 2
        Point c2 = getPointOnSegment(PA, PB, 3.0 / 8.0);
        c2.x = c2.x - dx;
        c2.y = c2.y - dy;

        // calculate control point 3
        Point c3 = getPointOnSegment(PB, PA, 3.0 / 8.0);
        c3.x = c3.x + dx;
        c3.y = c3.y + dy;

        // calculate control point 4
        Point c4 = getPointOnSegment(P3, P2, 3.0 / 8.0);

        // calculate the 3 anchor points (as midpoints of the control segments)
        Point a1 = new Point(((c1.x + c2.x) / 2.0), ((c1.y + c2.y) / 2.0));
        Point a2 = new Point(((PA.x + PB.x) / 2.0), ((PA.y + PB.y) / 2.0));
        Point a3 = new Point(((c3.x + c4.x) / 2.0), ((c3.y + c4.y) / 2.0));

        // draw the four quadratic sub-segments
        curved(c1.x, c1.y, a1.x, a1.y);
        curved(c2.x, c2.y, a2.x, a2.y);
        curved(c3.x, c3.y, a3.x, a3.y);
View Full Code Here

TOP

Related Classes of org.apache.flex.utils.Point

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.