十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
创新互联公司专业为企业提供克什克腾网站建设、克什克腾做网站、克什克腾网站设计、克什克腾网站制作等企业网站建设、网页设计与制作、克什克腾企业网站模板建站服务,10多年克什克腾做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
窗体上放个图片框试试下面代码:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim startColor As Color = Color.Red
Dim endColor As Color = Color.Green
Dim s As String = "vb点虐 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?"
Dim Steps As Integer = s.Length \ 2
Dim StepR As Integer = (CInt(endColor.R) - startColor.R) \ Steps
Dim StepG As Integer = (CInt(endColor.G) - startColor.G) \ Steps
Dim StepB As Integer = (CInt(endColor.B) - startColor.B) \ Steps
Dim R As Integer = startColor.R
Dim G As Integer = startColor.G
Dim B As Integer = startColor.B
Dim drawFont As New System.Drawing.Font("Arial", 16)
Dim X As Integer = 50
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R += StepR
G += StepG
B += StepB
Next
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i + Steps - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R -= StepR
G -= StepG
B -= StepB
Next
End Sub
在普通window应用程序中的背景是不能有ALPHA通道的
既然是点虐 ,试试用WPF窗体吧:
Listbox1.Background=New SolidBrush(Color.FromARGB(200,0,0,0))
当然你要是了解点虐 的笔刷类,绘制复杂的背景也不成问题
我是新手,仅谈谈我的理解,按钮的MouseEnter与MouseLeave事件就可以解决,需要这么复杂吗?
比如当鼠标移入按钮(Button1)时,按钮的字体变色(假如变为红色)可以写为(MouseEnter事件):
Button1.Forecolor=color.red;
当鼠标移出,字体颜色变回去(假如本来是黄色)(MouseLeave事件):
Button1.Forecolor=color.yellow;
如要做高级的动态变化,估计添加timer进来,写Timer的Tick事件,比如Tmier每Tick一次,按钮的红色就加5,同时设置按钮的Tick间距。