如何设定色彩亮度 [英] How To Set Color Brightness

查看:77
本文介绍了如何设定色彩亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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:





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

推荐答案

您的代码不完整,发布所有代码浪费我们的时间.发布决定颜色的位.无论如何,如果要遍历某个范围,只需以相反的顺序遍历该范围即可获得相反的效果.
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.


这篇关于如何设定色彩亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆