Jump to content

how to Anti Alias


Recommended Posts

Here is a code

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
_Main()
Func _Main()
Local $hGUI, $hGraphic
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
GUISetState()
_Curvature($hGUI,160,100,20,20,100,180,0x702E2EFE)
_DrawLine($hGui,160,100+(20/2),160,120+40,0x702E2EFE)
_Curvature($hGUI,160,160-(20/2),20,20,-100,180,0x702E2EFE)
; Draw arcs
;_GDIPlus_GraphicsDrawArc($hGraphic, 180, 100, 10, 10, 180, 360)
;_GDIPlus_GraphicsDrawArc($hGraphic, 160, 104, 30, 30, 160, -140)
;_GDIPlus_GraphicsDrawArc($hGraphic, 140, 80, 70, 70, 180, 360)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources

EndFunc   ;==>_Main
Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel=0x80FFD700)
Local  $hGraphic, $hPen
; Draw line
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Gui)
$hPen = _GDIPlus_PenCreate ($sChannel)
If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error from GDI+:'&@error&@CRLF)
; Clean up resources
_GDIPlus_PenDispose ($hPen)
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_ShutDown ()
;Done.....
EndFunc   ;==>_Main
Func _Curvature($hGui, $iX, $iY, $iWidth, $iHeight, $fSweepAngle,$fStartAngle=180, $hPen = 0x80FFD700)
_GDIPlus_Startup()
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hPen=_GDIPlus_PenCreate($hPen)
_GDIPlus_GraphicsDrawArc($hGraphic, $iX, $iY, $iWidth, $iHeight, $fStartAngle, $fSweepAngle , $hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc

I want to anti alias the Curves

I have already seen _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $iSmooth)

But it doesnt seem to do anything

Please guide me in the right direction

Thnx for your Time ;)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Try this:

#include <guiconstantsex.au3>
#include <gdiplus.au3>
_GDIPlus_Startup()
Global $hGraphic, $hGUI
_Main()
Func _Main()
    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
    _Curvature($hGUI,160,100,20,20,100,180,0x702E2EFE)
    _DrawLine($hGui,160,100+(20/2),160,120+40,0x702E2EFE)
    _Curvature($hGUI,160,160-(20/2),20,20,-100,180,0x702E2EFE)
    ; Draw arcs
    ;_GDIPlus_GraphicsDrawArc($hGraphic, 180, 100, 10, 10, 180, 360)
    ;_GDIPlus_GraphicsDrawArc($hGraphic, 160, 104, 30, 30, 160, -140)
    ;_GDIPlus_GraphicsDrawArc($hGraphic, 140, 80, 70, 70, 180, 360)
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Clean up resources

    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_ShutDown ()
    Exit
EndFunc   ;==>_Main

Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel=0x80FFD700)
    Local $hPen = _GDIPlus_PenCreate ($sChannel)
    If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error from GDI+:'&@error&@CRLF)
    _GDIPlus_PenDispose ($hPen)
EndFunc

Func _Curvature($hGui, $iX, $iY, $iWidth, $iHeight, $fSweepAngle,$fStartAngle=180, $hPen = 0x80FFD700)
    $hPen=_GDIPlus_PenCreate($hPen)
    _GDIPlus_GraphicsDrawArc($hGraphic, $iX, $iY, $iWidth, $iHeight, $fStartAngle, $fSweepAngle , $hPen)
    _GDIPlus_PenDispose ($hPen)
EndFunc

Btw, you don't need to start/shutdown GDI+ in each function. Create a global graphic handle and use it in you functions.

Or use this:

;coded by UEZ 2012
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()
$iW = 640
$iH = 480
$hgui = GUICreate("GDI+ draw rectangle with round corners", $iW, $iH)
GUISetBkColor(0x000020, $hgui)
GUISetState()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
$p = 150

Draw_RoundRect($hGraphic, $p, $p, $iW - $p, $p, $iH - 2 * $p) ;draw rectangle with round corners

GUISetOnEvent(-3, "_Exit")

While Sleep(100000)
WEnd

Func Draw_RoundRect($hGfx, $iX1, $iY1, $iX2, $iY2, $iDist, $iArcSize = 40, $iColor = 0xFFFFFFFF, $iPenSize = 2) ;coded by UEZ 2012
    Local $hPen = _GDIPlus_PenCreate($iColor, $iPenSize)
    _GDIPlus_GraphicsDrawLine($hGfx, $iX1, $iY1, $iX2 + 1, $iY2, $hPen) ;upper horizontal line
    _GDIPlus_GraphicsDrawArc($hGfx, $iX1 - $iArcSize / 2, $iY1, $iArcSize + 1, $iArcSize + 1, -90, -90, $hPen) ;left upper corner
    _GDIPlus_GraphicsDrawArc($hGfx, $iX2 - $iArcSize / 2, $iY2, $iArcSize, $iArcSize, 0, -90, $hPen) ;right upper corner
    _GDIPlus_GraphicsDrawArc($hGfx, $iX1 - $iArcSize / 2, $iY2 + $iDist - $iArcSize, $iArcSize, $iArcSize, 180, -90, $hPen) ;left bottom corner
    _GDIPlus_GraphicsDrawArc($hGfx, $iX2 - $iArcSize / 2, $iY2 + $iDist - $iArcSize, $iArcSize, $iArcSize, -270, -90, $hPen) ;right bottom corner
    _GDIPlus_GraphicsDrawLine($hGfx, $iX1 - $iArcSize / 2, $iY1 + $iArcSize / 2 - 1, $iX1 - $iArcSize / 2, $iY1 + $iDist - $iArcSize / 2 + 1, $hPen) ;left vertical line
    _GDIPlus_GraphicsDrawLine($hGfx, $iX2 + $iArcSize / 2, $iY2 + $iArcSize / 2 - 1, $iX2 + $iArcSize / 2, $iY2 + $iDist - $iArcSize / 2 + 1, $hPen) ;right vertical line
    _GDIPlus_GraphicsDrawLine($hGfx, $iX1 - 1, $iY1 + $iDist, $iX2 + 1, $iY2 + $iDist, $hPen) ;lower horizontal line
    _GDIPlus_PenDispose($hPen)
EndFunc

Func _Exit()
    GUIDelete()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Br,

UEZ

Edited 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thnx UEZ it worked ;)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...