Package flash.swf.types

Examples of flash.swf.types.Rect


     * @return bounding box rectangle.
     */
    public static Rect getBounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode strokeNode)
    {
        if (records == null || records.size() == 0)
            return new Rect();

        int x1 = 0;
        int y1 = 0;
        int x2 = 0;
        int y2 = 0;
        int x = 0;
        int y = 0;
        boolean firstMove = true;

        Iterator<ShapeRecord> iterator = records.iterator();
        while (iterator.hasNext())
        {
            ShapeRecord r = iterator.next();

            if (r == null)
                continue;

            if (r instanceof StyleChangeRecord)
            {
                StyleChangeRecord scr = (StyleChangeRecord)r;
                x = scr.moveDeltaX;
                y = scr.moveDeltaY;
                if (firstMove)
                {
                    x1 = x;
                    y1 = y;
                    x2 = x;
                    y2 = y;
                    firstMove = false;
                }
            }
            else if (r instanceof StraightEdgeRecord)
            {
                StraightEdgeRecord ser = (StraightEdgeRecord)r;
                x = x + ser.deltaX;
                y = y + ser.deltaY;
            }
            else if (r instanceof CurvedEdgeRecord)
            {
                CurvedEdgeRecord cer = (CurvedEdgeRecord)r;
               
                Rect currRect = new Rect(x1, x2, y1, y2);
                if (!curveControlPointInsideCurrentRect(x, y, cer, currRect))
                {               
                  Rect curvBounds = computeCurveBounds(x, y, cer);
               
                  if (curvBounds.xMin < x1) x1 = curvBounds.xMin;
                  if (curvBounds.yMin < y1) y1 = curvBounds.yMin;
                  if (curvBounds.xMax > x2) x2 = curvBounds.xMax;
                  if (curvBounds.yMax > y2) y2 = curvBounds.yMax;
                }
                               
                x = x + cer.controlDeltaX + cer.anchorDeltaX;
                y = y + cer.controlDeltaY + cer.anchorDeltaY;
            }

            //update x1, y1 to min values and x2, y2 to max values
            if (x < x1) x1 = x;
            if (y < y1) y1 = y;
            if (x > x2) x2 = x;
            if (y > y2) y2 = y;
        }
       
        Rect newRect = new Rect(x1, x2, y1, y2);

        if (ls == null)
        {
            return newRect;
        }
       
        // Inflate the bounding box from all sides with half of the stroke
        // weight - pathBBox.inflate(weight/2, weight/2).
        Rect strokeExtents = getStrokeExtents(strokeNode, ls);

        newRect.xMin -= strokeExtents.xMax;
        newRect.yMin -= strokeExtents.yMax;
        newRect.xMax += strokeExtents.xMax;
        newRect.yMax += strokeExtents.yMax;
View Full Code Here


     *
     * @return the rect
     */
    public static Rect addJoint2Bounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode stroke, double halfWeight, Rect pathBBox)
    {
        Rect newRect = pathBBox;
        int count = records.size();
      int start = 0;
      int end = 0;
      int lastMoveX = 0;
      int lastMoveY = 0;
View Full Code Here

    else
      {
        height = configuration.defaultHeight();
      }

    size = new Rect(width * 20, height * 20);

        if ((configuration.scriptLimitsSet()))
        {
            scriptLimits = new ScriptLimits( configuration.getScriptRecursionLimit(),
                                             configuration.getScriptTimeLimit() );
View Full Code Here

            y1 = y1 - stroke;
            x2 = x2 + stroke;
            y2 = y2 + stroke;
        }

      return new Rect(x1, x2, y1, y2);
    }
View Full Code Here

        {
            // 180 degrees, nothing to contribute
            return pathBBox;
        }
  
        Rect newRect = pathBBox;
        // Is there miter limit at play?
        if (sinHalfAlpha == 0 || miterLimit < 1 / sinHalfAlpha)
        {
            // The miter limit is reached. Calculate two extra points that may
            // contribute to the bounds.
View Full Code Here

     *  <code>Rectangle(left, top, right - left, bottom - top)</code>.
     *  Note that if rect is non-null, it will be updated to reflect the return value. 
     */
    private static Rect rectUnion(int left, int top, int right, int bottom, Rect rect)
    {
        Rect newRect = new Rect();
        if (rect == null)
        {
            newRect = new Rect(left, right, top, bottom);
            return newRect;
        }
       
        newRect.xMin = Math.min(rect.xMin, left);
        newRect.yMin = Math.min(rect.yMin, top);
View Full Code Here

        // TODO (egeorgie): currently we take only scale into account,
        // but depending on joint style, cap style, etc. we need to take
        // the whole matrix into account as well as examine every line segment.
        if (stroke == null)
        {
            return new Rect(0, 0, 0 , 0);
        }
       
        int xMin, xMax, yMin, yMax;
        // Stroke with weight 0 or scaleMode "none" is always drawn
        // at "hairline" thickness, which is exactly one pixel.
        int lineWidth = ls.width;  
        if (lineWidth == 0)
        {
            xMin = (int)StrictMath.rint(-0.5 * TWIPS_PER_PIXEL);
            xMax = (int)StrictMath.rint(0.5 * TWIPS_PER_PIXEL);
            yMin = (int)StrictMath.rint(-0.5 * TWIPS_PER_PIXEL);
            yMax = (int)StrictMath.rint(0.5 * TWIPS_PER_PIXEL);
        }
        else
        {
            xMin = (int)StrictMath.rint(-lineWidth * 0.5);
            xMax = (int)StrictMath.rint(lineWidth * 0.5);
            yMin = (int)StrictMath.rint(-lineWidth * 0.5);
            yMax = (int)StrictMath.rint(lineWidth * 0.5);  
        }
        return new Rect(xMin, xMax, yMin, yMax);
    }   
View Full Code Here

            if (y < ymin) ymin = y;
            if (x > xmax) xmax = x;
            if (y > ymax) ymax = y;
        }
       
        Rect r = new Rect(xmin, xmax, ymin, ymax);       
        return r;
    }
View Full Code Here

        Movie movie = new Movie();
        movie.version = version;
        movie.framerate = framerate;
        movie.width = width;
        movie.height = height;
        movie.size = new Rect(width * SwfConstants.TWIPS_PER_PIXEL, height * SwfConstants.TWIPS_PER_PIXEL);

        Frame frame = new Frame();
        movie.frames = new ArrayList<Frame>();
        movie.frames.add(frame);

View Full Code Here

     * @param maxY The y-coordinate of the bottom right corner of the rectangle.
     * @return A SWF Rect type representing the implied rectangle.
     */
    public static Rect rect(double minX, double minY, double maxX, double maxY)
    {
        Rect rect = new Rect();
        rect.xMin = (int)(minX * SwfConstants.TWIPS_PER_PIXEL);
        rect.yMin = (int)(minY * SwfConstants.TWIPS_PER_PIXEL);
        rect.xMax = (int)(maxX * SwfConstants.TWIPS_PER_PIXEL);
        rect.yMax = (int)(maxY * SwfConstants.TWIPS_PER_PIXEL);
        return rect;
View Full Code Here

TOP

Related Classes of flash.swf.types.Rect

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.