예제 #1
0
        RadialGradientBrush CreateRadialGradientBrush(XElement e)
        {
            var b = new RadialGradientBrush ();

            b.Center.X = ReadNumber (e.Attribute ("cx"));
            b.Center.Y = ReadNumber (e.Attribute ("cy"));
            b.Focus.X = ReadNumber (e.Attribute ("fx"));
            b.Focus.Y = ReadNumber (e.Attribute ("fy"));
            var r = ReadNumber (e.Attribute ("r"));
            b.Radius = new Size (r);

            ReadStops (e, b.Stops);

            return b;
        }
예제 #2
0
		RadialGradientBrush CreateRadialGradientBrush (XElement e)
		{
			var b = new RadialGradientBrush ();

			b.Center.X = ReadNumber (e.Attribute ("cx"));
			b.Center.Y = ReadNumber (e.Attribute ("cy"));
			if (e.Attribute ("fx") != null)
				b.Focus.X = ReadNumber (e.Attribute ("fx"));
			else
				b.Focus.X = b.Center.X;
			if (e.Attribute ("fy") != null)
				b.Focus.Y = ReadNumber (e.Attribute ("fy"));
			else
				b.Focus.Y = b.Center.Y;
			var r = ReadNumber (e.Attribute ("r"));
			b.Radius = new Size (r);

			var gradientUnits = e.Attribute("gradientUnits");
			if (gradientUnits != null)
			{
				b.Absolute = gradientUnits.Value == "userSpaceOnUse";
			}

			// TODO: check gradientTransform attribute

			ReadStops (e, b.Stops);

			return b;
		}
예제 #3
0
		public async Task TriWithRadGrad ()
		{
			var canvas = Platform.CreateImageCanvas (new Size (100), transparency: true);
			var size = new Size (100);
			var b = new RadialGradientBrush (
				new Point (0.5, 1), new Size (1),
				Colors.Yellow, Colors.Blue);
			var p = new Path ();
			p.MoveTo (0, 0);
			p.LineTo (size.Width, 0);
			p.LineTo (size.Width / 2, size.Height);
			p.Close ();
			p.Brush = b;
			p.Draw (canvas);
			await SaveImage (canvas, "ImageCanvas.TriWithRadGrad");
		}