Package flash.swf.types

Examples of flash.swf.types.GradRecord


        return gradient;
    }

    private GradRecord decodeGradRecord(int shape) throws IOException
    {
        GradRecord g = new GradRecord();
        g.ratio = r.readUI8();

        switch (shape)
        {
        case stagDefineShape:
View Full Code Here


        String[] parts = StringUtils.split(s, " ");
        int count = parts.length / 2;
        gradient.records = new GradRecord[count];
        for (int i = 0; i < count; i++)
        {
            GradRecord record = gradient.records[i] = new GradRecord();
            record.ratio = Integer.parseInt(parts[2 * i]);
            record.color = hasAlpha ? parseRGBA(parts[2 * i + 1]) : parseRGB(parts[2 * i + 1]);
        }
        return gradient;
    }
View Full Code Here

        fs.type = FillStyle.FILL_LINEAR_GRADIENT;

                fs.gradient = new Gradient();
                fs.gradient.records = new GradRecord[2];
        fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(gp.getColor1())); //from left
        fs.gradient.records[1] = new GradRecord(255,  SwfUtils.colorToInt(gp.getColor2())); //to right
      }
      else if (paint instanceof LinearGradientPaint)
      {
        LinearGradientPaint lgp = (LinearGradientPaint)paint;
                Point2D start = lgp.getStartPoint();
        Point2D end = lgp.getEndPoint();

        AffineTransform gt = objectBoundingBoxTransform(start, end, width, height, width, height);

        fs = new FillStyle();
        fs.matrix = MatrixBuilder.build(gt);

        Color[] colors = lgp.getColors();
        float[] ratios = lgp.getFractions();

        if (colors.length == 0 || colors.length != ratios.length) //Invalid fill so we skip
        {
          return null;
        }
        else if (colors.length == 1) //Solid fill
        {
          return new FillStyle(SwfUtils.colorToInt(colors[0]));
        }
        else
        {
          fs.type = FillStyle.FILL_LINEAR_GRADIENT;

          //Maximum of 8 gradient control points records
          int len = ratios.length;
          if (len > 8)
            len = 8;
                    fs.gradient = new Gradient();
                    fs.gradient.records = new GradRecord[len];

          for (int i = 0; i < len; i++)
          {
            fs.gradient.records[i] = new GradRecord((int)Math.rint(255 * ratios[i]), SwfUtils.colorToInt(colors[i]));
          }

        }
      }
      else if (paint instanceof RadialGradientPaint)
      {
        RadialGradientPaint rgp = (RadialGradientPaint)paint;

        //Note: Flash doesn't support the focal point of a radial gradient
        //Point2D cp = rgp.getCenterPoint();
        //Point2D fp = rgp.getFocusPoint();
        double diameter = rgp.getRadius() * 2.0;
        double outerX = diameter * rgp.getTransform().getScaleX();
        double outerY = diameter * rgp.getTransform().getScaleY();

        AffineTransform gt = objectBoundingBoxTransform(null, null, width, height, outerX, outerY);
        fs = new FillStyle();
        fs.matrix = MatrixBuilder.build(gt);

        fs.type = FillStyle.FILL_RADIAL_GRADIENT;

        Color[] colors = rgp.getColors();
        float[] ratios = rgp.getFractions();

                fs.gradient = new Gradient();
                fs.gradient.records = new GradRecord[ratios.length <= 8 ? ratios.length : 8];
        for (int i = 0; i < ratios.length && i < 8; i++)
        {
          fs.gradient.records[i] = new GradRecord((int)Math.rint(255 * ratios[i]), SwfUtils.colorToInt(colors[i]));
        }

      }
      else if (paint instanceof TexturePaint)
      {
View Full Code Here

            filter.gradientRatio = new int[count];

            GradRecord[] records = createGradRecords(node.entries);
            for (int i = 0; i < records.length; i++)
            {
                GradRecord record = records[i];
                filter.gradientColors[i] = record.color;
                filter.gradientRatio[i] = record.ratio;
            }
        }
View Full Code Here

            filter.gradientRatio = new int[count];

            GradRecord[] records = createGradRecords(node.entries);
            for (int i = 0; i < records.length; i++)
            {
                GradRecord record = records[i];
                filter.gradientColors[i] = record.color;
                filter.gradientRatio[i] = record.ratio;
            }
        }
View Full Code Here

                        thisRatio = previousRatio;
                    }
                }
            }

            GradRecord record = new GradRecord();
            record.color = TypeHelper.colorARGB(entry.color, entry.alpha);
            record.ratio = TypeHelper.gradientRatio(thisRatio);
            records[currentIndex] = record;

            // Remember this ratio as the last one specified
View Full Code Here

        return gradient;
    }

    private GradRecord decodeGradRecord(int shape) throws IOException
    {
        GradRecord g = new GradRecord();
        g.ratio = r.readUI8();

        switch (shape)
        {
        case stagDefineShape:
View Full Code Here

        String[] parts = StringUtils.split(s, " ");
        int count = parts.length / 2;
        gradient.records = new GradRecord[count];
        for (int i = 0; i < count; i++)
        {
            GradRecord record = gradient.records[i] = new GradRecord();
            record.ratio = Integer.parseInt(parts[2 * i]);
            record.color = hasAlpha ? parseRGBA(parts[2 * i + 1]) : parseRGB(parts[2 * i + 1]);
        }
        return gradient;
    }
View Full Code Here

        fs.type = FillStyle.FILL_LINEAR_GRADIENT;

                fs.gradient = new Gradient();
                fs.gradient.records = new GradRecord[2];
        fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(gp.getColor1())); //from left
        fs.gradient.records[1] = new GradRecord(255,  SwfUtils.colorToInt(gp.getColor2())); //to right
      }
      else if (paint instanceof LinearGradientPaint)
      {
        LinearGradientPaint lgp = (LinearGradientPaint)paint;
                Point2D start = lgp.getStartPoint();
        Point2D end = lgp.getEndPoint();

        AffineTransform gt = objectBoundingBoxTransform(start, end, width, height, width, height);

        fs = new FillStyle();
        fs.matrix = MatrixBuilder.build(gt);

        Color[] colors = lgp.getColors();
        float[] ratios = lgp.getFractions();

        if (colors.length == 0 || colors.length != ratios.length) //Invalid fill so we skip
        {
          return null;
        }
        else if (colors.length == 1) //Solid fill
        {
          return new FillStyle(SwfUtils.colorToInt(colors[0]));
        }
        else
        {
          fs.type = FillStyle.FILL_LINEAR_GRADIENT;

          //Maximum of 8 gradient control points records
          int len = ratios.length;
          if (len > 8)
            len = 8;
                    fs.gradient = new Gradient();
                    fs.gradient.records = new GradRecord[len];

          for (int i = 0; i < len; i++)
          {
            fs.gradient.records[i] = new GradRecord((int)Math.rint(255 * ratios[i]), SwfUtils.colorToInt(colors[i]));
          }

        }
      }
      else if (paint instanceof RadialGradientPaint)
      {
        RadialGradientPaint rgp = (RadialGradientPaint)paint;

        //Note: Flash doesn't support the focal point of a radial gradient
        //Point2D cp = rgp.getCenterPoint();
        //Point2D fp = rgp.getFocusPoint();
        double diameter = rgp.getRadius() * 2.0;
        double outerX = diameter * rgp.getTransform().getScaleX();
        double outerY = diameter * rgp.getTransform().getScaleY();

        AffineTransform gt = objectBoundingBoxTransform(null, null, width, height, outerX, outerY);
        fs = new FillStyle();
        fs.matrix = MatrixBuilder.build(gt);

        fs.type = FillStyle.FILL_RADIAL_GRADIENT;

        Color[] colors = rgp.getColors();
        float[] ratios = rgp.getFractions();

                fs.gradient = new Gradient();
                fs.gradient.records = new GradRecord[ratios.length <= 8 ? ratios.length : 8];
        for (int i = 0; i < ratios.length && i < 8; i++)
        {
          fs.gradient.records[i] = new GradRecord((int)Math.rint(255 * ratios[i]), SwfUtils.colorToInt(colors[i]));
        }

      }
      else if (paint instanceof TexturePaint)
      {
View Full Code Here

TOP

Related Classes of flash.swf.types.GradRecord

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.