Пример #1
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		int w, h;
		ImageSurface image;
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
		gr.Clip ();
		gr.NewPath ();
		
		image = new ImageSurface("data/e.png");
		w = image.Width;
		h = image.Height;
		
		gr.Scale (1.0/w, 1.0/h);
		
		image.Show (gr, 0, 0);
		
		image.Destroy();
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();
		
		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
		gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
Пример #2
0
        public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
		                                        double width, double height, double radius,
		                                        Cairo.Color color, Cairo.Color borderColor)
        {
            gr.Save();

            if((radius > height / 2) || (radius > width / 2))
                radius = Math.Min(height / 2, width / 2);

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();

            gr.LineJoin = LineJoin.Round;
            gr.Color = borderColor;
            gr.StrokePreserve();
            gr.Color = color;
            gr.Fill();
        }
Пример #3
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		double xc = 0.5;
		double yc = 0.5;
		double radius = 0.4;
		double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
		double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		
		gr.Arc (xc, yc, radius, angle1, angle2);
		gr.Stroke ();
		
		/* draw helping lines */
		gr.Color = new Color(1, 0.2, 0.2, 0.6);
		gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
		gr.Fill ();
		gr.LineWidth = 0.03;
		gr.Arc (xc, yc, radius, angle1, angle1);
		gr.LineTo (new PointD(xc, yc));
		gr.Arc (xc, yc, radius, angle2, angle2);
		gr.LineTo (new PointD(xc, yc));
		gr.Stroke ();
		
	}
        public static void RoundedRectangle(Cairo.Context c, RectangleD rect, double radius)
        {
            if (radius > (rect.Width /2) || radius > (rect.Height / 2)) {
                radius = Math.Min ((rect.Width /2), (rect.Height / 2));
            }

            c.Save ();

            /* Bottom Left */
            c.MoveTo(rect.X, rect.Y + radius);
            c.Arc (rect.X + radius, rect.Y + radius, radius, Math.PI, -Math.PI/2);
            c.LineTo (rect.X2 - radius, rect.Y);

            /* Bottom Right */
            c.Arc (rect.X2 - radius, rect.Y + radius, radius, -Math.PI/2, 0);
            c.LineTo (rect.X2, rect.Y2 - radius);

            /* Top Right */
            c.Arc (rect.X2 - radius, rect.Y2 - radius, radius, 0, Math.PI/2);
            c.LineTo (rect.X + radius, rect.Y2);

            /* Top Left */
            c.Arc(rect.X + radius, rect.Y2 - radius, radius, Math.PI/2, Math.PI);
            c.ClosePath ();

            c.Restore ();
        }
Пример #5
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		LinearGradient pat;		
		
		pat = new LinearGradient (0.0, 0.0,  0.0, 1.0);
		pat.AddColorStop (1, new Color (0, 0, 0, 1) );
		pat.AddColorStop (0, new Color (1, 1, 1, 1) );
		gr.Rectangle ( new PointD (0, 0),
			       1, 1
			       );
		
		gr.Pattern =  pat;
		gr.Fill ();
		pat.Destroy ();

		RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
				     0.4,  0.4, 0.5);
		
		pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
		pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
		gr.Pattern =  pat2;
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Fill ();
		pat2.Destroy ();
	}
Пример #6
0
 public void draw(Cairo.Context cr)
 {
     cr.MoveTo (position);
     cr.SetSourceRGB (0, 1.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
Пример #7
0
		protected void DrawCircle (Cairo.Context cr, double x, double y, double size)
		{
			x += 0.5; y += 0.5;
			cr.NewPath ();
			cr.Arc (x + size/2, y + size / 2, (size-4)/2, 0, 2 * Math.PI);
			cr.ClosePath ();
		}
Пример #8
0
	static void oval_path (Cairo.Context gr, double xc, double yc, double xr, double yr)
	{
		gr.Translate (xc, yc);
		gr.Scale (1.0, yr / xr);
		gr.MoveTo (new PointD (xr, 0.0) );
		gr.Arc (0, 0, xr, 0, 2 * M_PI);
		gr.ClosePath ();
	}
Пример #9
0
        static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius)
        {
            gr.Save ();

            if ((radius > height / 2) || (radius > width / 2))
                radius = min (height / 2, width / 2);
            gr.Color = new Color (200, 10, 210, 1);
            gr.MoveTo (x, y + radius);
            gr.Arc (x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo (x + width - radius, y);
            gr.Arc (x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo (x + width, y + height - radius);
            gr.Arc (x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo (x + radius, y + height);
            gr.Arc (x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath ();
            gr.Restore ();
        }
Пример #10
0
 public void draw(Cairo.Context cr)
 {
     if (!canSeePlayer) {
         return;
     }
     cr.MoveTo (position);
     cr.SetSourceRGB (1.0, 0.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
Пример #11
0
		static void DrawFace (Cairo.PointD center, double radius, Cairo.Context e)
		{
			e.Arc (center.X, center.Y, radius, 0, 360);
			Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100);
			pat.AddColorStop (0, Eto.Drawing.Color.FromArgb (240, 240, 230, 75).ToCairo ());
			pat.AddColorStop (1, Eto.Drawing.Color.FromArgb (0, 0, 0, 50).ToCairo ());
			e.LineWidth = 0.1;
			e.Pattern = pat;
			e.FillPreserve ();
			e.Stroke ();
		}
Пример #12
0
 public static void RenderCircle(Cairo.Context g, Cairo.Color c, double r, double x, double y)
 {
     g.Save();
     g.Color = c;
     g.MoveTo(x, y);
     g.Arc(x, y, r, 0, 6.28);
     g.LineWidth = 3;
     g.ClosePath();
     g.Fill();
     g.Restore();
 }
Пример #13
0
		void DrawFace (Cairo.PointD center, double radius, Cairo.Context e)
		{
			e.Arc (center.X, center.Y, radius, 0, 360);
			Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100);
			pat.AddColorStop (0, Generator.ConvertC (new Eto.Drawing.Color (240, 240, 230, 75)));
			pat.AddColorStop (1, Generator.ConvertC (new Eto.Drawing.Color (0, 0, 0, 50)));
			e.LineWidth = 0.1;
			e.Pattern = pat;
			e.FillPreserve ();
			e.Stroke ();
		}
Пример #14
0
        /// <summary>
        /// The draw rounded rectangle.
        /// </summary>
        protected void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius)
        {
            gr.Save();

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            gr.MoveTo(this._x + x, this._y + y + radius);
            gr.Arc(this._x + x + radius, this._y + y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(this._x + x + width - radius, this._y + y);
            gr.Arc(this._x + x + width - radius, this._y + y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(this._x + x + width, this._y + y + height - radius);
            gr.Arc(this._x + x + width - radius, this._y + y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(this._x + x + radius, this._y + y + height);
            gr.Arc(this._x + x + radius, this._y + y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();
        }
Пример #15
0
	static void draw (Cairo.Context gr, int width, int height)
	{		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
		gr.SetFontSize (0.35);
		
		gr.MoveTo ( new PointD(0.04, 0.53) );
		gr.ShowText ("Hello");
		
		gr.MoveTo ( new PointD(0.27, 0.65) );
		gr.TextPath ("void");
		gr.ColorRgb = new Color (0.5, 0.5, 1, 0);
		gr.FillPreserve ();
		gr.ColorRgb = new Color (0, 0, 0, 0);
		gr.LineWidth =  0.01;
		gr.Stroke ();
		
		gr.Color = new Color (1,0.2,0.2, 0.6);
		gr.Arc (0.04, 0.53, 0.02, 0, 2*M_PI);
		gr.Arc (0.27, 0.65, 0.02, 0, 2*M_PI);
		gr.Fill ();				
	}
Пример #16
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();

		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
	        gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
Пример #17
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad = radius - 0.5;
            int centerX = region.X + region.Width / 2;
            int centerY = region.Y + region.Height / 2;

            context.MoveTo (centerX + rad, centerY);
            context.Arc (centerX, centerY, rad, 0, Math.PI * 2);

            double high;
            double low;
            switch (state) {
            case StateType.Selected:
                high = 0.85;
                low = 1.0;
                break;
            case StateType.Prelight:
                high = 1.0;
                low = 0.9;
                break;
            case StateType.Insensitive:
                high = 0.95;
                low = 0.83;
                break;
            default:
                high = 1.0;
                low = 0.85;
                break;
            }
            using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
                lg.AddColorStop (0, new Cairo.Color (high, high, high));
                lg.AddColorStop (1, new Cairo.Color (low, low, low));
                context.SetSource (lg);
                context.FillPreserve ();
            }

            context.SetSourceRGBA (0, 0, 0, 0.4);
            context.LineWidth = 1;
            context.Stroke ();
        }
Пример #18
0
		static void DrawCloseButton (Cairo.Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				double fillColor = .74;

				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);

				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();

				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);

					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();


					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new Cairo.LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.Pattern = lg;
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();
				}
			}
		}
Пример #19
0
		public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
		                                    double r, CairoCorners corners, bool topBottomFallsThrough)
		{
			if(topBottomFallsThrough && corners == CairoCorners.None) {
				cr.MoveTo(x, y - r);
				cr.LineTo(x, y + h + r);
				cr.MoveTo(x + w, y - r);
				cr.LineTo(x + w, y + h + r);
				return;
			} else if(r < 0.0001 || corners == CairoCorners.None) {
				cr.Rectangle(x, y, w, h);
				return;
			}
			
			if((corners & (CairoCorners.TopLeft | CairoCorners.TopRight)) == 0 && topBottomFallsThrough) {
				y -= r;
				h += r;
				cr.MoveTo(x + w, y);
			} else {
				if((corners & CairoCorners.TopLeft) != 0) {
					cr.MoveTo(x + r, y);
				} else {
					cr.MoveTo(x, y);
				}
				if((corners & CairoCorners.TopRight) != 0) {
					cr.Arc(x + w - r, y + r, r, System.Math.PI * 1.5, System.Math.PI * 2);
				} else {
					cr.LineTo(x + w, y);
				}
			}
			
			if((corners & (CairoCorners.BottomLeft | CairoCorners.BottomRight)) == 0 && topBottomFallsThrough) {
				h += r;
				cr.LineTo(x + w, y + h);
				cr.MoveTo(x, y + h);
				cr.LineTo(x, y + r);
				cr.Arc(x + r, y + r, r, System.Math.PI, System.Math.PI * 1.5);
			} else {
				if((corners & CairoCorners.BottomRight) != 0) {
					cr.Arc(x + w - r, y + h - r, r, 0, System.Math.PI * 0.5);
				} else {
					cr.LineTo(x + w, y + h);
				}
				
				if((corners & CairoCorners.BottomLeft) != 0) {
					cr.Arc(x + r, y + h - r, r, System.Math.PI * 0.5, System.Math.PI);
				} else {
					cr.LineTo(x, y + h);
				}
				
				if((corners & CairoCorners.TopLeft) != 0) {
					cr.Arc(x + r, y + r, r, System.Math.PI, System.Math.PI * 1.5);
				} else {
					cr.LineTo(x, y);
				}
			}
		}
Пример #20
0
		void DrawBlockBg (Cairo.Context ctx, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;
			
			x += 0.5;
			Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor;
			double y = block.YStart + 0.5;
			int height = block.YEnd - block.YStart;
			
			double markerx = x + LeftPaddingBlock - 0.5;
			double rd = RoundedSectionRadius;
			if (block.SectionStart) {
				ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
				ctx.LineTo (markerx, y);
			} else {
				ctx.MoveTo (markerx, y);
			}
			
			ctx.LineTo (markerx, y + height);
			
			if (block.SectionEnd) {
				ctx.LineTo (x + rd, y + height);
				ctx.Arc (x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
			} else {
				ctx.LineTo (x, y + height);
			}
			if (block.SectionStart) {
				ctx.LineTo (x, y + rd);
			} else {
				ctx.LineTo (x, y);
			}
			ctx.Color = color.AddLight (0.1).ToCairoColor ();
			ctx.Fill ();
			
			ctx.Rectangle (markerx, y, width - markerx, height);
			Cairo.Gradient pat = new Cairo.LinearGradient (x, y, x + width, y);
			pat.AddColorStop (0, color.AddLight (0.21).ToCairoColor ());
			pat.AddColorStop (1, color.AddLight (0.3).ToCairoColor ());
			ctx.Pattern = pat;
			ctx.Fill ();
		}
		static void RoundBorder (Cairo.Context ctx, double x, double y, double w, double h)
		{
			double r = h / 2;
			ctx.Arc (x + r, y + r, r, Math.PI / 2, Math.PI + Math.PI / 2);
			ctx.LineTo (x + w - r, y);
			
			ctx.Arc (x + w - r, y + r, r, Math.PI + Math.PI / 2, Math.PI + Math.PI + Math.PI / 2);
			
			ctx.LineTo (x + r, y + h);
			
			ctx.ClosePath ();
		}
Пример #22
0
		void DrawBlockBg (Cairo.Context ctx, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;
			
			var color = block.Type == BlockType.Added ? Styles.LogView.DiffAddBackgroundColor : Styles.LogView.DiffRemoveBackgroundColor;
			double y = block.YStart;
			int height = block.YEnd - block.YStart;
			
			double markerx = x + LeftPaddingBlock;
			double rd = RoundedSectionRadius;
			if (block.SectionStart) {
				ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
				ctx.LineTo (markerx, y);
			} else {
				ctx.MoveTo (markerx, y);
			}
			
			ctx.LineTo (markerx, y + height);
			
			if (block.SectionEnd) {
				ctx.LineTo (x + rd, y + height);
				ctx.Arc (x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
			} else {
				ctx.LineTo (x, y + height);
			}
			if (block.SectionStart) {
				ctx.LineTo (x, y + rd);
			} else {
				ctx.LineTo (x, y);
			}
			ctx.SetSourceColor (color.AddLight (0.1).ToCairoColor ());
			ctx.Fill ();
			
			ctx.Rectangle (markerx, y, width - markerx, height);

			// FIXME: VV: Remove gradient features
			using (Cairo.Gradient pat = new Cairo.LinearGradient (x, y, x + width, y)) {
				pat.AddColorStop (0, color.AddLight (0.21).ToCairoColor ());
				pat.AddColorStop (1, color.AddLight (0.3).ToCairoColor ());
				ctx.SetSource (pat);
				ctx.Fill ();
			}
		}
		protected void DrawSearchIndicator (Cairo.Context cr)
		{
			int diameter = Math.Min (Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2;
			var x1 = Math.Round (Allocation.Width / 2d);
			double y1 = indicatorPadding;
			if (diameter % 2 == 0) {
				x1 += 0.5;
				y1 += 0.5;
			}

			cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);
			
			var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color;
			darkColor.L *= 0.5;

			if (flatStyle) {
				using (var pattern = new Cairo.SolidPattern (TextEditor.ColorStyle.SearchResultMain.Color)) {
					cr.Pattern = pattern;
					cr.FillPreserve ();
				}
			} else {
				using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) {
					pattern.AddColorStop (0, darkColor);
					pattern.AddColorStop (1, TextEditor.ColorStyle.SearchResultMain.Color);
					cr.Pattern = pattern;
					cr.FillPreserve ();
				}
			}
			
			cr.Color = darkColor;
			cr.Stroke ();
		}
Пример #24
0
		void DrawRoundedRectangle (Cairo.Context c, Cairo.Rectangle rect)
		{
			double x = rect.X;
			double y = rect.Y;
			double width = rect.Width;
			double height = rect.Height;
			double radius = 5;
			
			c.MoveTo (x, y + radius);
			c.Arc (x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
			c.LineTo (x + width - radius, y);
			c.Arc (x + width - radius, y + radius, radius, -Math.PI / 2, 0);
			c.LineTo (x + width, y + height - radius);
			c.Arc (x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
			c.LineTo (x + radius, y + height);
			c.Arc (x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
			c.ClosePath ();
			
			c.Color = new Cairo.Color (161 / 255.0, 40 / 255.0, 48 / 255.0);
			c.Fill ();
		}
Пример #25
0
        public override void Draw(Cairo.Context dc)
        {
            Pen p = IsDashed ? PensAndBrushes.DashedPen : ThePen;
            float R = (float) (center-p1).Length;   // the radius of the circle
            var diag = new System.Windows.Vector(R,R);
            Rect re = new System.Windows.Rect(center+diag, center-diag);  // BB of the circle
            System.Windows.Vector v1 = p1 - center, v2 = p2 - center;


            if (IsPie)
            {
                dc.DrawLine(center, p1); //p, 
                dc.DrawLine(center, p2); //p, 
            }

            float angle2 = (float)( Math.Atan2(v2.Y, v2.X) *180 / Math.PI);
            float angle1 = (float)( Math.Atan2(v1.Y, v1.X) *180 / Math.PI);
            float angle = angle2 - angle1;
            float bngle = angle + (angle>0?-360:360);


            if (     ( IsLargeArc && Math.Abs(angle) < 180)
                 ||  (!IsLargeArc && Math.Abs(angle) > 180) )
                angle = bngle;

            if (re.Height * re.Width > 0)
            {
                dc.Arc( re.Center().X, re.Center().Y, re.Width/2, angle1, angle);//p, // hack
            }
            /* TODO
            context.BeginFigure(p1, false, IsPie);
            
            SweepDirection sd;
            if ((v1.X * v2.Y - v1.Y * v2.X > 0) != LargeArc)
                sd = SweepDirection.Clockwise;
            else
                sd = SweepDirection.Counterclockwise;

            context.ArcTo(p2, new Size(r, r), 0, LargeArc, sd, true, false);*/

            
        }
Пример #26
0
		void DrawBuildEffect (Cairo.Context context, Gdk.Rectangle area, double progress, double opacity)
		{
			context.Save ();
			LayoutRoundedRectangle (context, area);
			context.Clip ();

			Gdk.Point center = new Gdk.Point (area.Left + 19, (area.Top + area.Bottom) / 2);
			context.Translate (center.X, center.Y);
			var circles = new [] {
				new { Radius = 200, Thickness = 12, Speed = 1, ArcLength = Math.PI * 1.50 },
				new { Radius = 195, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.50 },
				new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 },
				new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 },
				new { Radius = 240, Thickness = 12, Speed = 3, ArcLength = Math.PI * 1.50 },
				new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 },
				new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 },
				new { Radius = 215, Thickness = 20, Speed = 2, ArcLength = Math.PI * 1.25 }
			};

			double zmod = 1.0d;
			double zporg = progress;
			foreach (var arc in circles) {
				double zoom = 1.0d;
				zoom = (double) Math.Sin (zporg * Math.PI * 2 + zmod);
				zoom = ((zoom + 1) / 6.0d) + .05d;

				context.Rotate (Math.PI * 2 * progress * arc.Speed);
				context.MoveTo (arc.Radius * zoom, 0);
				context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength);
				context.LineWidth = arc.Thickness * zoom;
				context.Color = CairoExtensions.ParseColor ("B1DDED", 0.35 * opacity);
				context.Stroke ();
				context.Rotate (Math.PI * 2 * -progress * arc.Speed);

				progress = -progress;

				context.Rotate (Math.PI * 2 * progress * arc.Speed);
				context.MoveTo (arc.Radius * zoom, 0);
				context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength);
				context.LineWidth = arc.Thickness * zoom;
				context.Stroke ();
				context.Rotate (Math.PI * 2 * -progress * arc.Speed);

				progress = -progress;

				zmod += (float)Math.PI / circles.Length;
			}

			context.LineWidth = 1;
			context.ResetClip ();
			context.Restore ();
		}
 public static void DrawCircle(Cairo.Context cr, double x, double y, double r)
 {
     cr.Arc (x, y, r, 0, 2 * Math.PI);
 }
Пример #28
0
		void DrawSearchIndicator (Cairo.Context cr)
		{
			int x1 = 1 + Allocation.Width / 2;
			int y1 = Allocation.Height - Allocation.Width + (Allocation.Width + 3) / 2;
			cr.Arc (x1, 
				y1, 
				(Allocation.Width - 5) / 2, 
				0, 
				2 * Math.PI);
			
			var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg;
			darkColor.L *= 0.5;
			
			using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) {
				pattern.AddColorStop (0, darkColor);
				pattern.AddColorStop (1, TextEditor.ColorStyle.SearchTextMainBg);
				cr.Pattern = pattern;
				cr.FillPreserve ();
			}
			
			cr.Color = darkColor;
			cr.Stroke ();
		}
Пример #29
0
		void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor)
		{
			var width = Allocation.Width;

			int diameter = Math.Min (width, (int)IndicatorHeight) - indicatorPadding * 2;
			var x1 = Math.Round (width / 2d);
			double y1 = indicatorPadding + diameter / 2;
			if (diameter % 2 == 0) {
				x1 += 0.5;
				y1 += 0.5;
			}

			cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);

			if (Platform.IsWindows) {
				using (var pattern = new Cairo.SolidPattern (color)) {
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			} else {
				using (var pattern = new Cairo.RadialGradient (x1, y1, width / 2, x1 - width, y1 - width, width)) {
					pattern.AddColorStop (0, borderColor);
					pattern.AddColorStop (1, color);
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			}
			
			cr.SetSourceColor (borderColor);
			cr.Stroke ();
		}
Пример #30
0
        //private double last_invalidate_value = -1;

        /*private void Invalidate ()
        {
            double current_value = (IsValueUpdatePending ? PendingValue : Value);

            // FIXME: Something is wrong with the updating below causing an
            // invalid region when IsValueUpdatePending is true, so when
            // that is the case for now, we trigger a full invalidation
            if (last_invalidate_value < 0 || IsValueUpdatePending) {
                last_invalidate_value = current_value;
                InvalidateRender ();
                return;
            }

            double max = Math.Max (last_invalidate_value, current_value) * RenderSize.Width;
            double min = Math.Min (last_invalidate_value, current_value) * RenderSize.Width;

            Rect region = new Rect (
                InvalidationRect.X + min,
                InvalidationRect.Y,
                (max - min) + 2 * ThrobberSize,
                InvalidationRect.Height
            );

            last_invalidate_value = current_value;
            InvalidateRender (region);
        }*/

        /*protected override Rect InvalidationRect {
            get { return new Rect (
                -Margin.Left - ThrobberSize / 2,
                -Margin.Top,
                Allocation.Width + ThrobberSize,
                Allocation.Height);
            }
        }*/

        protected override void ClippedRender (Cairo.Context cr)
        {
            double throbber_r = ThrobberSize / 2.0;
            double throbber_x = Math.Round (RenderSize.Width * (IsValueUpdatePending ? PendingValue : Value));
            double throbber_y = (Allocation.Height - ThrobberSize) / 2.0 - Margin.Top + throbber_r;
            double bar_w = RenderSize.Width * Value;

            cr.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, Gtk.StateType.Normal);
            cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
            cr.Fill ();

            Color color = Theme.Colors.GetWidgetColor (GtkColorClass.Dark, Gtk.StateType.Active);
            Color fill_color = CairoExtensions.ColorShade (color, 0.4);
            Color light_fill_color = CairoExtensions.ColorShade (color, 0.3);
            fill_color.A = 1.0;
            light_fill_color.A = 1.0;

            LinearGradient fill = new LinearGradient (0, 0, 0, RenderSize.Height);
            fill.AddColorStop (0, light_fill_color);
            fill.AddColorStop (0.5, fill_color);
            fill.AddColorStop (1, light_fill_color);

            cr.Rectangle (0, 0, bar_w, RenderSize.Height);
            cr.Pattern = fill;
            cr.Fill ();

            cr.Color = fill_color;
            cr.Arc (throbber_x, throbber_y, throbber_r, 0, Math.PI * 2);
            cr.Fill ();
        }