GDI+ 学习记录(25): 变换 - Transform

//比例变化
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); 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;
//位置变化(移动) 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;

你可能感兴趣的:(transform)