vb.net画渐变色 vb按钮变色代码
VB.NET怎么在屏幕上画一个逐渐变大的空心圈?
在窗体上拉一个Timer控件,enabled设为true,Interval设为20。完整代码如下: Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
创新互联建站专注于企业成都营销网站建设、网站重做改版、芮城网站定制设计、自适应品牌网站建设、H5网站设计、购物商城网站建设、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为芮城等各大城市提供网站开发制作服务。
Dim formGraphics As System.Drawing.Graphics
Dim num As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Refresh() '清屏
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(100, 100, num, num)) '在坐标(100,100)的位置画圆
If num 200 Then '如果大于200则停止画圆
myPen.Dispose()
formGraphics.Dispose()
Timer1.Enabled = False
Else
num = num + 1
End If
End Sub
C#或VB.NET中,如何用timer控件给Label.BackColor来回变色闪动?
首先,设定Timer控件的Enabled属性为True,Interval属性为1000(单位为毫秒)。
然后,添加程序代码如下:
private void timer1_Tick(object sender, EventArgs e)
{
if (this.label1.BackColor == Color.Red) //判断当前背景色是否为红色
this.label1.BackColor = Color.Blue; //如果是则变为蓝色
else //如果当前背景色不是红色
this.label1.BackColor = Color.Red; //将背景色变为红色
}
vb.net 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?
也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
窗体上放个图片框试试下面代码:
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.net画渐变色 vb按钮变色代码
转载来于:http://hbruida.cn/article/dopdcis.html