我只是想在vb.net中的矩形之间画一些线。我使用了g.drawstring()
方法。
但是现在,基于一个值我只想改变箭头的不透明度。
答案 0 :(得分:2)
这是一个工作示例(尽管您关于使用g.DrawString()
绘制某些行的评论有点令人困惑)。您需要为箭头创建一个带有端盖的笔,并设置颜色的Alpha通道以获得 opaqueness :
Public Class Form1
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim r1 As New Rectangle(10, 10, 32, 16)
Dim p1 As New Point(Convert.ToInt32(r1.Left + (r1.Width / 2)), Convert.ToInt32(r1.Top + (r1.Height / 2)))
Dim r2 As New Rectangle(96, 18, 32, 16)
Dim p2 As New Point(Convert.ToInt32(r2.Left + (r2.Width / 2)), Convert.ToInt32(r2.Top + (r2.Height / 2)))
e.Graphics.FillRectangle(Brushes.Yellow, r1)
e.Graphics.DrawRectangle(Pens.Black, r1)
e.Graphics.FillRectangle(Brushes.Orange, r2)
e.Graphics.DrawRectangle(Pens.Black, r2)
Using alphaPen As New Pen(Color.FromArgb(120, Color.Black), 3)
alphaPen.EndCap = LineCap.ArrowAnchor
e.Graphics.DrawLine(alphaPen, p1, p2)
End Using
End Sub
End Class
此示例使用的是alpha值120.接近0会使其不可见,接近255会使其完全可见。
结果(放大显示透视):