Example #1
0
 public void SetBlendTriangularShape(float focus, float scale)
 {
     _x2           = (_x1 + _x2) / 2;
     _y2           = (_y1 + _y2) / 2;
     _cyclic       = true;
     _nativeObject = null;
 }
		private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, bool cyclic) {
			_x1 = x1;
			_y1 = y1;
			_color1 = color1;

			_x2 = x2;
			_y2 = y2;
			_color2 = color2;

			_cyclic = cyclic;
			_nativeObject = null;
		}
Example #3
0
 private void setPaint(Paint paint, boolean invert, double xoffset, double yoffset)
 {
     this.paint = paint;
     if (paint is Color)
     {
         cb.setColorFill((Color)paint);
     }
     else if (paint is GradientPaint)
     {
         GradientPaint gp = (GradientPaint)paint;
         Point2D       p1 = gp.getPoint1();
         transform.transform(p1, p1);
         Point2D p2 = gp.getPoint2();
         transform.transform(p2, p2);
         Color             c1      = gp.getColor1();
         Color             c2      = gp.getColor2();
         PdfShading        shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float)p1.getX(), (float)p1.getY(), (float)p2.getX(), (float)p2.getY(), c1, c2);
         PdfShadingPattern pat     = new PdfShadingPattern(shading);
         cb.setShadingFill(pat);
     }
     else
     {
         try {
             BufferedImage img  = null;
             int           type = BufferedImage.TYPE_4BYTE_ABGR;
             if (paint.getTransparency() == Transparency.OPAQUE)
             {
                 type = BufferedImage.TYPE_3BYTE_BGR;
             }
             img = new BufferedImage((int)width, (int)height, type);
             Graphics2D g        = (Graphics2D)img.getGraphics();
             Shape      fillRect = new Rectangle2D.Double(0, 0, img.getWidth(),
                                                          img.getHeight());
             g.setPaint(paint);
             g.fill(fillRect);
             if (invert)
             {
                 AffineTransform tx = new AffineTransform();
                 tx.scale(1, -1);
                 tx.translate(-xoffset, -yoffset);
                 g.drawImage(img, tx, null);
             }
             com.lowagie.text.Image image   = com.lowagie.text.Image.getInstance(img, null);
             PdfPatternPainter      pattern = cb.createPattern(width, height);
             image.setAbsolutePosition(0, 0);
             pattern.addImage(image);
             cb.setPatternFill(pattern);
         } catch (Exception ex) {
             cb.setColorFill(Color.gray);
         }
     }
 }
Example #4
0
        private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, bool cyclic)
        {
            _x1     = x1;
            _y1     = y1;
            _color1 = color1;

            _x2     = x2;
            _y2     = y2;
            _color2 = color2;

            _cyclic       = cyclic;
            _nativeObject = null;
        }
Example #5
0
        public static CALayer?CreateCALayer(this GradientPaint gradientPaint, CGRect frame = default)
        {
            if (gradientPaint is LinearGradientPaint linearGradientPaint)
            {
                return(linearGradientPaint.CreateCALayer(frame));
            }

            if (gradientPaint is RadialGradientPaint radialGradientPaint)
            {
                return(radialGradientPaint.CreateCALayer(frame));
            }

            return(null);
        }
Example #6
0
		internal static GradientData GetGradientPaintData(GradientPaint gradientPaint, float alpha = 1.0f)
		{
			var orderStops = gradientPaint.GradientStops;

			var data = new GradientData(orderStops.Length);

			int count = 0;
			foreach (var orderStop in orderStops)
			{
				data.Colors[count] = orderStop.Color.WithAlpha(alpha).ToPlatform().ToArgb();
				data.Offsets[count] = orderStop.Offset;
				count++;
			}

			return data;
		}
        static GradientData GetGradientPaintData(GradientPaint gradientPaint)
        {
            var orderStops = gradientPaint.GradientStops;

            var data = new GradientData(orderStops.Length);

            int count = 0;

            foreach (var orderStop in orderStops)
            {
                data.Colors[count]  = orderStop.Color.ToNative().ToArgb();
                data.Offsets[count] = orderStop.Offset;
                count++;
            }

            return(data);
        }
		public void SetBlendTriangularShape (float focus, float scale) {
			_x2 = (_x1 + _x2) / 2;
			_y2 = (_y1 + _y2) / 2;
			_cyclic = true;
			_nativeObject = null;
		}