Advertisement
WarPie90

Untitled

May 19th, 2023
1,525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.31 KB | None | 0 0
  1. procedure TMufasaBitmap.DrawText(txt:String; pt:TPoint; font:TFont;
  2.   color:Int32; align:Int32=0; shadow:Boolean=False; shadowDir:Byte=0); overload;
  3. var
  4.   bit:TBitmap;
  5.   muf:TMufasaBitmap;
  6.   W,H:Int32;
  7. begin
  8.   bit.Init();
  9.   bit.GetCanvas().SetFont(font);
  10.   bit.GetCanvas().GetBrush().SetStyle(bsClear);
  11.  
  12.   W := bit.GetCanvas().TextWidth(txt);
  13.   H := bit.GetCanvas().TextHeight(txt);
  14.   bit.SetWidth(W+1);
  15.   bit.SetHeight(H+1);
  16.  
  17.   if align then
  18.     pt := Point(pt.x-W, pt.y);
  19.  
  20.   muf := self.Copy(pt.x,pt.y,pt.x+W,pt.y+H);
  21.   muf.DrawToCanvas(0,0,bit.GetCanvas());
  22.  
  23.   if Shadow then
  24.   begin
  25.     bit.GetCanvas().GetFont().SetColor(1);
  26.     case ShadowDir of
  27.       0:bit.GetCanvas().TextOut(0,0,txt);
  28.       1:bit.GetCanvas().TextOut(1,0,txt);
  29.       2:bit.GetCanvas().TextOut(2,0,txt);
  30.       3:bit.GetCanvas().TextOut(2,1,txt);
  31.       4:bit.GetCanvas().TextOut(2,2,txt);
  32.       5:bit.GetCanvas().TextOut(1,2,txt);
  33.       6:bit.GetCanvas().TextOut(0,2,txt);
  34.       7:bit.GetCanvas().TextOut(0,1,txt);
  35.     end;
  36.     bit.GetCanvas().GetFont().SetColor(color);
  37.     bit.GetCanvas().TextOut(1,1,txt);
  38.   end else
  39.   begin
  40.     bit.GetCanvas().GetFont().SetColor(color);
  41.     bit.GetCanvas().TextOut(0,0,txt);
  42.   end;
  43.  
  44.   muf.LoadFromTBitmap(bit);
  45.   muf.DrawTransparent(pt.x,pt.y,self);
  46.  
  47.   muf.Free();
  48.   bit.Free();
  49. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement