I would like to use the AddLine
method of the interface ID2D1GeometrySink
repeatedly, but defining the color of each segment at each consecutive inclusion. I imagine that 'closing' the action of adding line segments and opening it again just to change the color of a line segment would make the process slow. Is there a way to perform this operation quickly and efficiently?
Geometry does not have such attributes as color or style. Those are provided when you draw or fill it, with DrawGeometry/FillGeometry. So no, it's not possible to set color for the geometry segments at all.
If you need to switch styles or colors you'll need to have multiple geometries, and several draw/fill calls. It's possible to pack those in a single command list.