Пример #1
0
        protected virtual void ShapeSurface(Context cr, Cairo.Color color)
        {
            cr.Operator = Operator.Source;
#if MONO_1_2_5
            Cairo.Pattern p = new Cairo.SolidPattern(new Cairo.Color(0, 0, 0, 0));
#else
            Cairo.Pattern p = new Cairo.SolidPattern(new Cairo.Color(0, 0, 0, 0), true);
#endif
            cr.Source = p;
            p.Destroy();
            cr.Paint();
            cr.Operator = Operator.Over;

#if MONO_1_2_5
            Cairo.Pattern r = new SolidPattern(color);
#else
            Cairo.Pattern r = new SolidPattern(color, true);
#endif
            cr.Source = r;
            r.Destroy();
            cr.MoveTo(round, 0);
            if (x_align == 1.0)
            {
                cr.LineTo(Allocation.Width, 0);
            }
            else
            {
                cr.Arc(Allocation.Width - round, round, round, -Math.PI * 0.5, 0);
            }
            if (x_align == 1.0 || y_align == 1.0)
            {
                cr.LineTo(Allocation.Width, Allocation.Height);
            }
            else
            {
                cr.Arc(Allocation.Width - round, Allocation.Height - round, round, 0, Math.PI * 0.5);
            }
            if (y_align == 1.0)
            {
                cr.LineTo(0, Allocation.Height);
            }
            else
            {
                cr.Arc(round, Allocation.Height - round, round, Math.PI * 0.5, Math.PI);
            }
            cr.Arc(round, round, round, Math.PI, Math.PI * 1.5);
            cr.ClosePath();
            cr.Fill();
        }
Пример #2
0
		public bool OnExpose (Context ctx, Gdk.Rectangle allocation)
		{
			if (frames == 0)
				start = DateTime.UtcNow;
			
			frames ++;
			TimeSpan elapsed = DateTime.UtcNow - start;
			double fraction = elapsed.Ticks / (double) duration.Ticks; 
			double opacity = Math.Sin (Math.Min (fraction, 1.0) * Math.PI * 0.5);
			
			ctx.Operator = Operator.Source;
			
			SurfacePattern p = new SurfacePattern (begin_buffer.Surface);
			ctx.Matrix = begin_buffer.Fill (allocation);
			p.Filter = Filter.Fast;
			ctx.Source = p;
			ctx.Paint ();
			
			ctx.Operator = Operator.Over;
			ctx.Matrix = end_buffer.Fill (allocation);
			SurfacePattern sur = new SurfacePattern (end_buffer.Surface);
#if MONO_1_2_5
			Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity));
#else
			Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity), true);
#endif
			//ctx.Source = black;
			//ctx.Fill ();
			sur.Filter = Filter.Fast;
			ctx.Source = sur;
			ctx.Mask (black);
			//ctx.Paint ();
			
			ctx.Matrix = new Matrix ();
			
			ctx.MoveTo (allocation.Width / 2.0, allocation.Height / 2.0);
			ctx.Source = new SolidPattern (1.0, 0, 0);	
			#if debug
			ctx.ShowText (String.Format ("{0} {1} {2} {3} {4} {5} {6} {7}", 
						     frames,
						     sur.Status,
						     p.Status,
						     opacity, fraction, elapsed, start, DateTime.UtcNow));
			#endif
			sur.Destroy ();
			p.Destroy ();
			return fraction < 1.0;
		}
Пример #3
0
        protected virtual void ShapeSurface(Context cr, Cairo.Color color)
        {
            cr.Operator = Operator.Source;
            Cairo.Pattern p = new Cairo.SolidPattern(new Cairo.Color(0, 0, 0, 0));
            cr.SetSource(p);
            p.Dispose();
            cr.Paint();
            cr.Operator = Operator.Over;

            Cairo.Pattern r = new SolidPattern(color);
            cr.SetSource(r);
            r.Dispose();
            cr.MoveTo(round, 0);
            if (x_align == 1.0)
            {
                cr.LineTo(Allocation.Width, 0);
            }
            else
            {
                cr.Arc(Allocation.Width - round, round, round, -Math.PI * 0.5, 0);
            }
            if (x_align == 1.0 || y_align == 1.0)
            {
                cr.LineTo(Allocation.Width, Allocation.Height);
            }
            else
            {
                cr.Arc(Allocation.Width - round, Allocation.Height - round, round, 0, Math.PI * 0.5);
            }
            if (y_align == 1.0)
            {
                cr.LineTo(0, Allocation.Height);
            }
            else
            {
                cr.Arc(round, Allocation.Height - round, round, Math.PI * 0.5, Math.PI);
            }
            cr.Arc(round, round, round, Math.PI, Math.PI * 1.5);
            cr.ClosePath();
            cr.Fill();
        }
Пример #4
0
        protected virtual void ShapeSurface(Context cr, Cairo.Color color)
        {
            cr.Operator = Operator.Source;
            Cairo.Pattern p = new Cairo.SolidPattern (new Cairo.Color (0, 0, 0, 0));
            cr.Source = p;
            p.Destroy ();
            cr.Paint ();
            cr.Operator = Operator.Over;

            Cairo.Pattern r = new SolidPattern (color);
            cr.Source = r;
            r.Destroy ();
            cr.MoveTo (round, 0);
            if (x_align == 1.0)
                cr.LineTo (Allocation.Width, 0);
            else
                cr.Arc (Allocation.Width - round, round, round, - Math.PI * 0.5, 0);
            if (x_align == 1.0 || y_align == 1.0)
                cr.LineTo (Allocation.Width, Allocation.Height);
            else
                cr.Arc (Allocation.Width - round, Allocation.Height - round, round, 0, Math.PI * 0.5);
            if (y_align == 1.0)
                cr.LineTo (0, Allocation.Height);
            else
                cr.Arc (round, Allocation.Height - round, round, Math.PI * 0.5, Math.PI);
            cr.Arc (round, round, round, Math.PI, Math.PI * 1.5);
            cr.ClosePath ();
            cr.Fill ();
        }
Пример #5
0
        /// <summary>
        /// Exports the specified <see cref="PlotModel" /> to the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="stream">The output stream.</param>
        public void Export(IPlotModel model, Stream stream)
        {
            using (var bm = new ImageSurface(Format.ARGB32, this.Width, this.Height))
            {
                using (var g = new Context(bm))
                {
                    if (this.Background.IsVisible())
                    {
                        g.Save();
                        using (var pattern = new SolidPattern(this.Background.R, this.Background.G, this.Background.B, this.Background.A))
                        {
                            g.SetSource(pattern);
                            g.Rectangle(0, 0, this.Width, this.Height);
                            g.Fill();
                        }

                        g.Restore();
                    }

                    var rc = new GraphicsRenderContext { RendersToScreen = false };
                    rc.SetGraphicsTarget(g);
                    model.Update(true);
                    model.Render(rc, this.Width, this.Height);

                    // write to a temporary file
                    var tmp = Guid.NewGuid() + ".png";
                    bm.WriteToPng(tmp);
                    var bytes = File.ReadAllBytes(tmp);

                    // write to the stream
                    stream.Write(bytes, 0, bytes.Length);

                    // delete the temporary file
                    File.Delete(tmp);
                }
            }
        }