It can be done for an arc using this procedure:
Create a pie region with a radius that corresponds to what will become the
outer edge of the arc (the example below uses, X, Y, width, height, start
and end angles). Create a path gradient brush with the two colors you want
to use, and set the FS point half way between the inner and outer edges of
the arc. Adjust the centre point to the start of the path. Set the siga
bell shape to the style you want. For instance, an arced neon looks better
with this slightly offset from the half-way point. Create a pen from the
brush using the original rectangle. Draw the pen into the region of the
original rectangle.
Shorter is the size for drawing into, Centre is the central point for the
arcs. t2 is the starting angle and rot is the amount to rotate.
Dim P0 As Single = Shorter * Math.Abs(myOuterEdge)
Dim P1 As Single = Shorter * Math.Abs(myInnerEdge)
t0 = Center - Center * Math.Abs(myInnerEdge)
t1 = Center - Center * Math.Abs(myOuterEdge)
Dim PA As GraphicsPath = New GraphicsPath
PA.AddPie(t1, t1, P0, P0, t2, Rot)
Dim GradBrush As New PathGradientBrush(PA)
Dim colors() As Color
Dim FS As Single
Dim PointerAntiColor As Color = Color.FromArgb(myPointerColor.A,
(myPointerColor.R + 128) Mod 256, (myPointerColor.G + 128) Mod 256,
(myPointerColor.B + 128) Mod 256)
colors = New Color() {PointerAntiColor}
GradBrush.CenterPoint = PA.PathPoints(0)
GradBrush.CenterColor = PointerColor
FS = (myOuterEdge - myInnerEdge) / 2.0! + myInnerEdge
GradBrush.FocusScales = New PointF(FS, FS)
GradBrush.SurroundColors = colors
GradBrush.SetSigmaBellShape(4) 'THIS NEEDS EXPERIMENTING
Dim GPPen As Pen = New Pen(GradBrush, (t0 - t1) * 2)
GPPen.Alignment = PenAlignment.Center
G.DrawArc(GPPen, t1, t1, P0, P0, t2, Rot)
"kpg" <ipost@thereforeiam> wrote
Quote:
Hi all,
I've hacked my way through doing some pretty impressive (to me at least)
things with the .net drawing functions, but this one has me stumped.
I want to draw neon lines. Now I can draw a straight line with a gradient
to simulate a neon effect, but I'm having trouble with curves and
arbitrarily complex polygons.
To achieve a basic neon effect a gradient of dark-light-dark is used, with
the light color in the center and dark on the edges. I need to be able to
draw a line of s specified with this gradient following a path.
Any ides, sites, examples or other input is appreciated.
kpg
|