본문 바로가기
Application/Delphi Lecture

How do I flip text

by 현이빈이 2008. 8. 13.
반응형
procedure TForm29.PaintBox1Paint(Sender: TObject);
var
  graphics : TGPGraphics;
  FontFamily: TGPFontFamily;
  Font: TGPFont;
  SolidBrush: TGPSolidBrush;
  Matrix : TGPmatrix;
  SolidPen : TGPPen;
  r : TGPrectF;
  GraphicsPath : TGPGraphicsPath;
begin
  graphics   := TGPGraphics.Create(PaintBox1.Canvas.handle);
  FontFamily := TGPFontFamily.Create('Times New Roman');
  Font       := TGPFont.Create(FontFamily, 32, FontStyleRegular, UnitPixel);
  SolidBrush := TGPSolidBrush.Create(MakeColor(255, 0, 0, 255));
  SolidPen := TGPPen.Create(MakeColor(255, 0, 0, 255));

//  graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);

// so you can see the box
  graphics.drawRectangle(SolidPen, MakeRect(0,0,PaintBox1.Width-1, PaintBox1.height-1));

// the normal text offset to the right half of the paintbox
  graphics.TranslateTransform(PaintBox1.width div 2, 0);
  graphics.DrawString('AntiAlias', -1, font, MakePoint(0.0, 0.0), solidBrush);

  // x mirror
  matrix := TGPMatrix.Create(-1,0,0,1,PaintBox1.width div 2,0);
  graphics.settransform(matrix);
  graphics.DrawString('AntiAlias', -1, font, MakePoint(0.0, 0.0), solidBrush);
  matrix.free;

  // y mirror
  matrix := TGPMatrix.Create(1,0,0,-1,PaintBox1.width div 2,PaintBox1.height);
  graphics.settransform(matrix);
  graphics.DrawString('AntiAlias', -1, font, MakePoint(0.0, 0.0), solidBrush);
  matrix.free;

  // x and y mirror
  matrix := TGPMatrix.Create(-1,0,0,1,PaintBox1.width div 2,0);
  graphics.settransform(matrix);
  matrix.free;
  matrix := TGPMatrix.Create(1,0,0,-1,0,PaintBox1.height);
  graphics.multiplytransform(matrix);
  graphics.DrawString('AntiAlias', -1, font, MakePoint(0.0, 0.0), solidBrush);
  matrix.free;

  graphics.Free;
  FontFamily.Free;
  Font.Free;
  SolidBrush.Free;
end; 
반응형