//比例变化 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;
var g:TGPGraphics; p:TGPPen; rect:TGPRect; begin g:=TGPGraphics.Create(Canvas.Handle); g.Clear(aclWhite); p:=TGPPen.Create(aclRed); rect:=MakeRect(10,60,100,100); g.DrawRectangle(p,rect); g.RotateTransform(-28); //旋转,正值顺时针旋转,负值逆时针旋转 p.SetColor(aclBlue); g.DrawRectangle(p,rect); g.ResetTransform; p.Free; g.Free; end;
//位置变化(移动) var g:TGPGraphics; p:TGPPen; rect:TGPRect; begin g:=TGPGraphics.Create(Canvas.Handle); g.Clear(aclWhite); p:=TGPPen.Create(aclRed,2); rect:=MakeRect(10,10,100,100); g.DrawRectangle(p,rect); g.TranslateTransform(111,66); //移动 p.SetColor(aclBlue); g.DrawRectangle(p,rect); p.Free; g.Free; end;