画图--1

Public Sub drawDotAt35Minutes(ByVal onObj As PictureBox, ByVal e As Windows.Forms.PaintEventArgs)
        Const clockInset As Integer = 100         ' distance from clock edge to box edge 
        Const dotRadius As Integer = 15           ' size of the dot 
        Dim smallDim As Integer                   ' smaller of width and height of box 
        Dim clockRadius As Integer                ' radius of the clock 
        Dim centerX As Integer                    ' x for center of the clock 
        Dim centerY As Integer                    ' y for center of the clock 
        Dim x As Integer                          ' x position of dot 
        Dim y As Integer                          ' y position of dot
        Dim brush As New SolidBrush(Color.Blue)  'brush
        Dim brush1 As New SolidBrush(Color.Black)

        ' calculate the center of the clock and its radius so it fits in the box 
        centerX = onObj.Width / 2
        centerY = onObj.Height / 2
        smallDim = onObj.Width
        If (onObj.Height < smallDim) Then
            smallDim = onObj.Height
        End If
        clockRadius = smallDim / 2 - clockInset

        ' calculate the position of the dot 
        x = centerX  'clockX(35, clockRadius - dotRadius)
        y = centerY + 0 ' clockY(35, clockRadius - dotRadius)

        ' draw a filled black circle 
        e.Graphics.FillEllipse(brush1, x, y, dotRadius, dotRadius)

        e.Graphics.FillRectangle(brush, x, y + 20, dotRadius, dotRadius)
    End Sub

 用于在picturesBox 里面画图的方法~~

 Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        drawDotAt35Minutes(PictureBox1, e)
    End Sub

 用于在form加载时,加载方法 drawDotAt35 Minutes。

更多画图参考: http://www.host01.com/article/Net/00020005/056151545005180.htm

 

 

 

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 

 另外一种画图的方法。。

 

对于直线,参数的含义发生了变化~~

 

 

直线:第一个是代表画笔,后面依次是x1,y1(起点坐标),X2,Y2(终点坐标)

 

其他图形:x1,y1 决定了中心位置, X2,Y2 ,相当于radius

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值