Abgerundetes Rechteck (GDI+ Form)

  • Hi!
    ich sitze seit kurzem hier an meiner kleinen (vllt hilfreichen!) UDF dran,
    diese erstellt eine Form eines Abgerundetes Rechteck's

    UDF selbst
    [autoit]

    Func _GDIPlus_GraphicsDraw_AbgerundetesRechteck($hGraphics,$iX, $iY, $iWidth, $iHeight,$Pen=0)
    If ($iX + $iY) - ($iHeight+$iWidth) < 40 Then
    $iHeight += 10
    $iWidth += 10
    EndIf
    _GDIPlus_GraphicsDrawArc($hGraphics,$iX,$iY,30,30,180,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iHeight,$iWidth,30,30,360,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iX,$iWidth,30,30,90,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iHeight,$iY,30,30,270,90,$Pen) ;25

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics,$iX + 15,$iY,$iHeight+15,$iY,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iHeight+30,$iX+15,$iHeight+30,$iWidth+15,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iX+15,$iWidth+30,$iHeight+15,$iWidth+30,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iX,$iY+15,$iX,$iWidth+15,$Pen)
    EndFunc

    [/autoit]

    hier als beispiel:

    Beispiel
    [autoit]

    ;~ $X,$Y,$W,$H
    $X = InputBox("X","X-Koordinate")
    $Y = InputBox("X","Y-Koordinate")
    $W = InputBox("X","Breite")
    $H = InputBox("X","Höhe")

    [/autoit] [autoit][/autoit] [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Mein Projekt in GDI+ : AbgerundetesRechteck", 800, 500, 192, 124)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    _GDIPlus_GraphicsDraw_AbgerundetesRechteck($hGraphics,$X,$Y,$W,$H)
    GUIRegisterMsg(0x000F,"_ReDraw")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _ReDraw()
    _GDIPlus_GraphicsClear($hGraphics,0xF4F4F4)
    _GDIPlus_GraphicsDraw_AbgerundetesRechteck($hGraphics,$X,$Y,$W,$H)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_GraphicsDraw_AbgerundetesRechteck($hGraphics,$iX, $iY, $iWidth, $iHeight,$Pen=0)
    If ($iX + $iY) - ($iHeight+$iWidth) < 40 Then
    $iHeight += 10
    $iWidth += 10
    EndIf
    _GDIPlus_GraphicsDrawArc($hGraphics,$iX,$iY,30,30,180,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iHeight,$iWidth,30,30,360,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iX,$iWidth,30,30,90,90,$Pen) ;25
    _GDIPlus_GraphicsDrawArc($hGraphics,$iHeight,$iY,30,30,270,90,$Pen) ;25

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics,$iX + 15,$iY,$iHeight+15,$iY,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iHeight+30,$iX+15,$iHeight+30,$iWidth+15,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iX+15,$iWidth+30,$iHeight+15,$iWidth+30,$Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics,$iX,$iY+15,$iX,$iWidth+15,$Pen)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]


    es sind noch ein paar (viele) bugs drin!ich hoffe meine berechnungen der linien etc stimmen so!
    :party: :party: :party: :party: :party:

    2 Mal editiert, zuletzt von Alizame (30. Mai 2010 um 09:53)

  • Wenn ich zum Beispiel das eingebe:
    X-Koord. = 50
    Y-Koord. = 100
    Breite = 50
    Höhe = 100

    Kommt das dabei raus: autoit.de/wcf/attachment/9967/

    Soll das so sein ?(

  • eigentlich nicht X(
    eben hat es noch gegangen!
    AH:
    es geht nur wenn X und Y gleich sind! (glaube ich......)
    ich werde das warscheinlich morgen fixen, denn jetzt habe ich kein bock das zu tun!


    ok wieder da,....

    2 Mal editiert, zuletzt von Alizame (29. Mai 2010 um 21:31)

  • Ersetz:

    [autoit]

    _GDIPlus_GraphicsDrawPie()

    [/autoit]

    Durch:

    [autoit]

    _GDIPlus_GraphicsDrawArc()

    [/autoit]

    Sind die selben Parameter. ;)

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • @black_scorpi:
    _GDIPlus_GraphicsDraw_AbgerundetesQuadrat
    enthält das wort "Quadrat", ein Quadrat ist aber sozusagen eine spezielle form einen rechtecks!bei einem quadrat sind alle seiten gleich lang!
    hierbei handelt es sich aber viel mehr um ein Rechteck (wenn ich den bug endlich gefunden habe der bei manchen zahlen auftaucht)!

    @H2112
    Danke den befehl habe ich gesucht aber nicht gefunden :D ich editiere es oben!

  • Hier mal kurz und bündig ;) :

    [autoit]

    Func _GDIPlus_GraphicsDrawRoundedRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius = 30, $Pen = "")
    _GDIPlus_GraphicsDrawArc($hGraphics, $iX, $iY, $iRadius, $iRadius, 180, 90, $Pen)
    _GDIPlus_GraphicsDrawArc($hGraphics, $iX + $iWidth - $iRadius, $iY, $iRadius, $iRadius, 270, 90, $Pen)
    _GDIPlus_GraphicsDrawArc($hGraphics, $iX, $iY + $iHeight - $iRadius, $iRadius, $iRadius, 90, 90, $Pen)
    _GDIPlus_GraphicsDrawArc($hGraphics, $iX + $iWidth - $iRadius, $iY + $iHeight - $iRadius, $iRadius, $iRadius, 360, 90, $Pen)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics, $iX + $iRadius / 2, $iY, $iX + $iWidth - $iRadius / 2, $iY, $Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX, $iY + $iRadius / 2, $iX, $iY + $iHeight - $iRadius / 2, $Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX + $iRadius / 2, $iY + $iHeight, $iX + $iWidth - $iRadius / 2, $iY + $iHeight, $Pen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX + $iWidth, $iY + $iRadius / 2, $iX + $iWidth, $iY + $iHeight - $iRadius / 2, $Pen)
    EndFunc

    [/autoit]

    Edit:
    Hier noch als Fill Funktion. ;)

    [autoit]

    Func _GDIPlus_GraphicsFillRoundedRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius = 30, $Brush = "")
    _GDIPlus_GraphicsFillPie($hGraphics, $iX, $iY, $iRadius, $iRadius, 180, 90, $Brush)
    _GDIPlus_GraphicsFillPie($hGraphics, $iX + $iWidth - $iRadius, $iY, $iRadius, $iRadius, 270, 90, $Brush)
    _GDIPlus_GraphicsFillPie($hGraphics, $iX, $iY + $iHeight - $iRadius, $iRadius, $iRadius, 90, 90, $Brush)
    _GDIPlus_GraphicsFillPie($hGraphics, $iX + $iWidth - $iRadius, $iY + $iHeight - $iRadius, $iRadius, $iRadius, 360, 90, $Brush)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + $iRadius / 2 - 1, $iWidth, $height - $iRadius + 1, $Brush)
    _GDIPlus_GraphicsFillRect($hGraphics, $iX + $iRadius / 2 - 1, $iY, $iWidth - $iRadius + 2, $height, $Brush)
    EndFunc

    [/autoit]
    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

    Einmal editiert, zuletzt von H2112 (30. Mai 2010 um 12:58)

  • @H2112
    Das FillRoundedRect macht bei transparenten Brushs Muster daraus, deswegen hier das ohne Muster und ohne weiße Linien usw (geht nicht ohne Paths)

    [autoit]


    Func _GDIPlus_GraphicsFillRoundRect($gra,$x,$y,$w,$h,$r=30,$brush=0)
    ;Author: TheShadowAE
    Local $path=_GDIPlus_PathCreate(1)
    _GDIPlus_PathAddPie($path,$x,$y,$r,$r,180,90)
    _GDIPlus_PathAddPie($path,$x+$w-$r,$y,$r,$r,270,90)
    _GDIPlus_PathAddPie($path,$x+$w-$r,$y+$h-$r,$r,$r,0,90)
    _GDIPlus_PathAddPie($path,$x,$y+$h-$r,$r,$r,90,90)
    _GDIPlus_PathAddRectangle($path,$x,$y+$r/2,$w,$h-$r)
    _GDIPlus_PathAddRectangle($path,$x+$r/2,$y,$w-$r,$h)
    _GDIPlus_PathCloseFigure($path)
    _GDIPlus_GraphicsFillPath($gra,$path,$brush)
    _GDIPlus_PathDispose($path)
    EndFunc

    [/autoit]

    Die GDIP.au3, die ihr dafür braucht ist zum Beispiel da:
    https://autoit.de/index.php?page=Thread&amp;threadID=20658