Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3755

Color Gradient in a Listbox

$
0
0

After much tinkering I managed to get a gradient, but I would like it to go from left to right, from the color chosen as the background it should fade towards white… or at least a color more towards white. The code is this:

' RowTag of ROW
If row >= 0 And row < ListBoxEventi.LastRowIndex+1 Then
  
  Var tag As String = ListBoxEventi.RowTagAt(row)
  
  If tag <> "" Then
    Var colori() As String = tag.Split(",")
    
    Dim startColor As Color =Color.FromString(colori(0))
    Dim endColor As Color = color.white
    Dim p as New Picture(g.Width, g.Height)
    Dim samt, eamt As Double
    
    For i As Integer = 0 To p.Width
      samt = 1 - (i / p.width)
      eamt = i / p.width
      p.Graphics.ForeColor = RGB((startColor.Red * samt) + (endColor.Red * eamt), (startColor.Green *samt) + (endColor.Green * eamt), (startColor.Blue * samt) + (endColor.Blue * eamt))
      p.Graphics.DrawLine(i,-1,i, p.width+1)
    Next
    
    g.DrawPicture(p, 0, 0)
    
    
  End If
else
  g.DrawingColor= color.White  'WHITE
  g.FillRectangle(0, 0, g.Width, g.Height)
  
  
end if


I’m experimenting, a solution that I might like, in the meantime I’ll try things that I’ve never tried before :slight_smile:

I would like to smoke or understand how to go from the color chosen as the background color, to white to apply it to the individual boxes, thus having the first cell with the chosen color, the second with the chosen color minus something and so on, up to the last almost white box.

I hope I’ve managed to make myself clear.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3755

Trending Articles