internal static void FillCircle(this Cairo.Context g, Point center, float radius, Color color) { g.NewPath(); g.SetSourceColor(color); g.Arc(center.X, center.Y, radius, 0, 2 * Math.PI); g.Fill(); }
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(); }
public void DrawRoundedRectangle(Cairo.Context aContext, double aRadius) { if ((aRadius > height / 2) || (aRadius > width / 2)) { aRadius = Math.Min(height / 2, width / 2); } aContext.MoveTo(x, y + aRadius); aContext.Arc(x + aRadius, y + aRadius, aRadius, Math.PI, -Math.PI / 2); aContext.LineTo(x + width - aRadius, y); aContext.Arc(x + width - aRadius, y + aRadius, aRadius, -Math.PI / 2, 0); aContext.LineTo(x + width, y + height - aRadius); aContext.Arc(x + width - aRadius, y + height - aRadius, aRadius, 0, Math.PI / 2); aContext.LineTo(x + aRadius, y + height); aContext.Arc(x + aRadius, y + height - aRadius, aRadius, Math.PI / 2, Math.PI); aContext.ClosePath(); }
internal static void StrokeCircle(this Cairo.Context g, Point center, float radius, Color color) { g.NewPath(); g.LineWidth = 1; g.SetSourceColor(color); g.Arc(center.X, center.Y, radius, 0, 2 * Math.PI); g.Stroke(); }
/// <summary> /// Render a list of points. /// </summary> public void RenderPoints(IEnumerable <IVector> points, Cairo.Context gr, double radius) { foreach (IVector iv in points) { this.TransformPoint(iv, ref _p0); gr.Arc(_p0.X, _p0.Y, radius, 0, 2 * Math.PI); gr.Fill(); } }
public override void Draw(Cairo.Context surface, int PositionX, int PositionY) { X = PositionX; Y = PositionY; surface.SetSourceRGBA(R, G, B, 0.4); surface.Arc(X, Y, Radius, 0, Math.PI * 2); surface.Stroke(); }
public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera) { // just draw a circle var pos = camera.Transform(this.position) - camera.Transform(origin); var cl = this.color; ctx.SetSourceRGB(cl.x, cl.y, cl.z); ctx.Arc(pos.x, pos.y, this.radius, 0, 2 * Math.PI); ctx.Fill(); }
public 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.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(); }
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(); }
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(); }
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(); }
private void DrawCenterFilledCircle(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, CairoUtil.ColorFromRgb(240, 235, 229, 0.3)); pat.AddColorStop(1, CairoUtil.ColorFromRgb(0, 0, 0, 0.2)); e.LineWidth = 0.1; e.Pattern = pat; e.FillPreserve(); e.Stroke(); }
public override void Draw(Cairo.Context surface, int x, int y) { X = x; Y = y; int waveTops = Radius / 3; int waveBottoms = Radius / 2; int waveDepths = Radius / 6; WaterTemperature = CurrentData.GetCurrentValueByIdFloat(XIVELY_DATA_STREAM_ID); //WaterTemperature = WaterTemperature / 100; // CIRCLE surface.SetSourceRGBA(1, 1, 1, 0.3); surface.Arc(X, Y, Radius, 0, Math.PI * 2); surface.Fill(); surface.SetSourceRGBA(1, 1, 1, WaterLight); surface.Arc(X, Y, Radius + 5, 0, Math.PI * 2); surface.Stroke(); surface.Fill(); // WAVEFORMED CIRCLE surface.CurveTo(X - Radius, Y - waveDepths, X - waveBottoms, Y + waveDepths, X - waveTops, Y - waveDepths); surface.CurveTo(X - waveTops, Y - waveDepths, X, Y + waveDepths, X + waveTops, Y - waveDepths); surface.CurveTo(X + waveTops, Y - waveDepths, X + waveBottoms, Y + waveDepths, X + Radius, Y - waveDepths); surface.SetSourceRGBA(colorWater[0], colorWater[1], colorWater[2], alphaChannel); surface.Arc(X, Y, Radius, 0, Math.PI * 1); surface.Fill(); // TEXT surface.SetSourceRGBA(1, 1, 1, 0.1); surface.MoveTo(X, Y); surface.SetFontSize(Radius / 2); string widgetText = Convert.ToString(WaterTemperature); Cairo.TextExtents text = surface.TextExtents(widgetText); surface.MoveTo(X - (text.Width / 2), Y + (text.Height / 2)); surface.ShowText(widgetText); surface.Fill(); }
internal static void DrawEllipse(Cairo.Context context, Ellipse el, double startAngle = 0, double endAngle = Math.PI * 2) { var radius = Math.Max(el.AxisA.Length, el.AxisB.Length); var scaleX = el.AxisA.Length / radius; var scaleY = el.AxisB.Length / radius; context.Save(); context.Scale(scaleX, scaleY); context.Arc(el.Center.X, el.Center.Y, radius, startAngle, endAngle); context.Stroke(); context.Restore(); }
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(); }
public override void DrawEllipse(Brush brush, Pen pen, Point center, double radiusX, double radiusY) { cr.Save(); cr.Translate(center.X, center.Y); cr.Scale(1, radiusY / radiusX); if (brush != null) { if (brush is SolidColorBrush) { var b = brush as SolidColorBrush; cr.Color = new Cairo.Color(b.Color.R, b.Color.G, b.Color.B, b.Color.Alfa); cr.Arc(0, 0, radiusX, 0, 2 * Math.PI); cr.Fill(); } } if (pen != null) { cr.Color = new Cairo.Color(pen.Color.R, pen.Color.G, pen.Color.B, pen.Color.Alfa); cr.LineWidth = pen.Thickness; cr.Arc(0, 0, radiusX - pen.Thickness / 2, 0, 2 * Math.PI); cr.Stroke(); } cr.Restore(); }
public override void Draw(Cairo.Context context) { Cairo.Matrix oldMatrix = context.Matrix; double a = MinorAxis / _majorAxis; context.Translate(0.0, _position.Y * (1 - a)); context.Scale(1.0, a); context.MoveTo(_position.X + _majorAxis, _position.Y); context.Arc(_position.X, _position.Y, _majorAxis, 0.0, 2 * Math.PI); context.ClosePath(); //todo change in order to process rotated ellipses (i.e. MajorAxis is collinear with OY) context.Matrix = oldMatrix; }
public static void FillEllipse(this Cairo.Context dc, double x, double y, double width, double height) { dc.Save(); dc.Translate(x + width / 2, y + height / 2); dc.Scale(width / 2, height / 2); dc.Arc(0, 0, 1, 0, 2 * Math.PI); //dc.fill.SetupFill(); //dc.fill_preserve() //dc.SetupStroke() dc.Fill(); dc.Restore(); }
public override void Draw(Cairo.Context surface, int x, int y) { _humidityValue = CurrentData.GetCurrentValueByIdString(XIVELY_DATA_STREAM_ID); GraphContainer.AssignXivelyDatastreamStringById(_graphId, XIVELY_DATA_STREAM_ID); GraphContainer.SetGraphColorById(_graphId, G, R, 0.4f); X = x; Y = y; surface.SetSourceRGBA(R, B, G, Alpha); surface.Arc(X, Y, Radius, 0, Math.PI * 2); surface.Fill(); surface.SetSourceRGB(R, G, B); surface.Arc(X, Y, Radius + 5, 0, Math.PI * 2); surface.Stroke(); string widgetText = _humidityValue + "%"; surface.SetFontSize(15); Cairo.TextExtents text = surface.TextExtents(widgetText); surface.SetSourceRGBA(1, 1, 1, Alpha); surface.MoveTo(X - (text.Width / 2), Y + (text.Height / 2)); surface.ShowText(widgetText); widgetText = "Humidity"; surface.SetFontSize(13); text = surface.TextExtents(widgetText); surface.SetSourceRGBA(0.98f, 0.5f, 0.4f, Alpha); surface.MoveTo(X - (text.Width / 2), Y + (text.Height / 2) + 15); surface.ShowText(widgetText); }
void DrawIndicator(Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor) { const int indicatorPadding = 3; const int indicatorDiameter = 8; var x1 = Allocation.Width / 2d; var y1 = indicatorPadding + indicatorDiameter / 2d; cr.Arc(x1, y1, indicatorDiameter / 2d, 0, 2 * Math.PI); cr.SetSourceColor(color); cr.FillPreserve(); cr.SetSourceColor(borderColor); cr.Stroke(); }
/// <summary> /// Draw on specified surface. /// </summary> /// <param name="surface">Surface.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> public override void Draw(Cairo.Context surface, int x, int y) { X = x; Y = y; surface.SetSourceRGB(R, G, B); surface.Arc(X, Y, Radius, 0, Math.PI * 2); surface.Fill(); surface.SetSourceRGBA(0, 0, 0, 0.5f); surface.Arc(X, Y, Radius + 5, 0, Math.PI * 2); surface.Stroke(); string widgetText = "Preferences"; surface.SetFontSize(15); Cairo.TextExtents text = surface.TextExtents(widgetText); surface.SetSourceRGBA(1, 1, 1, _textAlpha); surface.MoveTo(X - (text.Width / 2), Y + (text.Height / 2)); surface.ShowText(widgetText); }
protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { using (Cairo.Context cr = Gdk.CairoHelper.Create(window)) { cr.LineWidth = 2.0; double center_x = cell_area.X + Math.Round((double)(cell_area.Width / 2d)); double center_y = cell_area.Y + Math.Round((double)(cell_area.Height / 2d)); cr.Arc(center_x, center_y, 5, 0, 2 * Math.PI); var state = StateType.Normal; if (!base.Sensitive) { state = StateType.Insensitive; } else if (flags.HasFlag(CellRendererState.Selected)) { if (widget.HasFocus) { state = StateType.Selected; } else { state = StateType.Active; } } else if (flags.HasFlag(CellRendererState.Prelit)) { state = StateType.Prelight; } else if (widget.State == StateType.Insensitive) { state = StateType.Insensitive; } cr.SetSourceColor(widget.Style.Text(state).ToCairoColor()); cr.Stroke(); if (!FirstNode) { cr.MoveTo(center_x, cell_area.Y - 2); cr.LineTo(center_x, center_y - 5); cr.Stroke(); } if (!LastNode) { cr.MoveTo(center_x, cell_area.Y + cell_area.Height + 2); cr.LineTo(center_x, center_y + 5); cr.Stroke(); } } }
public void DrawCloseButton(Cairo.Context cr) { var yArc = Allocation.Height / 2; var xArc = Allocation.Width - 14; cr.Arc(xArc, yArc, 6, 0, Math.PI * 2); cr.Color = IsCloseSelected ? new Cairo.Color(0, 0, 0) : new Cairo.Color(1, 1, 1); cr.Fill(); cr.Arc(xArc, yArc, 6, 0, Math.PI * 2); cr.ClosePath(); cr.Color = (Mono.TextEditor.HslColor)Style.Dark(StateType.Normal); cr.Stroke(); cr.Color = IsCloseSelected ? new Cairo.Color(1, 1, 1) : new Cairo.Color(0, 0, 0); cr.LineWidth = 1; cr.MoveTo(xArc - 3, yArc - 3); cr.LineTo(xArc + 3, yArc + 3); cr.Stroke(); cr.MoveTo(xArc + 3, yArc - 3); cr.LineTo(xArc - 3, yArc + 3); cr.Stroke(); }
protected override void DrawInnerFunction(Cairo.Context graphics, double uw, double x, double y, double width, double height) { double marg = uw * 3; double bmarg = uw * 5; double quart = (width - 2 * bmarg) / 4; double half = (width - 2 * bmarg) / 2; graphics.MoveTo(x + bmarg, y + height - bmarg); graphics.CurveTo(x + bmarg + quart, y + height - bmarg, x + bmarg + quart, y + bmarg, x + bmarg + half, y + bmarg); graphics.CurveTo(x + half + quart + bmarg, y + bmarg, x + half + quart + bmarg, y + height - bmarg, x + bmarg + half + half, y + height - bmarg); graphics.SetSourceRGB(0.3, 0.3, 0.6); graphics.Stroke(); graphics.Arc(x + bmarg, y + height - bmarg, marg, 0, System.Math.PI * 2); graphics.Fill(); graphics.Arc(x + bmarg + half, y + bmarg, marg, 0, System.Math.PI * 2); graphics.Fill(); graphics.Arc(x + bmarg + half + half, y + height - bmarg, marg, 0, System.Math.PI * 2); graphics.Fill(); }
protected virtual void GetBorderFrame(Cairo.Context cairo) { /* Override coordinates to align to the cairo grid */ double X, Y, Width, Height; X = x + cairo.LineWidth / 2.0; Y = y + cairo.LineWidth / 2.0; Width = width - cairo.LineWidth; Height = height - cairo.LineWidth; if (radius == 0) { cairo.MoveTo(X, Y); cairo.Rectangle(X, Y, Width, Height); } else { cairo.MoveTo(X + radius, Y); cairo.Arc(X + Width - radius, Y + radius, radius, (Math.PI * 1.5), (Math.PI * 2)); cairo.Arc(X + Width - radius, Y + Height - radius, radius, 0, (Math.PI * 0.5)); cairo.Arc(X + radius, Y + Height - radius, radius, (Math.PI * 0.5), Math.PI); cairo.Arc(X + radius, Y + radius, radius, Math.PI, (Math.PI * 1.5)); } }
void DrawIndicator(Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor) { var width = Allocation.Width; const int indicatorPadding = 3; int indicatorDiameter = Platform.IsWindows ? Math.Min(Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2 : 8; var x1 = Math.Round(width / 2d); double y1 = indicatorPadding + indicatorDiameter / 2; cr.Arc(x1, y1, indicatorDiameter / 2d, 0, 2 * Math.PI); cr.SetSourceColor(color); cr.FillPreserve(); cr.SetSourceColor(borderColor); cr.Stroke(); }
private void OnExpose(object obj, Gtk.ExposeEventArgs args) { Gtk.DrawingArea area = (Gtk.DrawingArea)obj; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width, height; width = Allocation.Width; height = Allocation.Height; double radius = Math.Min(width, height) / 4; //draw face cr.Arc(width / 2, height / 2, radius, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(0, 0, 0); cr.Fill(); //draw hands double hoursHandSize = 0.35 * radius; double minutesHandSize = 0.5 * radius; double secondsHandSize = 0.75 * radius; double x = width / 2; double y = height / 2; cr.LineWidth = 2 * cr.LineWidth; cr.SetSourceRGB(0, 255, 0); cr.MoveTo(x, y); cr.LineTo(x + hoursHandSize * Math.Cos(ToRadian(hoursHand)), y + hoursHandSize * Math.Sin(ToRadian(hoursHand))); cr.Stroke(); cr.MoveTo(x, y); cr.LineTo(x + minutesHandSize * Math.Cos(ToRadian(minutesHand)), y + minutesHandSize * Math.Sin(ToRadian(minutesHand))); cr.Stroke(); cr.LineWidth = 0.25 * cr.LineWidth; cr.SetSourceRGB(255, 0, 0); cr.MoveTo(x, y); cr.LineTo(x + secondsHandSize * Math.Cos(ToRadian(secondsHand)), y + secondsHandSize * Math.Sin(ToRadian(secondsHand))); cr.Stroke(); ((IDisposable)cr.Target).Dispose(); ((IDisposable)cr).Dispose(); }
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);*/ }
public static void DrawCircle(DrawingArea da, int width, int height, double lineWidth, double[] lineColor, double[] fillColor, Position position, double size) { Cairo.Context cr = Gdk.CairoHelper.Create(da.GdkWindow); cr.SetSourceRGB(lineColor[0], lineColor[1], lineColor[2]); cr.LineWidth = lineWidth; cr.Translate(position.x * width, position.y * height); cr.Arc(0, 0, size * width / 100f, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(fillColor[0], fillColor[1], fillColor[2]); cr.Fill(); ((IDisposable)cr.GetTarget()).Dispose(); ((IDisposable)cr).Dispose(); }
static void DrawSpaceAtIter(Cairo.Context cntx, TextView view, TextIter iter) { Gdk.Rectangle rect = view.GetIterLocation(iter); int x, y; view.BufferToWindowCoords(TextWindowType.Text, rect.X + rect.Width / 2, rect.Y + rect.Height / 2, out x, out y); cntx.Save(); cntx.Color = GetDrawingColorForIter(view, iter); //no overlap on the circle, even if context is set to LineCap.Square cntx.LineCap = Cairo.LineCap.Butt; cntx.MoveTo(x, y); cntx.Arc(x, y, 0.5, 0, 2 * Math.PI); cntx.Stroke(); cntx.Restore(); }