TCanvas *canvas = Form1->Canvas; canvas->MoveTo(50,50); // move cursor to new position at (50,50)
TCanvas *canvas = Form1->Canvas; canvas->Pen->Color = clRed; // set color of pen to red canvas->Pen->Width = 2; // set width of pen to 2 pixels canvas->MoveTo(50,50); // move cursor to start position canvas->LineTo(100,50); // draw line to next position canvas->LineTo(100,100); // draw line to next position canvas->LineTo(50,100); // draw line to next position canvas->LineTo(50,50); // draw line to the start positionThis code example uses the MoveTo and LineTo functions to draw a red rectangle on a canvas with a pen width of 2 pixels.