Examples of FillStyle


Examples of flash.swf.types.FillStyle

  {
    Point origin = new Point(graphicContext.getPen().getX(), graphicContext.getPen().getY());
    Paint paint = graphicContext.getPaint();
    Stroke stroke = graphicContext.getStroke();

    FillStyle fs = null;
    LineStyle ls = null;

    if (fill && paint != null)
      fs = FillStyleBuilder.build(paint, shape.getBounds2D(), graphicContext.getTransform());
View Full Code Here

Examples of flash.swf.types.FillStyle

        return a;
    }

    private FillStyle decodeFillStyle(int shape) throws IOException
    {
        FillStyle s = new FillStyle();

        s.type = r.readUI8();
        switch (s.type)
        {
        case FillStyle.FILL_SOLID: // 0x00
View Full Code Here

Examples of flash.swf.types.FillStyle

    public void fillstyle(Attributes attributes) throws SAXParseException
    {
        DefineShape defineShape = (DefineShape)stack.peek();
        boolean hasAlpha = (defineShape.code == stagDefineShape3);
        FillStyle fillstyle = new FillStyle();
        if (hasAttribute(attributes, "color"))
        {
            fillstyle.setType(FillStyle.FILL_SOLID);
            fillstyle.color = hasAlpha ? parseRGBA(getAttribute(attributes, "color")) :
                    parseRGB(getAttribute(attributes, "color"));
        }
        if (hasAttribute(attributes, "gradient"))
        {
            // todo support radial gradients
            fillstyle.setType(FillStyle.FILL_LINEAR_GRADIENT);
            fillstyle.gradient = parseGradient(getAttribute(attributes, "gradient"), hasAlpha);
            fillstyle.matrix = parseMatrix(getAttribute(attributes, "matrix"));
        }
        if (hasAttribute(attributes, "idref"))
        {
            // todo support clipped bitmaps
            fillstyle.setType(FillStyle.FILL_BITS); // tiled
            int idref = parseInt(getAttribute(attributes, "idref"));
            // todo check to make sure bitmapId points to a bitmap
            fillstyle.bitmap = findCharacter(idref);
            fillstyle.matrix = parseMatrix(getAttribute(attributes, "matrix"));
        }
View Full Code Here

Examples of flash.swf.types.FillStyle

        // Create Fill Style
        Matrix matrix = new Matrix();
        matrix.scaleX = (int)Math.rint(SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE);
        matrix.scaleY = (int)Math.rint(SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE);
        matrix.hasScale = true; //Apply runtime scale of 20 (for twips)
        FillStyle fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag);

        // Apply Fill Styles
        ShapeWithStyle sws = new ShapeWithStyle();
        sws.fillstyles = new ArrayList<FillStyle>();
        int fsIndex = sws.fillstyles.add(fs) ? sws.fillstyles.lastIndexOf(fs) + 1 : 0;
View Full Code Here

Examples of flash.swf.types.FillStyle

   * @param bounds - required for gradient ratio calculation
   * @return a new <code>FillStyle</code> representing the given paint
   */
  public static FillStyle build(Paint paint, Rectangle2D bounds, AffineTransform transform)
  {
    FillStyle fs = null;

    if (paint != null)
    {
      double width = bounds.getWidth();
      double height = bounds.getHeight();

      if (paint instanceof Color)
      {
        fs = new FillStyle(SwfUtils.colorToInt((Color)paint));
      }
      else if (paint instanceof GradientPaint)
      {
        GradientPaint gp = (GradientPaint)paint;
        AffineTransform gt = objectBoundingBoxTransform(transform.transform(gp.getPoint1(), null),
            transform.transform(gp.getPoint2(), null),
            width,
            height,
            width,
            height);
        fs = new FillStyle();
        fs.matrix = MatrixBuilder.build(gt);

        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)
      {
        TexturePaint tp = (TexturePaint)paint;
        Image image = tp.getImage();

              LosslessImage losslessImage = new LosslessImage(image);
              int imageWidth = losslessImage.getWidth();
              int imageHeight = losslessImage.getHeight();
              DefineBitsLossless tag = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), imageWidth, imageHeight);

        //Apply Twips Scale of 20 x 20
        AffineTransform at = new AffineTransform();
        at.setToScale(SwfConstants.TWIPS_PER_PIXEL, SwfConstants.TWIPS_PER_PIXEL);
        Matrix matrix = MatrixBuilder.build(at);

        fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag);
      }

    }

    return fs;
View Full Code Here

Examples of flash.swf.types.FillStyle

            //Build valid SWF DefineShape tag
            ShapeWithStyle sws = new ShapeWithStyle();
            sws.shapeRecords = shape.shapeRecords;
            sws.linestyles = new ArrayList();
            sws.fillstyles = new ArrayList();
            sws.fillstyles.add(new FillStyle(SwfUtils.colorToInt(0, 0, 200, 255)));
            DefineShape tag = new DefineShape(Tag.stagDefineShape3);
            tag.bounds = new Rect(250 * 20, 250 * 20);
            tag.shapeWithStyle = sws;

            //Create a SWF Movie shell
View Full Code Here

Examples of org.apache.flex.swf.types.FillStyle

     * @throws MalformedTagException
     * @throws RuntimeException if the FillStyle is invalid.
     */
    private FillStyle readStandardFillStyle(TagType tagType) throws MalformedTagException
    {
        final FillStyle s = new FillStyle();
        final int type = bitStream.readUI8();
        s.setFillStyleType(type);

        switch (type)
        {
            case FillStyle.SOLID_FILL:
                switch (tagType)
                {
                    case DefineShape3:
                    case DefineShape4:
                        s.setColor(readRGBA());
                        break;
                    case DefineShape2:
                    case DefineShape:
                        s.setColor(readRGB());
                        break;
                    default:
                        throw new IllegalArgumentException("Invalid tag: " + tagType);
                }
                break;
            case FillStyle.LINEAR_GRADIENT_FILL:
            case FillStyle.RADIAL_GRADIENT_FILL:
                s.setGradientMatrix(readMatrix());
                s.setGradient(readGradient(tagType));
                break;
            case FillStyle.FOCAL_RADIAL_GRADIENT_FILL:
                s.setGradientMatrix(readMatrix());
                s.setGradient(readFocalGradient(tagType));
                break;
            case FillStyle.REPEATING_BITMAP_FILL: // 0x40 tiled bitmap fill
            case FillStyle.CLIPPED_BITMAP_FILL: // 0x41 clipped bitmap fill
            case FillStyle.NON_SMOOTHED_REPEATING_BITMAP: // 0x42 tiled non-smoothed fill
            case FillStyle.NON_SMOOTHED_CLIPPED_BITMAP: // 0x43 clipped non-smoothed fill
                final int idref = bitStream.readUI16();
                s.setBitmapCharacter(getTagById(idref, tagType));
                s.setBitmapMatrix(readMatrix());
                break;
            default:
                problems.add(new SWFUnknownFillStyleProblem(type, false, swfPath, bitStream.getOffset()));
                throw new MalformedTagException();
        }
View Full Code Here

Examples of org.apache.flex.swf.types.FillStyle

        // Create Fill Style
        Matrix matrix = new Matrix();
        double twx = (ISWFConstants.TWIPS_PER_PIXEL);
        matrix.setScale(twx, twx);
       
        FillStyle fs = null;
        if (fileVersion.equalTo(FXGVersion.v1_0))
        {
          if (repeat)
            fs = new FillStyle(FillStyle.REPEATING_BITMAP_FILL, matrix, image.getTag());
          else
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
        }
        else
        {
          if (fillMode.equals(FillMode.REPEAT))
          {
            fs = new FillStyle(FillStyle.REPEATING_BITMAP_FILL, matrix, image.getTag());
          }
          else if (fillMode.equals(FillMode.CLIP))
          {
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
          }
          else if (fillMode.equals(FillMode.SCALE))
          {
            //override the scale for matrix
              double fwidth = (width*ISWFConstants.TWIPS_PER_PIXEL)/(double)image.getWidth();
              double fheight = (height*ISWFConstants.TWIPS_PER_PIXEL)/(double)image.getHeight();
               
              //For consistency with the 4.5.1 snapshot of the flex compiler.
              fwidth = ((double)StrictMath.rint(0x10000 * fwidth))/((double)0x10000);
              fheight = ((double)StrictMath.rint(0x10000 * fheight))/((double)0x10000);
             
              matrix.setScale(fwidth, fheight);
           
            //fill style does not matter much since the entire area is filled with bitmap
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
          }
        }

        // Apply Fill Styles
        FillStyleArray styleArray = new FillStyleArray();
View Full Code Here

Examples of org.apache.flex.swf.types.FillStyle

        matrix.setScale(twx, twx);
       
        // Create 9 identical fillstyles as a work around
        for (int i = 0; i < 9; i++)
        {
            FillStyle fs = new FillStyle(FillStyle.NON_SMOOTHED_REPEATING_BITMAP, matrix, bitmap.getTag());
            fillStyleArray.add(fs);
        }
        Styles styles = new Styles(fillStyleArray, lineStyleArray);
       
        int dxa = slt;
View Full Code Here

Examples of org.apache.flex.swf.types.FillStyle

        // 9 identical fillstyles to fool things
        // not sure why this is needed, and why we're indexing into
        // the into, as the values are identical.  Was ported over from hero.
        for (int i = 0; i < 9; ++i)
        {
            FillStyle fs = new FillStyle();
            fs.setBitmapCharacter(image);
            fs.setBitmapMatrix(tsm);
            fs.setFillStyleType(FillStyle.NON_SMOOTHED_REPEATING_BITMAP);
            fillStyles.add(fs);
        }

        int slt = r.xMin();
        int srt = r.xMax();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.