Draw multiple lines with color gradient

  • Thread starter Thread starter dw80916
  • Start date Start date
D

dw80916

Guest
I'm needing to draw multiple lines, each one a set of data, and each successive line incrementing through a color gradient.

Red remains fixed at 255. Blue remains fixed at 0. Green increments from 0 to 255. Green appears to increment properly, but the result is all lines draw Red. I'm not getting the expected gradient. Any assistance is appreciated.

' A gradient from Red to Yellow only needs to modify GREEN from 0 to 255.
' Find the gradient increment
Dim GradInc As Single = TraceList(0).P1dB_Count / 255

' Loop through X_Index, Y Data
For DataSet = 0 To TraceList(0).P1dB_Count - 1

Dim G As New Pen(Color.FromArgb(255, CInt(DataSet * GradInc), 0))

For y As Integer = 0 To DataPoints - 2

' Calculate X-Y values

X1 = y * (921 / (DataPoints - 1))
Y1 = 531 - ((TraceList(0).Y_PwrOut(DataSet, y) * TraceList(0).ScaleY) + Offset)

X2 = (y + 1) * (921 / (DataPoints - 1))
Y2 = 531 - ((TraceList(0).Y_PwrOut(DataSet, y + 1) * TraceList(0).ScaleY) + Offset)

PNADisplayGfx.DrawLine(G, X1, Y1, X2, Y2)

Next

G.Dispose()

Next
1505777.png

Continue reading...
 
Back
Top