大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Dim b As New Bitmap(PictureBox1.Width, PictureBox1.Height)
创新互联服务项目包括留坝网站建设、留坝网站制作、留坝网页制作以及留坝网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,留坝网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到留坝省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
Dim p As New Pen(Color.Black)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
g.DrawLine(p, 30, PictureBox1.Height - 30, 30, 30)
g.DrawLine(p, 30, PictureBox1.Height - 30, PictureBox1.Width - 30, PictureBox1.Height - 30)
Dim i As Integer
Dim bs As New SolidBrush(Color.Green)
Dim po As New Point
po.X = 0
po.Y = PictureBox1.Height - 35
For i = 700 To 1000 Step 50
g.DrawString(i, Me.Font, bs, po.X, po.Y)
g.DrawLine(p, po.X + 28, po.Y + 5, po.X + 30, po.Y + 5)
po.Y -= (PictureBox1.Height - 100) / 6
Next
po.X = 30
po.Y = PictureBox1.Height - 30
For i = 0 To 40 Step 5
g.DrawString(i, Me.Font, bs, po.X, po.Y + 5)
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (PictureBox1.Width - 100) / 8
Next
PictureBox1.Image = b
也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
窗体上放个图片框试试下面代码:
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
不想整个重画,最好用单色的背景,例如黑色,线条是白色的
用变量把线条的内容备份
当想改变线条的位置或者长度之前,先用存下来的变量以黑色重画一次,覆盖原来的白色线条
然后再画新的白色线条,这种重画方法比较节省资源
假如需要用花哨的背景或者图片当背景,也可以用局部重回的方式。
代码就不提供了,只提供思路。
您好!!请看如下代码:
Private Sub Form_Click()
Dim Max As Integer
Max = 10000
For i = 1 To Max
Line (i, 0)-(i, Me.Height), RGB(i * (255 / Max), 0, 0)
Next i
End Sub
这段代码实现在窗体中画出一个由黑色到红色的渐变,范围是变量Max决定的10000(您定的100范围太小,渐变效果不明显,所以我改成了10000。),您可以改成其他的数值,您只需要稍加修改就能够使用了。望采纳!!
代码写起来可能比较麻烦,给你个思路,就是用GraphicsPath来绘制,然后通过绘制目标的鼠标移动事件来获取当前鼠标在绘制目标中的实际位置,再通过GraphicsPath的IsVisible()方法来确认鼠标是否包含在GraphicsPath中。
DrawLine直线比较容易处理,只要得到Line的坐标点,然后比较当前鼠标坐标就好。