Requires: Direct2D.lg32
Starts and ends a figure and closes the sink object.
D2Sink_BeginFigure geoSink, x1!, y1! [,figureBegin%]
D2Sink_EndFigure geoSink [,figureEnd%]
D2Sink_Close geoSink
geoSink | : Object created with D2GeometrySink() |
x1!, y! | : Single exp |
figureBegin%, figureEnd% | : Int exp |
D2Sink_BeginFigure starts the definition of a new figure. After creating a sink object for a geometry using D2PathGeometry() and D2GeometrySink() a program starts populating the geometry with figures by calling D2Sink_* commands. To start a figure call the D2Sink_BeginFigure command, passing in the figure's starting point x1!, y1!, and optionally a value to indicate a hollow (D2D1_FIGURE_BEGIN_HOLLOW = 1) or - the default - a filled figure ( D2D1_FIGURE_BEGIN_FILLED = 0). The figureBegin setting determines the fill behavior for D2FillGeometry; if D2Sink_BeginFigure sets the figure to hollow D2FillGeometry won't fill the figure.
After executing D2Sink_BeginFigure use the D2Sink_Add* commands (such as D2Sink_AddLines and D2Sink_AddBezier) to add segments.
D2Sink_EndFigure ends the definition of a figure started with D2Sink_BeginFigure. When you are finished adding segments to a figure, call the D2Sink_EndFigure command specifying the sink and optionally a value that indicates how to end the figure. Set the optional parameter figureEnd% to D2D1_FIGURE_END_CLOSED = 1 to close the figure by connecting last and first point, by default the figureEnd% argument defaults to D2D1_FIGURE_END_OPEN = 0 so that the figure isn't closed .
You can repeat this sequence to create additional figures. When you are finished creating figures, call the D2Sink_Close command to close the sink, after which the sink can't be used any longer.
'
' D2Sink_BeginFigure/D2Sink_EndFigure/D2Sink_Close sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT, geo
OpenW 1, 0, 0, 420, 360, ~15
Set Win1RT = D2GetRT() ' DC render target
' Create a pathgeometry for an hourglass shape
DefHourGlassGeo() ' sets geo Object
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_Wheat
D2Transform D2TF_MOVE, 100, 10' move it to 100,10
D2DefLine , 3 ' 3 dpi wide
D2DefFill D2C_AliceBlue ' fill color
D2FillGeometry geo
D2DrawGeometry geo ' outline
D2EndDraw
EndSub
Sub Win_1_ReSize
D2ResizeRT Win1RT, _X, _Y
EndSub
Procedure DefHourGlassGeo()
Local Object geoSink ' released when it goes out-of-scope
Local pt As D2D1_POINT_2F
Local bz As D2D1_BEZIER_SEGMENT
Set geo = D2PathGeometry() ' global, remeains in memory
Set geoSink = D2GeometrySink(geo)
D2Sink_BeginFigure geoSink, 0, 0, D2D1_FIGURE_BEGIN_FILLED ' first point, D2FillGeometry will fill
' Add line
pt.x = 200, pt.y = 0
D2Sink_AddLine geoSink, pt
' Add bezier
bz.point1.x = 150, bz.point1.y = 50
bz.point2.x = 150, bz.point2.y = 150
bz.point3.x = 200, bz.point3.y = 200
D2Sink_AddBezier geoSink, bz
' Add line
pt.x = 0, pt.y = 200
D2Sink_AddLine geoSink, pt
' Add bezier
bz.point1.x = 50, bz.point1.y = 150
bz.point2.x = 50, bz.point2.y = 50
bz.point3.x = 0, bz.point3.y = 0
D2Sink_AddBezier geoSink, bz
D2Sink_EndFigure geoSink, D2D1_FIGURE_END_CLOSED
D2Sink_Close geoSink
EndProc
An example of creating multiple figures is demonstrated in the D2Sink_AddBezier topic.
SDK info for these commands:
ID2D1SimplifiedGeometrySink::BeginFigure (d2d1.h) - Win32 apps | Microsoft Docs ;
ID2D1SimplifiedGeometrySink::EndFigure (d2d1.h) - Win32 apps | Microsoft Docs;
ID2D1SimplifiedGeometrySink::Close (d2d1.h) - Win32 apps | Microsoft Docs.
D2DrawGeometry, D2FillGeometry, D2Sink_Fillmode, D2Sink_AddLines, D2Sink_AddArc, D2Sink_AddBezier, D2Sink_AddQuadraticBezier.
{Created by Sjouke Hamstra; Last updated: 17/03/2021 by James Gaite}