using Cairo; ... using (var surface = new ImageSurface(Format.ARGB32, 200, 200)) using (var cr = new Context(surface)) { cr.MoveTo(10, 10); // set starting point cr.LineTo(190, 190); // draw a line to (190, 190) cr.LineWidth = 2; // set line width cr.Stroke(); // draw the line surface.WriteToPng("example.png"); // save the image }
using Cairo; ... using (var surface = new ImageSurface(Format.ARGB32, 200, 200)) using (var cr = new Context(surface)) { cr.MoveTo(100, 100); // set starting point cr.LineTo(100, 190); // draw a line straight down cr.LineTo(10, 190); // draw a line to the left cr.LineWidth = 2; // set line width cr.Stroke(); // draw the lines surface.WriteToPng("example.png"); // save the image }This code creates a 200x200 pixel image and draws a rectangle shape using three `LineTo` calls. In both examples, `Cairo.Context` is the main class used to draw graphics using Cairo. The `ImageSurface` class is used to create an image that can be drawn on, and `cr.MoveTo` sets the starting point for the line drawing. The `Stroke` method is used to actually draw the lines on the image. Overall, these examples show how to use Cairo LineTo to draw lines in C# using the Cairo graphics library.