static void DrawLineEndAtIter(Cairo.Context cntx, TextView view, TextIter iter) { Gdk.Rectangle rect = view.GetIterLocation(iter); int x, y; view.BufferToWindowCoords(TextWindowType.Text, rect.X, rect.Y + rect.Height / 2, out x, out y); cntx.Save(); cntx.Color = GetDrawingColorForIter(view, iter); double arrowSize = 3; cntx.MoveTo(x + 10, y); cntx.RelLineTo(new Cairo.Distance(0, -arrowSize)); cntx.RelMoveTo(new Cairo.Distance(0, arrowSize)); cntx.RelLineTo(new Cairo.Distance(-8, 0)); cntx.RelLineTo(new Cairo.Distance(arrowSize, arrowSize)); cntx.RelMoveTo(new Cairo.Distance(-arrowSize, -arrowSize)); cntx.RelLineTo(new Cairo.Distance(arrowSize, -arrowSize)); cntx.Stroke(); cntx.Restore(); }
public static void RenderCross(Cairo.Context context, Point scale, Point item, double msize, double lw) { context.MoveTo(item.X * scale.X, item.Y * scale.Y); context.RelMoveTo(-msize / 2, -msize / 2); context.RelLineTo(msize, msize); context.Stroke(); context.MoveTo(item.X * scale.X, item.Y * scale.Y); context.RelMoveTo(msize / 2, -msize / 2); context.RelLineTo(-msize, msize); context.Stroke(); }
public void DrawAxisBoundingBox(Cairo.Context cr, int x, int y, int width, int height, AxisLocation loc) { cr.MoveTo(x, y); if (loc == AxisLocation.Bottom) { cr.RelMoveTo(width, 0); } else { cr.RelLineTo(width, 0); } if (loc == AxisLocation.Left) { cr.RelMoveTo(0, height); } else { cr.RelLineTo(0, height); } if (loc == AxisLocation.Top) { cr.RelMoveTo(-width, 0); } else { cr.RelLineTo(-width, 0); } if (loc == AxisLocation.Right) { cr.RelMoveTo(0, -height); } else { cr.RelLineTo(0, -height); } //cr.Color = CairoHelper.GetCairoColor (gtk_style.Foreground (state)); cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Foreground(state)).R, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).G, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).B, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).A); cr.LineWidth = 2.0f; cr.Stroke(); }
private static void MakeSquare(Cairo.Context context, Point scale, Point item, double msize, double lw) { double size = msize - lw; context.MoveTo(item.X * scale.X, item.Y * scale.Y); context.RelMoveTo(-size / 2, -size / 2); context.RelLineTo(size, 0); context.RelLineTo(0, size); context.RelLineTo(-size, 0); context.ClosePath(); }
public static void SaveToPng(List <LibTessDotNet.ContourVertex> path) { if (path == null || path.Count <= 1) { return; } using (Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.Argb32, (int)Form.current.Size.Width, (int)Form.current.Size.Height)) using (Cairo.Context g = new Cairo.Context(surface)) { g.MoveTo(path[0].Position.X, path[0].Position.Y); for (int i = 1; i < path.Count; i++) { var x0 = path[i - 1].Position.X; var y0 = path[i - 1].Position.Y; var x1 = path[i].Position.X; var y1 = path[i].Position.Y; g.LineTo(x1, y1); { // draw index number g.RelMoveTo(5, 5); g.ShowText(i.ToString()); g.MoveTo(x1, y1); // draw arrow var dx = x1 - x0; var dy = y1 - y0; if (MathEx.AmostZero(dx) && MathEx.AmostZero(dy)) { continue; } var n0 = new Vector(-dy, dx); n0.Normalize(); var n1 = new Vector(dy, -dx); n1.Normalize(); var B = new Point(x1, y1); var d = new Vector(x0 - x1, y0 - y1); d.Normalize(); var arrowEnd0 = B + 5 * (d + n0); var arrowEnd1 = B + 5 * (d + n1); g.MoveTo(x1, y1); g.LineTo(new Cairo.PointD(arrowEnd0.X, arrowEnd0.Y)); g.MoveTo(x1, y1); g.LineTo(new Cairo.PointD(arrowEnd1.X, arrowEnd1.Y)); g.MoveTo(x1, y1); } } g.Stroke(); surface.WriteToPng(@"D:\contour_test.png"); } }
private static void DrawArrow(Cairo.Context graphics, double x, double y, double pos) { graphics.MoveTo(x, y); graphics.Rotate(pos); graphics.RelMoveTo(0, (pos + 0.5 * System.Math.PI < System.Math.PI ? -1 : 1) * s_arrowSize / 2); graphics.RelLineTo(-s_arrowSize, 0); graphics.RelLineTo(s_arrowSize, -s_arrowSize); graphics.RelLineTo(s_arrowSize, s_arrowSize); graphics.RelLineTo(-s_arrowSize, 0); graphics.Fill(); }
private static void MakeTriangle(Cairo.Context context, Point scale, Point item, double msize, double lw) { double halfsize = (msize - lw) / 2; context.MoveTo(item.X * scale.X, item.Y * scale.Y); context.RelMoveTo(0, halfsize); double dx = halfsize * s_triangleDxDy.X; double dy = halfsize * s_triangleDxDy.Y; context.RelLineTo(dx, -halfsize - dy); context.RelLineTo(2 * -dx, 0); context.ClosePath(); }
public override void RelMoveTo(object backend, double dx, double dy) { Cairo.Context ctx = ((CairoContextBackend)backend).Context; ctx.RelMoveTo(dx, dy); }
public void RelMoveTo(object backend, double dx, double dy) { Cairo.Context ctx = ((GtkContext)backend).Context; ctx.RelMoveTo(dx, dy); }