示例#1
0
        public static void DrawRadialGradient(this Context g, Surface oldsurface, GradientColorMode mode, Color c1, Color c2, PointD p1, PointD p2, double r1, double r2)
        {
            g.Save();

            Gradient gradient = new Cairo.RadialGradient(p1.X, p1.Y, r1, p2.X, p2.Y, r2);

            if (mode == GradientColorMode.Color)
            {
                gradient.AddColorStop(0, c1);
                gradient.AddColorStop(1, c2);
                g.Source = gradient;
                g.Paint();
            }
            else if (mode == GradientColorMode.Transparency)
            {
                gradient.AddColorStop(0, new Color(0, 0, 0, 1));
                gradient.AddColorStop(1, new Color(0, 0, 0, 0));
                g.Source = new SurfacePattern(oldsurface);
                g.Mask(gradient);
            }

            g.Restore();
        }
示例#2
0
        public static void DrawRadialGradient(this Context g, Surface oldsurface, GradientColorMode mode, Cairo.Color c1, Cairo.Color c2, PointD p1, PointD p2, double r1, double r2)
        {
            g.Save ();

            Gradient gradient = new Cairo.RadialGradient (p1.X, p1.Y, r1, p2.X, p2.Y, r2);

            if (mode == GradientColorMode.Color) {
                gradient.AddColorStop (0, c1);
                gradient.AddColorStop (1, c2);
                g.Source = gradient;
                g.Paint ();
            }
            else if (mode == GradientColorMode.Transparency) {
                gradient.AddColorStop (0, new Cairo.Color (0, 0, 0, 1));
                gradient.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
                g.Source = new SurfacePattern (oldsurface);
                g.Mask (gradient);
            }

            g.Restore ();
        }
示例#3
0
		public static void DrawLinearReflectedGradient (this Context g, Surface oldsurface, GradientColorMode mode, Color c1, Color c2, PointD p1, PointD p2)
		{
			g.Save ();

			Gradient gradient = new Cairo.LinearGradient (p1.X, p1.Y, p2.X, p2.Y);

			if (mode == GradientColorMode.Color) {
				gradient.AddColorStop (0, c1);
				gradient.AddColorStop (0.5, c2);
				gradient.AddColorStop (1, c1);
				g.SetSource (gradient);
				g.Paint ();
			} else if (mode == GradientColorMode.Transparency) {
				gradient.AddColorStop (0, new Color (0, 0, 0, 1));
				gradient.AddColorStop (0.5, new Color (0, 0, 0, 0));
				gradient.AddColorStop (1, new Color (0, 0, 0, 1));
				g.SetSource (new SurfacePattern (oldsurface));
				g.Mask (gradient);
			}

			g.Restore ();
		}