Beispiel #1
0
        public override void AddColorStop(object backend, double position, Xwt.Drawing.Color color)
        {
            GradientInfo gr = (GradientInfo)backend;

            gr.Colors.Add(color.ToCGColor());
            gr.Stops.Add((float)position);
        }
Beispiel #2
0
		internal static void Draw (CGContext ctx, GradientInfo gradient)
		{
			ctx.SaveState ();
			ctx.Clip ();
			using (var cg = new CGGradient (Util.DeviceRGBColorSpace, gradient.Colors.ToArray (), gradient.Stops.ToArray ())) {
				if (gradient.Linear)
					ctx.DrawLinearGradient (cg, gradient.Start, gradient.End, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
				else
					ctx.DrawRadialGradient (cg, gradient.Start, gradient.StartRadius, gradient.End, gradient.EndRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
			}
			ctx.RestoreState ();
		}
Beispiel #3
0
 internal static void Draw(CGContext ctx, GradientInfo gradient)
 {
     ctx.SaveState();
     ctx.Clip();
     using (var cg = new CGGradient(Util.DeviceRGBColorSpace, gradient.Colors.ToArray(), gradient.Stops.ToArray())) {
         if (gradient.Linear)
         {
             ctx.DrawLinearGradient(cg, gradient.Start, gradient.End, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
         }
         else
         {
             ctx.DrawRadialGradient(cg, gradient.Start, gradient.StartRadius, gradient.End, gradient.EndRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
         }
     }
     ctx.RestoreState();
 }
Beispiel #4
0
        public void Fill(object backend)
        {
            ContextInfo ctx = (ContextInfo)backend;

            if (ctx.Pattern is Gradient)
            {
                GradientInfo gr = (GradientInfo)WidgetRegistry.GetBackend(ctx.Pattern);
                NSGradient   g  = new NSGradient(gr.Colors.ToArray(), gr.Stops.ToArray());
                g.DrawInBezierPath(ctx.Path, 0f);
            }
            else
            {
                ctx.Path.Fill();
            }
            ctx.Pattern = null;
            ctx.Path.Dispose();
            ctx.Path = new NSBezierPath();
        }
Beispiel #5
0
        public void Fill(object backend)
        {
            var ctx = GetContext(backend);

            if (ctx.Pattern is GradientInfo)
            {
                GradientInfo gr = (GradientInfo)ctx.Pattern;
                NSGradient   g  = new NSGradient(gr.Colors.ToArray(), gr.Stops.ToArray());
                g.DrawInBezierPath(ctx.Path, 0f);
            }
            else if (ctx.Pattern is NSColor)
            {
                NSColor col = (NSColor)ctx.Pattern;
                col.Set();
                col.SetFill();
            }
            else
            {
                ctx.Path.Fill();
            }
            ctx.Pattern = null;
            ctx.Path.Dispose();
            ctx.Path = new NSBezierPath();
        }