Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
This small project helps to modify color brightness. This project is not yet commplete because there are little problem which i believe can be correcte by somebody.
On my process of developing this work, I ran into a problem.
The problem is that the darkest part of the color begins at the Top part of the Panel1 rather than the Bottom part. What i really want is for the Darkest part of the color to start from the Bottom of the Panel1 then to the Top.
In a more simple term, i want the opposite direction of the color i.e from Bottom to the Top of the Panel1.
Below are the code that I used for the project:


VB
Private g As Graphics
   Private colorB As Color = Color.Red
   Public Sub DrawRect()
       g = Me.Panel1.CreateGraphics
       Dim rainbow() As Color = {Color.Black, colorB}
       Dim n As Integer = 0
       Dim br As SolidBrush
       For Each c As Color In rainbow
           Dim bs As Double
           For bs = 0 To 1 Step 0.025
               br = New SolidBrush(RGBHSL.SetBrightness(c, bs))
               g.FillRectangle(br, New Rectangle(CSng(0), CSng(Me.Panel1.Height * bs), CSng(Me.Panel1.Width), _
               CSng(Me.Panel1.Height * n)))

               br.Dispose()
           Next bs
           n += 1
       Next c

       g.Dispose()

   End Sub

   Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
       DrawRect()
   End Sub
Posted
Updated 18-Jul-12 13:05pm
v2
Comments
lewax00 18-Jul-12 17:37pm    
Where's the rest of your code? You cut off mid-line...

1 solution

Your code is not complete, and posting all your code is a waste of our time. Post the bit that decides the color. Anyhow, if you're iterating through a range, just iterate over it in reverse order in order to get the opposite effect.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900