Example #1
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.ArcNegative (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 ();
	}
Example #2
0
		/// <summary>
		/// Draws the outline of the button to the given context.
		/// </summary>
		/// <remarks>This can be used by decorators to avoid doing the geometry themselves.</remarks>
		public void DrawOutline(Cairo.Context cr)
		{
			// can't do anything if we're not inside a ring bar
			if (!(ParentControl is RingBar))
				return;
			var ringBar = ParentControl as RingBar;
			var outerRadius = ringBar.OuterRadius;

			var startAngle = CenterAngle.Negate() - ringBar.DiffAngle / 2;
			var stopAngle = startAngle + ringBar.DiffAngle;
			var inner = new Coord(ringBar.InnerRadius, 0).Rotate(startAngle);
			var outer = new Coord(ringBar.OuterRadius-2, 0).Rotate(startAngle);
			cr.MoveTo(outerRadius + inner.X, outerRadius + inner.Y);
			cr.LineTo(outerRadius + outer.X, outerRadius + outer.Y);
			cr.Arc(outerRadius, outerRadius, outerRadius-2, startAngle.Radians, stopAngle.Radians);
			var rotatedInner = inner.Rotate(ringBar.DiffAngle);
			cr.LineTo(outerRadius + rotatedInner.X, outerRadius + rotatedInner.Y);
			cr.ArcNegative(outerRadius, outerRadius, ringBar.InnerRadius, stopAngle.Radians, startAngle.Radians);
		}