wakillon Posted April 20, 2016 Posted April 20, 2016 expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath, $aBounds ; Create GUI $hGUI = GUICreate("GDI+", 800, 300) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA) $hPen = _GDIPlus_PenCreate ( 0xFF8800AA, 1 ) $hPen2 = _GDIPlus_PenCreate ( 0xFFFF0000, 1 ) ;~ Local $aPoints = [[4,0],[0,0],[0,99],[99,99],[99,0]] ;~ Local $aPoints = [[4,0],[1,1],[1,2],[2,2],[2,1]] ;~ Local $aPoints = [[4,0],[100,100],[100,209],[209,209],[209,100]] Local $aPoints = [[4,0],[101,101],[101,200],[200,200],[200,101]] $hPath = _GDIPlus_PathCreate() ;Create new path object _GDIPlus_PathAddPolygon($hPath, $aPoints) $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ConsoleWrite ( '+ $aBounds[x] : ' & $aBounds[0] & ', $aBounds[y] : ' & $aBounds[1] & ', $aBounds[w] : ' & $aBounds[2] & ', $aBounds[h] : ' & $aBounds[3] & @Crlf ) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 2, $aPoints[$i][1] - 2, 4, 4, $hPen2) Next _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI) ;~ $hRegion = _GDIPlus_RegionCreateFromPath ( $hPath ) ;~ $aBounds = _GDIPlus_RegionGetBounds ( $hRegion, $hGraphic ) ;~ ConsoleWrite ( '+ $aBounds[x] : ' & $aBounds[0] & ', $aBounds[y] : ' & $aBounds[1] & ', $aBounds[w] : ' & $aBounds[2] & ', $aBounds[h] : ' & $aBounds[3] & @Crlf ) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example The width and height return by _GDIPlus_PathGetWorldBounds function seems to be false... Is it me or something is wrong ? AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
mikell Posted April 20, 2016 Posted April 20, 2016 $aPoints = [[4,0],[101,101],[101,200],[200,200],[200,101]] + $aBounds[x] : 101, $aBounds[y] : 101, $aBounds[w] : 99, $aBounds[h] : 99 101 + 99 = 200 ?
UEZ Posted April 20, 2016 Posted April 20, 2016 @wakillon: what do you expect as the result? Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wakillon Posted April 21, 2016 Author Posted April 21, 2016 mikell and UEZ Local $aPoints = [[4,0],[0,0],[0,99],[99,99],[99,0]] ; Result should be 100 instead of 99 Local $aPoints = [[4,0],[1,1],[1,2],[2,2],[2,1]] ; ; Result should be 2 instead of 1 Local $aPoints = [[4,0],[100,100],[100,209],[209,209],[209,100]] ; Result should be 110 instead of 109 Local $aPoints = [[4,0],[101,101],[101,200],[200,200],[200,101]] ; Result should be 100 instead of 99 I can understand it can look confuse, but coordinates are based 0, but not dimensions. AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
UEZ Posted April 21, 2016 Posted April 21, 2016 For Local $aPoints = [[4,0],[100,100],[100,100],[100,100],[100,100]] w = 0, h = 0 Local $aPoints = [[4,0],[100,100],[100,100],[100,100],[100,101]] w = 0, h = 1 Local $aPoints = [[4,0],[100,100],[101,100],[100,100],[100,101]] w = 1, h = 1 Width and height are just added to the coordinate which are zero based. Local $aPoints = [[4,0],[100,100],[100,100],[100,100],[200,101]] w = 100, h = 1 When w = 0 and h = 0 then nothing will be displayed. To display a something either w or h must be greater than 0. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wakillon Posted April 21, 2016 Author Posted April 21, 2016 Are you sure ? For example Local $aPoints = [[4,0],[1,1],[1,2],[2,2],[2,1]] is a square of 4 pixels (2x2 ) but result is 1 instead of 2 AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
UEZ Posted April 21, 2016 Posted April 21, 2016 (edited) No, the width and height is 1 and not 2 as you think. I know what you mean but internally it's not calculated that way. E.g. _GDIPlus_PathAddRectangle($hPath, 0, 0, 0, 0), _GDIPlus_PathAddRectangle($hPath, 0, 0, 0, 1), _GDIPlus_PathAddRectangle($hPath, 0, 0, 1, 0) result is always w = 0, h = 0 whereas _GDIPlus_PathAddRectangle($hPath, 0, 0, 1, 1) w = 1, h = 1 which are 4 pixels at 0,0. Edited April 21, 2016 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wakillon Posted April 21, 2016 Author Posted April 21, 2016 This is not logic ! When i zoom on the gui, i see well a width and a height of 2 What's the interest of this method of calcul ? AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
UEZ Posted April 21, 2016 Posted April 21, 2016 13 minutes ago, wakillon said: What's the interest of this method of calcul ? I don't know ¯\_(ツ)_/¯ - only MS knows... Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wakillon Posted April 21, 2016 Author Posted April 21, 2016 So, in conclusion, you assure that the function works well despite the false result ? It is incomprehensible ! AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
UEZ Posted April 21, 2016 Posted April 21, 2016 Well, I assume the logic how the width and height is calculated is different. Probably the coders smoked some shit before coding that stuff. You cannot set only one pixel using the draw functions. Width and height is always somehow added to the x,y position. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now