I've been trying to modify the StrokeStyle
for the TDirect2DCanvas.Pen
in C++Builder.
The documentation says this about the property:
Determines the stroke style in which the pen draws lines.
Use StrokeStyle to specify a more complex style in which the lines are drawn. StrokeStyle accepts an interface that provides a set of methods, each returning a certain drawing option.
The documentation gives no examples. When I try to set this property to anything, I get a compile error saying "cannot write a property that has no write specifiers" (it looks like this property is only set up to read the StrokeStyle; even though the documentation seems to indicate otherwise).
My desire here is to get lines to be rendered with rounded ends rather than the flat ends that it seems to default to when using TDirect2DCanvas
. Does anybody know how to accomplish this?
I'm using C++Builder 10.2 and the clang compiler. I'm trying to use TDirect2DCanvas
rather than the regular TCanvas
because it can draw anti-aliased lines.
The documentation is misleading. The TDirect2DPen::StrokeStyle
property is indeed read-only, as it represents the current Direct2D ID2D1StrokeStyle
object, as created internally by TDirect2DPen
. TDirect2DPen
does not provide any way to customize any of the stroke settings other than its dashStyle
.
The only way to affect the TDirect2DPen::StrokeStyle
is to set the TDirect2DPen::Style
property. Setting the Style
will release the current ID2D1StrokeStyle
, and then if the Style
is set to a value other than psSolid
, psClear
, or psInsideFrame
then TDirect2DPen
will call ID2D1Factory::CreateStrokeStyle()
to create a new ID2D1StrokeStyle
, specifying the following properties for it:
TDirect2DPen.Style
:
This behavior is hard-coded and cannot be changed.
So, if you want more control over the StrokeStyle
, you cannot use TDirect2DCanvas
at all. You will have to use the Direct2D API directly instead.