十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
用属性设置。
站在用户的角度思考问题,与客户深入沟通,找到株洲网站设计与株洲网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、成都网站制作、企业官网、英文网站、手机端网站、网站推广、空间域名、雅安服务器托管、企业邮箱。业务覆盖株洲地区。
VB设置窗体背景颜色为渐变色,支持水平、垂直、圆形渐变,代码将告诉你如何设置渐变线型、线宽等。
VB菜单作用是提供人机对话的界面,以便让使用者选择应用系统的各种功能,管理应用系统,控制各种功能模块的运行。
也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
窗体上放个图片框试试下面代码:
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.net 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?"
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
用VB编程实现窗体背景由上至下的颜色逐渐变浅
很多应用程序的安装界面都采用了标准的由蓝到黑渐变的背景,你可以用如下代码实现这种效果
Sub Dither(vForm As Form)
Dim intLoop As Integer
vForm.DrawStyle = vbInsideSolid
vForm.DrawMode = vbCopyPen
vForm.ScaleMode = vbPixels
vForm.DrawWidth = 2
vForm.ScaleHeight = 256
For intLoop = 0 To 255
vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(0, 0, 255 - intLoop), B
Next intLoop
End Sub
Private Sub Form_Activate()
Dither Me
End Sub
将窗体的AutoRedraw属性设为True.
如果想得到由红到黑的渐变,只需如下改动:
vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(255 - intLoop, 0, 0), B
以下是由绿到黑的渐变效果
vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(0,255 - intLoop, 0), B
Dim myrgb(10, 3) '假设有10个要变换的背景颜色
Dim ctime '用于timer控件的计数,假设每个颜色延续时间为10个timer1.Interval时间
Private Sub Form_Load()
'在此设置好各背景颜色的RGB值, 关于RGB颜色的设置最好用用读取文件的形式获取,不多说
myrgb(1, 1) = 20: myrgb(1, 2) = 0: myrgb(1, 3) = 100
myrgb(2, 1) = 40: myrgb(2, 2) = 50: myrgb(2, 3) = 200
myrgb(3, 1) = 20: myrgb(3, 2) = 150: myrgb(3, 3) = 100
myrgb(4, 1) = 20: myrgb(4, 2) = 50: myrgb(4, 3) = 150
myrgb(5, 1) = 25: myrgb(5, 2) = 50: myrgb(5, 3) = 100
myrgb(6, 1) = 20: myrgb(6, 2) = 50: myrgb(6, 3) = 100
myrgb(7, 1) = 20: myrgb(7, 2) = 110: myrgb(7, 3) = 150
myrgb(8, 1) = 20: myrgb(8, 2) = 50: myrgb(8, 3) = 100
myrgb(9, 1) = 20: myrgb(9, 2) = 50: myrgb(9, 3) = 100
myrgb(10, 1) = 20: myrgb(10, 2) = 50: myrgb(10, 3) = 100
End Sub
Private Sub Timer1_Timer()
ctime = ctime + 1
ctime = ctime Mod 100
rgb0 = Int(ctime / 10) + 1
rgb1 = (rgb0 + 1) Mod 10
r0 = myrgb(rgb0, 1): g0 = myrgb(rgb0, 2): b0 = myrgb(rgb0, 3)
r1 = myrgb(rgb1, 1): g1 = myrgb(rgb1, 2): b0 = myrgb(rgb1, 3)
cc = ctime Mod 10
r = r0 + (r1 - r0) / 10 * cc
g = g0 + (g1 - g0) / 10 * cc
b = b0 + (b1 - b0) / 10 * cc
Me.BackColor = RGB(r, g, b)
End Sub