CustomEndCap Fill

XL Jedi

Active member
Joined
Apr 2, 2007
Messages
44
Location
Florida
Programming Experience
10+
I'm building a collection of CustomEndCaps to use with Pens to draw various lines and vectors in my application.

I have one CustomEndCap that I just call "Circle" and it looks like so:
VB.NET:
r = 3
path.AddEllipse(New Rectangle(-r, -r, r * 2, r * 2))
[SIZE=2]CustCap = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Drawing2D.CustomLineCap(path, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2])
[/SIZE]

When I use this endcap on the line the end of the line is the center of the circle and if I fill the circle, it fills in solid, as if a solid circle shape is drawn over the end of the line. This is what I want.

I have another CustomEndCap called "Triangle" and it looks something like this:
VB.NET:
ReDim Points(0 To 2)
Points(0) = New PointF(0, 0)
Points(1) = New PointF(3, -5)
Points(2) = New PointF(-3, -5)
path.AddPolygon(Points)
[SIZE=2]CustCap = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Drawing2D.CustomLineCap(path, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2])
[/SIZE]

In this case the point of the triangle starts at the end of the line. If I try to fill this one, for some reason, it doesn't fill in solid like the circle. The underlying line that runs through the center of the triangle is treated like an XOR fill. What do I have to do to get the polygon shape to fill in solid just like the ellipse?
 
I managed to solve this one on my own...

In the event that someone else might happen across this thread, the solution was to simply adjust the "BaseInset" property of the CustomLineCap class so the line stops where my custom line cap begins.

So at the end of my CustCap function (returns over 20 different custom line caps) I include the following...

VB.NET:
CustCap = New Drawing2D.CustomLineCap(Nothing, path)
With CustCap
.BaseInset = Offset dist between end of line and cap
.StrokeJoin = Drawing2D.LineJoin.Miter
End With

Where Offset is an appropriate pixel distance depending on which custom cap is drawn. Some of my caps are arrow style pointers in which case the offset is just the height of the shape, others use the radius or half the height of the shape.
 
Back
Top