GraphicsTPenMode

From RAD Studio Code Examples
Jump to: navigation, search

Description

The effect of changing the pen mode can be observed in the following example:

  1. Create a new VCL Forms Application (Delphi or C++Builder).
  2. Define the OnPaint callback of the form with the code in the following section.

Code

Delphi

procedure TForm1.FormPaint(Sender: TObject);
begin
  Self.Color := clGray;  { Sets the form's background color }
  Self.Canvas.Pen.Color := clSkyBlue; { Sets the pen's color }
  Self.Canvas.Pen.Mode := pmCopy; { Sets the pen mode }
  Self.Canvas.MoveTo(0, 0);
  Self.Canvas.LineTo(100, 100);
end;

C++

void __fastcall TForm1::FormPaint(TObject *Sender) {
  this->Color = clGray; // Sets the form's background color
  this->Canvas->Pen->Color = clSkyBlue; // Sets the pen's color
  this->Canvas->Pen->Mode = pmCopy; // Sets the pen mode
  this->Canvas->MoveTo(0, 0);
  this->Canvas->LineTo(100, 100);
}

Result

The following images represent the various effects obtained by changing the pen mode (not the pen color). The original images are scaled by a factor of 6.

Uses