Requires: Direct2D.lg32
D2Ellipse draws an ellipse in the render target's drawing area, while D2PEllipse draws a filled ellipse in the render target's drawing area.
D2Ellipse x!, y!, rx!, ry! [, w1%][, w2%][, Figure%] [,D2Brush]
D2PEllipse x!, y!, rx!, ry! [, w1%][, w2%][, Figure%] [,D2Brush]
x!, y!, rx!, ry! | : float expression |
w1%, w2%, Figure% | : integer expression |
D2Brush | : Object expression |
D2Ellipse draws the outline of an ellipse with position x,y and x-radius rx and y-radius ry in device-independent pixels. By default, the outline is drawn using a solid color brush created from the current foreground color D2ForeColor. If the application passes a D2Brush object, the stroke (line) is painted with that brush. Use D2DefLine to set the line style and width. By using the start (w1) and end (w2) angles, you can draw just an arc (default), a closed arc, or a pie, rather than the full ellipse - the angles w1 and w2 are given in whole degree steps with any arc being drawn in an anti-clockwise direction. Figure% can have the following values:
D2PEllipse draws a filled ellipse with position x,y and x-radius rx and y-radius ry in device-independent pixels. By default, the interior is painted using the brush set with D2DefFill. If the application specified a brush object with the D2PEllipse command, the interior is painted with that brush. The outline of the circle is painted using the current foreground color. To prevent the painting of the outline set line-width to zero using D2DefLine , 0. By using the start (w1) and end (w2) angles, you can draw just an arc (default) or a closed arc, rather than the full ellipse - the angles w1 and w2 are given in whole degree steps with any arc being drawn in an anti-clockwise direction. Figure% can have the following values:
'
' D2(P)Ellipse sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT
OpenW 1, 0, 0, 320, 260, ~15
' Rendertarget same size as clientarea
Set Win1RT = D2GetRT() 'Me.hWnd, _X, _Y)
' Here: Create Win_1 render target resources
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_White
D2ForeColor = D2C_Brown
D2Ellipse 100, 100, 50, 30
D2DefFill D2C_Beige
D2PEllipse 100, 100, 50, 30
D2EndDraw
EndSub
'
' D2EllipseArc sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT
OpenW 1, 0, 0, 320, 260, ~15
Set Win1RT = D2GetRT() ' DC render target
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_Wheat
D2ForeColor = D2C_Brown
D2DefFill D2C_Aqua
D2Ellipse 50, 50, 40, 30 ' entire ellipse
D2Ellipse 150, 50, 40, 30, 180, 45 ' arc in foreground color
D2Ellipse 50, 150, 40, 30, -45, 180 ' dito
D2EndDraw
EndSub
Sub Win_1_ReSize
D2ResizeRT Win1RT, _X, _Y
EndSub
'
' D2EllipseArc sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT
OpenW 1, 0, 0, 320, 260, ~15
Set Win1RT = D2GetRT() ' DC render target
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_Wheat
D2ForeColor = D2C_Brown
D2DefFill D2C_Aqua
D2PEllipse 50, 50, 40, 30
D2PEllipse 150, 50, 40, 30, 180, 45
D2PEllipse 50, 150, 40, 30, -45, 180
D2EndDraw
EndSub
Sub Win_1_ReSize
D2ResizeRT Win1RT, _X, _Y
EndSub
Requires an active render target, either set with D2BeginDraw or D2SetRT.
All drawing commands must be placed between D2BeginDraw and D2EndDraw.
D2Ellipse invokes the ID2D1RenderTarget::DrawEllipse method and D2PEllipse invokes the ID2D1RenderTarget::FillEllipse method.
The arc and pie figures are implemented using a temporary path geometry. More info can be found in the D2Sink_AddArc topic.
D2PBox, D2Box, D2PRBox, D2RBox, D2Line, D2Circle, D2PCircle, D2SetRT, D2DefFill, D2DefLine, D2Brush, D2BeginDraw, D2EndDraw, D2Sink_AddArc.
{Created by Sjouke Hamstra; Last updated: 15/03/2021 by James Gaite}