Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.87 KB | None | 0 0
  1. #include <GDIPlus.au3>
  2. #include <GUIConstantsEx.au3>
  3.  
  4. Example()
  5.  
  6. Func Example()
  7.     Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds
  8.  
  9.     ; Create GUI
  10.     $iW = 640
  11.     $iH = 220
  12.     $hGUI = GUICreate("GDI+", $iW, $iH)
  13.     GUISetState(@SW_SHOW)
  14.  
  15.     ; Draw a string using path
  16.     _GDIPlus_Startup()
  17.     $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
  18.     _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
  19.     _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
  20.  
  21.     $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
  22.     $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)
  23.  
  24.     $hPath = _GDIPlus_PathCreate() ;Create new path object
  25.  
  26.     $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
  27.     $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
  28.     _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ;Add the outline of the string to the path
  29.  
  30.     ; Tranform Path to fit to window
  31.     $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
  32.     $hMatrix = _GDIPlus_MatrixCreate()
  33.     _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ;Translate Matrix to the offset of the bounding rectangle
  34.     _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix
  35.     _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path
  36.  
  37.     _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
  38.     _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)
  39.  
  40.     ; Tranform Path to center the path
  41.     _GDIPlus_PathReset($hPath) ;Reset Path (delete previous string)
  42.     _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ;Add the outline of the string to the path
  43.  
  44.     $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
  45.     _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;Reset Matrix
  46.     _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] + ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
  47. ; >>> HIER <<<
  48.         _GDIPlus_MatrixScale($hMatrix, -1, 1) ; Spiegelt die Matrix
  49. ; >>> HIER <<<
  50.     _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate (offset) Path
  51.  
  52.     _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
  53.     _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
  54.     _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
  55.     _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)
  56.  
  57.     ; Loop until the user exits.
  58.     Do
  59.     Until GUIGetMsg() = $GUI_EVENT_CLOSE
  60.  
  61.     ; Clean up resources
  62.     _GDIPlus_MatrixDispose($hMatrix)
  63.     _GDIPlus_FontFamilyDispose($hFamily)
  64.     _GDIPlus_PathDispose($hPath)
  65.     _GDIPlus_PenDispose($hPen)
  66.     _GDIPlus_BrushDispose($hBrush)
  67.     _GDIPlus_GraphicsDispose($hGraphic)
  68.     _GDIPlus_Shutdown()
  69. EndFunc   ;==>Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement