using Cairo; using Gdk; public void DrawLine(Context cr) { cr.MoveTo(50, 50); // Current point set to (50, 50) cr.LineTo(100, 100); // Draw a line from (50, 50) to (100, 100) cr.LineTo(150, 50); // Draw a line from (100, 100) to (150, 50) cr.Stroke(); // Stroke the path to show the line }
using Cairo; using Gdk; public void DrawShapes(Context cr) { cr.MoveTo(50, 50); // Start the new path at (50, 50) cr.LineTo(100, 100); // Draw a line from (50, 50) to (100, 100) cr.MoveTo(150, 50); // Start a new path at (150, 50) cr.LineTo(100, 100); // Draw a line from (150, 50) to (100, 100) cr.Rectangle(50, 50, 100, 50); // Draw a rectangle with top-left corner (50, 50), width 100, height 50 cr.Stroke(); // Stroke the paths to show the shapes with lines }This example demonstrates how the MoveTo function can be used to create multiple paths and draw various shapes on a Cairo drawing surface, including lines and rectangles.