D2Sink_AddArc Command

Requires: Direct2D.lg32

Purpose

Creates a single arc and adds it to the path geometry.

Syntax

D2Sink_AddArc geoSink, arcseg

geoSink: Object created with D2GeometrySink()
arcseg: D2D1_ARC_SEGMENT

Description

D2Sink_AddArc Creates a single arc described by D2D1_ARC_SEGMENT and adds it to the specified geometry sink. The D2D1_ARC_SEGMENT is defined as:

Type D2D1_ARC_SEGMENT

- D2D1_POINT_2F point       // The end point of the arc.

- D2D1_SIZE_F size          // The x-radius and y-radius of the arc.

- Float rotationAngle       // degrees in the clockwise direction

- Long sweepDirection       // sweep is clockwise or counterclockwise.

- Long arcSize              // specifies if the arc is larger than 180 degrees.

EndType

The example shows how to draw an arc based on the center of a circle or ellipse with a given radius and corners (in degrees). The example demonstrates how D2PCircle and D2PEllipse are implemented.

Example

'

' D2Sink_AddArc sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT, geoArc

OpenW 1, 0, 0, 320, 260, ~15

Set Win1RT = D2GetRT()   ' DC render target

' Define a global arc geometry, center(100,100),

' radius 50/50, from 90 deg to 180 deg.

Set geoArc DefArcGeo(100, 100, 50, 50, 90, 180)

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_Wheat

D2DrawGeometry geoArc

D2EndDraw

EndSub

 

Sub Win_1_ReSize

D2ResizeRT Win1RT, _X, _Y

EndSub

 

Function DefArcGeo(x!, y!, rx!, ry!, w1%, Optional w2%) As Object

Local geo As Object, geoSink As Object

Local arcSeg As D2D1_ARC_SEGMENT

Local Float xs, ys, xe, ye

// start coordinates

xs = x + (CosQ(w1) * rx), ys = y - (SinQ(w1) * ry)

// end coordinates

xe = x + (CosQ(w2) * rx), ye = y - (SinQ(w2) * ry)

arcSeg.point.x = xe

arcSeg.point.y = ye

arcSeg.size.width = rx

arcSeg.size.height = ry

arcSeg.sweepDirection = 0         ' counter clockwise, draw from w1 to w2

If w1 > w2 Then w2 = w2 + 360

If w2 - w1 > 180 Then arcSeg.arcSize = 1

Set geo = D2PathGeometry()

Set geoSink = D2GeometrySink(geo)

D2Sink_BeginFigure geoSink, xs, ys

D2Sink_AddArc geoSink, arcSeg

D2Sink_EndFigure geoSink

D2Sink_Close geoSink

Set DefArcGeo = geo

EndFunc

Remarks

D2Sink_AddArc is a wrapper for ID2D1GeometrySink::AddArc (d2d1.h) - Win32 apps.

See Also

D2PathGeometry, D2GeometrySink, D2DrawGeometry, D2FillGeometry, D2Sink_BeginFigure, D2Sink_EndFigure, D2Sink_Close, D2Sink_Fillmode, D2Sink_AddBezier, D2Sink_AddLine.

{Created by Sjouke Hamstra; Last updated: 11/03/2021 by James Gaite}