Matrix Transformations (matrices) are powerful, and this is just a spin.
This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Comctrls;
Type
TForm1 = Class (Tform)
Trackbar1:ttrackbar;
Procedure Formpaint (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Trackbar1.min: =-45;
Trackbar1.max: = 45;
DoubleBuffered: = True;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
B:tgpbrush;
Rgn:tgpregion;
Matrix:tgpmatrix;
Begin
G: = Tgpgraphics.create (Canvas.handle);
B: = Tgphatchbrush.create (Hatchstylemin, Aclsilver, aclchocolate);
Rgn: = Tgpregion.create (Makerect, ClientWidth-80, ClientHeight-100));
Matrix: = tgpmatrix.create;
Matrix.rotate (trackbar1.position);
Rgn. Transform (Matrix);
G.fillregion (b, RGN);
Matrix.free;
Rgn. Free;
B.free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
End.
Form file:object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 174
ClientWidth = 197
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnCreate = FormCreate
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
object TrackBar1: TTrackBar
Left = 0
Top = 151
Width = 193
Height = 23
ShowSelRange = False
TabOrder = 0
OnChange = TrackBar1Change
end
end