Looking at the code, it is not readily obvious, but when I run the following test, I could see that the function can only support a radius up to 1/3 of the width, not 1/2 as we both first thought.
What I did in the script: visualize the clipping rects, to enable that, go in the code and uncomment up to 6 extra drawn rects. (#1..4 are boring, #5 and #6 are interesting). A bit confusing at first but I saw where the support for r>w/3 breaks down, because the circle is sticking out the wrong end of the clipping rect when r>h/3.
Code: Select all
#NoEnv
#SingleInstance, Force
OnExit, Bye
pToken := Gdip_Startup()
Gui, New, +hwndhGui +E0x80000
Gui, Show, NoActivate
hBM := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)
hDC := CreateCompatibleDC()
oBM := SelectObject(hDC, hBM)
pGraphics := Gdip_GraphicsFromHDC(hDC)
Gosub, Draw
UpdateLayeredWindow(hGui, hDC, 0, 0, A_ScreenWidth, A_ScreenHeight)
Return
GuiClose:
GuiEscape:
ExitApp
F5:: Reload
;-------------------------------------------------------------------------------
Bye:
;-------------------------------------------------------------------------------
Gdip_DeleteGraphics(pGraphics)
SelectObject(hDC, oBM)
DeleteObject(hBM)
DeleteDC(hDC)
Gdip_Shutdown(pToken)
ExitApp
;-------------------------------------------------------------------------------
Draw:
;-------------------------------------------------------------------------------
pBrush := Gdip_BrushCreateSolid(0x80008000)
Gdip_Fill_RoundedRectangle(pGraphics, pBrush, 200, 300, 100, 100, 40)
Gdip_DeleteBrush(pBrush)
Return
Gdip_Fill_RoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
{
Region := Gdip_GetClipRegion(pGraphics)
;~ Gdip_FillRectangle(pGraphics, pBrush, x-r, y-r, 2*r, 2*r)
;~ Gdip_FillRectangle(pGraphics, pBrush, x+w-r, y-r, 2*r, 2*r)
;~ Gdip_FillRectangle(pGraphics, pBrush, x-r, y+h-r, 2*r, 2*r)
;~ Gdip_FillRectangle(pGraphics, pBrush, x+w-r, y+h-r, 2*r, 2*r)
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
;~ Gdip_FillRectangle(pGraphics, pBrush, x+r, y-(2*r), w-(2*r), h+(4*r))
;~ Gdip_FillRectangle(pGraphics, pBrush, x-(2*r), y+r, w+(4*r), h-(2*r))
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
return E
}
Thanks for bringing this up.