Delphi GDI + learning Record (25): Transform

Source: Internet
Author: User

Proportional change

var
 g: TGPGraphics;
 p: TGPPen;
 rect: TGPRect;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(MakeColor(255,255,0,0),0);
 rect := MakeRect(10,10,100,100);
 g.DrawRectangle(p, rect); {原始}
 g.ScaleTransform(2, 0.5); {横向放大、纵向缩小}
 p.SetColor(aclBlue);   {变个颜色看清楚}
 g.DrawRectangle(p, rect); {重绘}
 g.ResetTransform;     {恢复变化, 不然下一个变化将基于现在的状态}
 p.Free;
 g.Free;
end;

Angle Change (rotation)

var
 g: TGPGraphics;
 p: TGPPen;
 rect: TGPRect;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(MakeColor(255,255,0,0),0);
 rect := MakeRect(10,10,100,100);
 g.DrawRectangle(p, rect);
 g.RotateTransform(28); {旋转28度角, 正值顺时针、负值逆时针}
 p.SetColor(aclBlue);
 g.DrawRectangle(p, rect);
 g.ResetTransform;
 p.Free;
 g.Free;
end;

Position change (move)

var
 g: TGPGraphics;
 p: TGPPen;
 rect: TGPRect;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(MakeColor(255,255,0,0),0);
 rect := MakeRect(10,10,100,100);
 g.DrawRectangle(p, rect);
 g.TranslateTransform(111,111); {移动}
 p.SetColor(aclBlue);
 g.DrawRectangle(p, rect);
 g.ResetTransform;
 p.Free;
 g.Free;
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.