精华内容
下载资源
问答
  • VB函数画图形

    2021-05-11 20:26:42
    VB函数画图形的源码示例,生成图形的VB绘图实例,设置Picture1控件使其中心点坐标为(0,0),Picture1.Cls清除其他图形,以下三行VB代码实现在Picture1中绘制黑色的水平坐标轴和垂直坐标轴。  Picture1.ForeColor = &...
  • VB6.0线段、圆形、填充图形画图实例,当鼠标按下时,对于选择不同的工具执行不同的操作,在标签中显示当前鼠标在画板中的位置,通过point方法拾取颜色,并设定为前景色,可线条、线段、设置画笔精细、圆形、...
  • vb画三维图形及等高线
  • vb 绘制图形/蝴蝶动画

    万次阅读 2019-05-22 19:24:15
    实验一 画图形 代码 Private Sub Form_Click() Scale (0, 30)-(120, 0) Circle (15, 15), 10 Circle (45, 15), 10, , , , 2 Circle (75, 15), 10, , -0.7, -2.1 Circle (105, 15), 10, , -2.1, 0.7 End...

    实验一 画图形

    在这里插入图片描述
    代码

    Private Sub Form_Click()
        Scale (0, 30)-(120, 0)
        Circle (15, 15), 10
        Circle (45, 15), 10, , , , 2
        Circle (75, 15), 10, , -0.7, -2.1
        Circle (105, 15), 10, , -2.1, 0.7
    End Sub
    

    实验二 画圆形

    在这里插入图片描述

    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        FillColor = QBColor(Int(Rnd * 15))
        FillStyle = Int(Rnd * 8)
        Circle (x, y), 500
    End Sub
    

    实验三 蝴蝶动画
    在这里插入图片描述

    Dim i As Integer
    Private Sub Command1_Click()
        Timer1.Interval = 100
    End Sub
    
    Private Sub Command2_Click()
        Timer1.Interval = 0
    End Sub
    
    Private Sub Command3_Click()
        End
    End Sub
    
    Private Sub Form_Load()
        i = 0
    End Sub
    
    Private Sub Timer1_Timer()
        i = i + 2
        Picture1.Picture = LoadPicture(App.Path & "\DH\" & i & ".bmp")
        If i = 8 Then i = 0
    
    End Sub
    
    
    展开全文
  • VB画机械图形

    2015-12-29 11:16:08
    利用VB画机械图,可以为初学者提供不错的学习思路!
  • 内容索引:VB源码,图形处理,绘画,画图工具 VB图形绘画_画图工具源代码,能设置线形、颜色、撤消和恢复操作,窗体上的滑块也是个不错的应用。
  • VB绘制图形

    千次阅读 2012-02-13 10:50:33
  • vb代码 五角星 椭圆 填充图形 ,以及栅栏线的绘制
  • VB使用Circle方法画弧和扇形,VB6.0画图形,几何图形。  Const pi = 3.14159 '常量声明  Private Sub Form_Click()  ForeColor = vbRed '设置窗体前景色  DrawWidth = 1 '设置线宽  FillStyle = 0 '设置填充...
  • 太极八卦图的VB源码,实现在窗口上一个不断旋转的太极图,创建刷子(参数:颜色值)返回值:刷子句柄,传递设备(参数:图片句柄,设备句柄)返回值:传递后ID,删除设备(参数:设备句柄)返回值:成功或失败信息[删除前需要...
  • VB088-随机图形,源代码
  • VB.NET绘制几何三角形图形,测试绘制时候请单击下面的空白区域,点击鼠标两点间的距离即可绘制出三角形,本程序所绘制的几何图形几乎是全部由三角形构成的,程序同时还可以自动判断交点。
  • vb.net 绘制坐标图形

    2015-01-20 15:08:02
    GDI+绘制图形技术中,最基本的是坐标系统,坐标系统的默认度量单位是像素,我们需要熟练掌握GDI+中坐标的变化概念才能绘制出理想的图形
  • VB画图例子,Line方法矩形 VB代码例子,虽然简单,参考学习挺有用的:  Private Sub Form_Load()  Show  x = 150  y = 150  Line (100, 100)-Step(x, y), QBColor(1), BF '出第1个蓝色小矩形  For i = 2 ...
  • VB图形绘画,图像透明处理工具源代码,能设置线形、颜色、撤消和恢复操作,窗体上的滑块也是个不错的应用。
  • demo.exe 2007/8/19 15:21 应用程序 64 KB DOT8.HZK 1994/1/23 14:24 HZK 文件 8 KB DOT16.HZK 1990/9/18 2:00 HZK 文件 238 KB Form1.frm 2006/1/27 13:03 Visual Basic For... 23 KB Form1.log 2006/1/27 12:57 ...
  • VB 话题 VB画各种图形 VB的RGB演示演示 功能强大,好用好学!
  • vb.net 图形控件 A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. 不久前,...

    vb.net 图形控件

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way.

    不久前,我正在开发Windows Forms应用程序,我需要一个特殊的具有反射(玻璃)效果的标签控件,以一种时尚的方式显示一些标题。

    The GlassLabel control at work.

    Mmmm... thinking deeply about it I realized that it would not be too difficult to build my own, so hands on!  First of all, I wrote my requirements list (and I added more and more things as soon as they popped into my head!).  The final requirement list was like this:

    嗯...对此深思熟虑,我意识到自己打造自己并不困难,所以动手吧! 首先,我写了我的需求列表(一旦它们出现在我的脑海里,我就添加了越来越多的东西!)。 最终需求列表如下:

    It must be a true label control.

    它必须是真正的标签控件。



    It will show a reflection or glass effect of the text drawn.

    它将显示所绘制文本的反射或玻璃效果。



    The control's background can be filled with solid or gradient colors.

    控件的背景可以填充纯色或渐变色。



    The control's text can be filled with solid or gradient colors, too.

    控件的文本也可以用纯色或渐变色填充。



    The text can draw (or not) a solid-color outline with configurable width.

    文本可以绘制(或不绘制)具有可配置宽度的纯色轮廓。



    The level of transparency must be configurable, too.

    透明度级别也必须是可配置的。



    Once done, I thought that writing an article focusing on the graphics work for this control would be a good idea. So I will comment on what I've done and why I did it and will finish my article with the complete code listing of the control.

    完成后,我认为写一篇专注于该控件图形工作的文章将是一个好主意。 因此,我将评论我所做的事情以及为什么这么做,并以控件的完整代码清单结束我的文章。

    1.如果是标签,则为标签 (1. If it's a Label, then it's a Label)

    As said in my requirements list, the control must be a true label control. So I started creating a new class and inheriting it from the standard WinForms Label control.

    如我的需求列表中所述,该控件必须是真正的标签控件。 因此,我开始创建一个新类,并从标准WinForms Label控件继承它。

    Public Class GlassLabel
        Inherits System.Windows.Forms.Label
    End Class
    
    'The AutoSize property has been overridden to achieve the control
    'not to be auto-sized.
    Public Overrides Property AutoSize() As Boolean
        Get
            Return MyBase.AutoSize
        End Get
        Set(ByVal value As Boolean)
            MyBase.AutoSize = False
        End Set
    End Property
    
    'The TextAlign property has been overridden to achieve the control text
    'be aligned always at Middle-Center.
    Public Overrides Property TextAlign() As System.Drawing.ContentAlignment
        Get
            Return MyBase.TextAlign
        End Get
        Set(ByVal value As System.Drawing.ContentAlignment)
            MyBase.TextAlign = ContentAlignment.MiddleCenter
        End Set
    End Property
    

    Finally, I have overridden completely the OnPaint method, because I don't want .Net to draw the control -- I want to do it myself with my requirements. Really, all the work is done in the OnPaint overridden method:

    最后,我完全重写了OnPaint方法,因为我不希望.Net绘制控件-我想根据自己的需要进行操作。 确实,所有工作都是通过OnPaint重写方法完成的:

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        'All the painting work is done here.
        ...
    End Sub
    

    2.渐变 (2. Gradients)

    该控件支持背景和文本的渐变。 借助GDI +,渐变是.Net中最简单的操作之一。 实际上,.Net为我们提供了一个名为LinearGradientBrush的自定义笔刷,我们只需要为其提供绘制矩形(需要计算渐变的步数),开始和结束颜色以及渐变的方向即可(水平,垂直或对角线)。 就这么简单:
    Dim gradBrush As LinearGradientBrush = New LinearGradientBrush(rectangle, color1, color2, direction)
    Graphics.FillRectangle(gradBrush, rectangle)
    

    In the complete listing of GlassLabel control you'll find some code in which I use gradients, and you'll see how easy is to use them.

    在GlassLabel控件的完整列表中,您将找到一些我在其中使用渐变的代码,并且您会看到使用它们的简便性。

    3.大纲 (3. Outline)

    有一些方法可以将文本绘制到Graphics对象中。 最基本的方法是使用DrawString方法,该方法带有一些参数(文本,字体,大小,位置...),并使用所需的画笔绘制文本。

    But for the outline requirement I needed more functionality than DrawString offers. So I used GraphicsPath object. As MSDN says, GraphicsPath represents a series of connected lines and curves. Applications use paths to draw outlines of shapes, fill the interiors of shapes, and create clipping regions. Best of all, the GraphicsPath object provides with it's own AddString method, so we just need to call AddString on the GraphicsPath and it creates a path that outlines the string passed. After that, you can both draw the string outline or fill its contents.

    但是对于大纲要求,我需要比DrawString提供的功能更多。 所以我用了GraphicsPath对象。 正如MSDN所说,GraphicsPath代表一系列连接的直线和曲线。 应用程序使用路径绘制形状的轮廓,填充形状的内部以及创建剪切区域。 最棒的是,GraphicsPath对象提供了它自己的AddString方法,因此我们只需要在GraphicsPath上调用AddString,它会创建一个概述所传递字符串的路径。 之后,您既可以绘制字符串轮廓,也可以填充其内容。

    Dim path As GraphicsPath = New GraphicsPath
    path.AddString(text, fontFamily, fontStyle, emSize, clippingRect, stringFormat)
    Graphics.DrawPath(pen, path)
    Graphics.FillPath(brush, path)
    

    4.反思 (4. Reflection)

    显而易见,要求的难度更大是玻璃或反射效果。 与GDI +中的几乎所有内容一样,有很多方法可以做到这一点。 但是我认为我可能使用了所有方法中最简单的方法。

    A graphics object supports a series of transformations that can affect to his size, rotation angle, etc. Once one of this transformation is applied to a graphics object, all the painting work done over the object is affected by the transformations done. This transformations can be cumulative and that gives us an extremely powerful mechanism to work with graphics.

    图形对象支持一系列可能影响其大小,旋转角度等的变换。一旦将此变换中的一个应用于图形对象,在该对象上完成的所有绘制工作都会受到所完成的变换的影响。 这种转换可以是累积的,这为我们提供了一种非常强大的处理图形的机制。

    In this case I did a really simple transformation: I "said" to my graphics object that all the painting must be affected by a scale transformation. The scale applied is 1 for the horizontal axis (so no transformation) and -1 for the vertical axis (so no transformation in size but vertically reflected). It's as simple as that. You'll find the complete sample in the code listing at the end of the article.

    在这种情况下,我做了一个非常简单的转换:我对图形对象“说”所有画都必须受到比例转换的影响。 对于水平轴,应用的比例为1;对于垂直轴,应用的比例为-1(因此,尺寸没有变化,但垂直反射)。 就这么简单。 您可以在本文结尾的代码清单中找到完整的示例。

    Graphics.ScaleTransform(1, -1)
    

    完整清单
    (The Complete Listing
    )

    好吧,信不信由你,使用这几个GDI +对象,就可以完成所有工作。 这是我的GlassLabel控件的完整列表代码。 该代码的注释很好,我认为您可以轻松地遵循它。

    As a suggestion for further work, maybe it would be a good idea to not override the TextAlign property and make it work in the control as expected, re-calculating the position for each one of the possible values.  Another interesting challenge would be to find a way to show the reflection effect in perspective.

    作为进一步工作的建议,最好不要重写TextAlign属性,并使其按预期方式在控件中工作,然后重新计算每个可能值的位置。 另一个有趣的挑战是找到一种方法来透视显示反射效果。

    Imports System.Drawing
    Imports System.Drawing.Drawing2D
    Imports System.Drawing.Imaging
    
    Public Class GlassLabel
        Inherits System.Windows.Forms.Label
    
        'Variables to hold properties values
        'Each initialization values represent the default value for the property
        Private m_BackGradientColor1 As Color = Color.Black
        Private m_BackGradientColor2 As Color = Color.White
        Private m_BackGradientMode As LinearGradientMode = LinearGradientMode.Horizontal
        Private m_BackGradient As Boolean = False
        Private m_Alpha As Integer = 100
        Private m_ForeGradientColor1 As Color = Color.Purple
        Private m_ForeGradientColor2 As Color = Color.White
        Private m_ForeGradientMode As LinearGradientMode = LinearGradientMode.Vertical
        Private m_ForeGradient As Boolean = False
        Private m_OffsetY As Integer = 0
        Private m_OutlineColor As Color = Color.White
        Private m_OutlineWidth As Integer = 0
    
        'This property get/set text outline border color
        Public Property OutlineColor() As Color
            Get
                Return m_OutlineColor
            End Get
            Set(ByVal value As Color)
                m_OutlineColor = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set text outline border width
        'If set to zero, then it's not outline
        Public Property OutlineWidth() As Integer
            Get
                Return m_OutlineWidth
            End Get
            Set(ByVal value As Integer)
                m_OutlineWidth = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set an integer value that represents
        'the number of pixels that must close up the normal text and
        'the reflected text. As MeasureString considers special characters
        'and glyphos, it returns vertically an extra space. The OffsetY
        'property tells the control to dispose N pixels of space between
        'the drawn texts.
        Public Property OffsetY() As Integer
            Get
                Return m_OffsetY
            End Get
            Set(ByVal value As Integer)
                m_OffsetY = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating if draw the texts
        'using a gradient fill (true) or a solid fill (false)
        Public Property ForeGradient() As Boolean
            Get
                Return m_ForeGradient
            End Get
            Set(ByVal value As Boolean)
                m_ForeGradient = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the direction of
        'the texts gradient fill
        Public Property ForeGradientMode() As LinearGradientMode
            Get
                Return m_ForeGradientMode
            End Get
            Set(ByVal value As LinearGradientMode)
                m_ForeGradientMode = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the second color of
        'the texts gradient fill
        Public Property ForeGradientColor2() As Color
            Get
                Return m_ForeGradientColor2
            End Get
            Set(ByVal value As Color)
                m_ForeGradientColor2 = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the first color of
        'the texts gradient fill
        Public Property ForeGradientColor1() As Color
            Get
                Return m_ForeGradientColor1
            End Get
            Set(ByVal value As Color)
                m_ForeGradientColor1 = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value that represents the level of
        'transparency in the reflected text. Values must be between 0 and 255.
        'The lower value, reflected text is more transparent.
        'The higher value, more opaque.
        Public Property Alpha() As Integer
            Get
                Return m_Alpha
            End Get
            Set(ByVal value As Integer)
                m_Alpha = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating if draw the control's background
        'using a gradient fill (true) or a solid fill (false)
        Public Property BackGradient() As Boolean
            Get
                Return m_BackGradient
            End Get
            Set(ByVal value As Boolean)
                m_BackGradient = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the direction of
        'the control's background gradient fill
        Public Property BackGradientMode() As LinearGradientMode
            Get
                Return m_BackGradientMode
            End Get
            Set(ByVal value As LinearGradientMode)
                m_BackGradientMode = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the second color of
        'the control's background gradient fill
        Public Property BackGradientColor2() As Color
            Get
                Return m_BackGradientColor2
            End Get
            Set(ByVal value As Color)
                m_BackGradientColor2 = value
                Me.Invalidate()
            End Set
        End Property
    
        'This property get/set a value indicating the first color of
        'the control's background gradient fill
        Public Property BackGradientColor1() As Color
            Get
                Return m_BackGradientColor1
            End Get
            Set(ByVal value As Color)
                m_BackGradientColor1 = value
                Me.Invalidate()
            End Set
        End Property
    
        'The AutoSize property has been overridden to achieve the control
        'not to be auto-sized.
        Public Overrides Property AutoSize() As Boolean
            Get
                Return MyBase.AutoSize
            End Get
            Set(ByVal value As Boolean)
                MyBase.AutoSize = False
            End Set
        End Property
    
        'The TextAlign property has been overridden to achieve the control text
        'be aligned always at Middle-Center.
        Public Overrides Property TextAlign() As System.Drawing.ContentAlignment
            Get
                Return MyBase.TextAlign
            End Get
            Set(ByVal value As System.Drawing.ContentAlignment)
                MyBase.TextAlign = ContentAlignment.MiddleCenter
            End Set
        End Property
    
        'All the paintint work is done here.
        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            With e.Graphics
                '*** Apply high-quality properties to the graphics object ************************
                .CompositingQuality = CompositingQuality.HighQuality
                .InterpolationMode = InterpolationMode.HighQualityBicubic
                .PixelOffsetMode = PixelOffsetMode.HighQuality
                .SmoothingMode = SmoothingMode.HighQuality
                .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
    
                '*** Draw the control's background ***********************************************
                If Me.BackGradient Then
                    'The background must show a gradient, so we need to create a gradient brush
                    'and fill the control's background rectangle with this gradient
                    Using bkg As LinearGradientBrush = New LinearGradientBrush(e.ClipRectangle, Me.BackGradientColor1, Me.BackGradientColor2, Me.BackGradientMode)
                        .FillRectangle(bkg, e.ClipRectangle)
                    End Using
                Else
                    'The background is a solid color. The Clear method of the Graphics object
                    'let us to choose a color to clear the background.
                    .Clear(Me.BackColor)
                End If
                '*********************************************************************************
    
                '*** Create and draw the normal (not reflected) text *****************************
                'Get the text width & height
                Dim width As Single = .MeasureString(Me.Text, Me.Font).Width
                Dim height As Single = .MeasureString(Me.Text, Me.Font).Height
    
                'Create a rectangle that delimites the position & size of the text drawn
    
                'The x position must be (control width - text width) / 2, so the text will be
                'horizontally centered
                Dim xpos As Single = (e.ClipRectangle.Width - width) / 2
    
                'The y position must be also vertically centered, so we start from
                '(control height - text height) / 2
                'But below the normal text will be the reflected text, so must offset to top
                'the half of text height
                'Additionally, MeasureString give us extra space reserved for tall glyphos,
                'so must consider the OffsetY value to delete this extra space, so must offset
                'to bottom the half of OffsetY value
                Dim ypos As Single = ((e.ClipRectangle.Height - height) / 2) - (height / 2) + (Me.OffsetY / 2)
    
                'Finally, create the rectangle from x,y pos and width & height of the text
                Dim originalRect As New RectangleF(xpos, ypos, width, height)
    
                'Draw the original string. We'll use a GraphicsPath object instead
                'using DrawString directly, because GraphicsPath will let us draw an
                'outline border to the text
    
                'Create the path
                Dim path As GraphicsPath = New GraphicsPath
    
                'Add the string to the path. Because GraphicsPath's AddString method
                'uses emSize (the height of the em square box that bounds the character)
                'instead of Point, we must convert out font's Point size to emSize using
                'this formula: (Vertical Resolution / 72) * Font's Point Size
                path.AddString(Me.Text, Me.Font.FontFamily, Me.Font.Style, (.DpiY / 72) * Me.Font.Size, originalRect, StringFormat.GenericDefault)
    
                'If and outline must be drawn, draw it
                If Me.OutlineWidth > 0 Then
                    Using p As Pen = New Pen(Me.OutlineColor, Me.OutlineWidth)
                        .DrawPath(p, path)
                    End Using
                End If
    
                'Create the brush to fill the text
                Dim fill As Brush
                If Me.ForeGradient Then
                    'Text must be filled with a gradient brush
                    fill = New LinearGradientBrush(originalRect, Me.ForeGradientColor1, Me.ForeGradientColor2, Me.ForeGradientMode)
                Else
                    'Text must be filled with a solid brush
                    fill = New SolidBrush(Me.ForeColor)
                End If
    
                'Fill the text and destroy the brush
                .FillPath(fill, path)
                fill.Dispose()
    
                'The GraphicsPath object won't be needed anymore
                path.Dispose()
    
                'From this point we must deal with reflected text. So it's a good idea to
                'save the current state of our graphics object. What is really saved is the
                'state of the objects (transformations applied, etc), not the drawings done
                'until here.
                Dim state As GraphicsState = .Save
    
                'Reset the transformations done until here so we start from a "fresh clean"
                'graphics object state.
                .ResetTransform()
    
                'ScaleTransform will set the graphics object into a state in which all the
                'drawings done after the instruction will be affected by the scaling done.
                'As we use 1 for horizontal value, the drawings will be not changed in the
                'horizontal plane. But as we use -1 for the vertical value, all the drawings
                'will be vertically inverted (the reflection effect that we want).
                .ScaleTransform(1, -1)
    
                'Now, as we did for the normal text, we'll create a rectangle that delimites
                'the position and size of the reflected text
    
                'The x-position must not be changed, as it is the same (horizontally centered)
    
                'The y-pos must be vertically centered, so we start from
                '(control height - text height) / 2
                'From there, as we did with normal text, we must offset the half of the text height
                '(in this case, offset to top)
                'Also must offset the OffsetY value, to top too
                'BUT we must remember that this will be drawn over a transformed (Scaled)
                'graphics object, so must invert all signs (for example, offset to bottom instead
                'to top)
                ypos = (((((e.ClipRectangle.Height - height) / 2) + (height / 2)) * -1) - height) + (Me.OffsetY / 2)
    
                'Create the rectangle
                Dim reflectedRect As New RectangleF(xpos, ypos, width, height)
    
                'Create the path to hold the text
                Dim reflectedPath As GraphicsPath = New GraphicsPath
    
                'Add the string to the path
                reflectedPath.AddString(Me.Text, Me.Font.FontFamily, Me.Font.Style, (.DpiY / 72) * Me.Font.Size, reflectedRect, StringFormat.GenericDefault)
    
                'Draw the outline, if it applies
                If Me.OutlineWidth > 0 Then
                    'Note that we apply alpha transparency to the outline. If not, reflected
                    'text's outline will appear too much "solid"
                    Using p As Pen = New Pen(Color.FromArgb(Me.Alpha, Me.OutlineColor), Me.OutlineWidth)
                        .DrawPath(p, reflectedPath)
                    End Using
                End If
    
                'Create the brush to fill the reflected text
                If Me.ForeGradient Then
                    'We must apply Alpha transparency on both gradient colors
                    fill = New LinearGradientBrush(reflectedRect, Color.FromArgb(Me.Alpha, Me.ForeGradientColor1), Color.FromArgb(Me.Alpha, Me.ForeGradientColor2), Me.ForeGradientMode)
                Else
                    'Apply Alpha to solid color too
                    fill = New SolidBrush(Color.FromArgb(Me.Alpha, Me.ForeColor))
                End If
    
                'Draw the text (it will be automatically reflected because of the Scale
                'transformation applied)
                .FillPath(fill, reflectedPath)
    
                'Destroy objects that are no more needed
                fill.Dispose()
                reflectedPath.Dispose()
    
                'Restore the Graphics object state (eliminate transformations, so if we drew
                'anymore from here will not be reflected)
                .Restore(state)
                '*********************************************************************************
            End With
        End Sub
    End Class
    

    翻译自: https://www.experts-exchange.com/articles/3623/Having-fun-with-graphics-a-VB-net-GlassLabel-control.html

    vb.net 图形控件

    展开全文
  • vb.net简单画图实现,画圆,矩形,直线,画笔,裁剪等基本画图功能
  • VB动画绘制正弦线

    2021-05-18 04:49:41
    摘要:VB源码,图形处理,正弦线,图形绘制 VB绘制正弦线,用VB实现在图片框中绘制坐标轴,并在坐标系内动态生成正弦线。注释:首先清除picture1内的图形,设置绘线宽度,绘坐标系的X轴及箭头线,绘坐标系的Y轴及箭头线...
  • 直接用VB6代码生成二维码,我也把代码做成了控件的方式,...VB生成二维码图形的控件,非常好用,含使用范例源码,VB生成二维码图形的控件,非常好用,含使用范例源码,VB生成二维码图形的控件,非常好用,含使用范例源码
  • vb Gdi+利用多颜色梯度线性渐变刷填充图形
  • VB源码,图形处理,验证码 本程序通过VB编写实现验证码生成,并根据用户的输入判断验证码是否相同,程序实现思路大致是这样的:初始化随机种子,生成随机校验码,显示校验码,添加噪点(防止自动图像识别),设置点...
  • VB画折线图的源码实例,鼠标在方格背景上单击两个地方,会以两点为基准为线,在不同处单击,就可连续画出拆线图。通过这个画拆线图的代码你可了解一下如何定义graphics对象、如何定义画刷和定义字体,以及画线时如何...
  • vb几何图形动画

    2007-11-20 21:32:05
    vb几何图形动画源代码,很酷的VB做的几何图形动画,看到这个你就可以知道学VB其实也是一种很又前途的语言,会觉得vb的强大
  • VB窗体开发实例,各种算法图形及画笔,调画笔粗细、调颜色、调笔刷样式等等,有用过PhotoShop的朋友,不用介绍就知道本程序的作用,没用过的,下载运行一下便知。  程序中的滚动条滑块模块、颜色选取模块我觉得挺...
  • vb画c60的三维图形

    2013-04-15 20:28:02
    vb画c60的三维图形
  • 摘要:VB源码,图形处理,绘制网络 绘制网格,VB在一张窗体的图片上绘制出指定行列的网格,设定数据后会自动计算并出方格,点击下方的控制按钮即可完成该效果。 运行环境:Windows/VB6
  • VB生成雪花图形.rar

    2019-07-10 11:33:32
    VB生成雪花图形,根据分形算法的原理生成的雪花图案,生成过程中以动画的方式展现,从雪花的下半部分开始生成,直到生成整个雪花。
  • vb.net绘制图形方法

    千次阅读 2018-04-14 21:14:21
    简述VB.NET绘制图形 学习VB.NET时,你可能会遇到VB.NET绘制图形问题,这里将介绍VB.NET绘制图形问题的解决方法,在这里拿出来和大家分享一下。 1.创建Graphics对象 VB.NET绘制图形需要指定绘图表面。其中,窗体和...

    简述VB.NET绘制图形

      学习VB.NET时,你可能会遇到VB.NET绘制图形问题,这里将介绍VB.NET绘制图形问题的解决方法,在这里拿出来和大家分享一下。

      1.创建Graphics对象

      VB.NET绘制图形需要指定绘图表面。其中,窗体和所有具有Text属性的控件都可以作为绘制图形的表面。因为Graphics对象标识GDI+的绘图表面,所以,绘制图形必须先创建Graphics对象。创建Graphics对象有以下几种方法。

      1>使用CreateGraphics方法创建
      这是一种常见的创建方法,其格式为:Dim 对象名 As Graphics对象名=窗体名(或控件名).CreateGraphics

      2>利用PaintEventArgs参数传递Graphics对象
      通过窗体或控件的Paint事件可以直接完成图形绘制。在编写Paint事件处理程序时,参数PaintEventArgs就提供了图形对象。例如:

      
      Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint  
      Dim g_paint As Graphics = e.Graphics  
      …  
      End Sub 

      3>从Image对象创建
      还可以使用Image对象来创建,这时要使用Graphics.FromImage方法

      2.VB.NET绘制图形首先要会使用画笔

      画笔是用来画线的GDI+对象,它是Pen类的一个实例。使用画笔可以绘制直线,曲线,以及矩形,圆形,多边形等形状的边框。

      1>建立画笔
      格式:Dim 画笔名 As New Pen(颜色[,宽度]) 其中颜色即用画笔绘制线条的颜色,宽度是画笔绘制线条的宽度,单位是像素。宽度的默认值是1。
      例如:Dim mypen As New Pen(Color.Blue)或Dim mypen As Pen = New Pen(Color.Blue)

      2>绘制线条或空心形状
      建立画笔后,就可以用Graphics类的各种方法绘制直线,曲线或矩形,圆形等空心形状的线条。
      (1)DrawLine方法——画直线DrawLine(画笔名,X1,Y1,X2,Y2) 其中,(X1,Y1)和(X2,Y2)是直线的起始点和终止点的坐标,他们可以是Integer值,也可以是Single值。当直线很短时,可以近似为点。
      (2)DrawRectangle方法——画矩形DrawRectangle(画笔名,X,Y,宽度,高度) 其中,(X,Y)时矩形左上角的坐标,宽度和高度指定矩形的宽和长。
      (3)DrawPolygon方法——画多边形DrawPolygon(画笔名,顶点)
      其中,顶点是一个数组,该数组类型是Point或PointF结构,数组的各元素用来指定多边形各顶点的坐标。由Point结构指定的是Integer类型,而由PointF指定的是Single类型。
      用Point或PointF结构来定义一个点的格式是:Dim 点名 As New Point/PointF(x,y)DrawPolygon方法的功能是按数组顶点的顺序连接成一个多边形,两个连续的顶点之间绘制一条边。
      (4)DrawEllipse方法——画圆和椭圆DrawEllipse(画笔名,X,Y,宽度,高度) 方法中的x,y,宽度,高度定义的矩形是要绘制的圆或椭圆的外切矩形,它决定了所画椭圆的大小和形状。当宽度和高度相等时,所画的就是圆,否则就是椭圆。
      (5)DrawArc方法——画弧DrawArc(画笔名,X,Y,宽度,高度,起始角,扫描角)  该方法与DrawEllipse方法相比多了起始角和扫描角两个参数,这可以看作是在截取圆或椭圆而形成的一段弧。起始角和扫描角都是以度为单位的,一般以水平向右的半径为0度,然后按顺时针方向画弧。起始角是开始画弧的角度,扫描角是顺时针方向增加的角度。当扫描角为360度时,画出的就是一个圆或者椭圆。
      (6)DrawPie方法——画饼图DrawPie(画笔名,X,Y,宽度,高度,起始角,扫描角) 饼图也称扇图。该方法与DrawArc方法的参数一样,但是饼图比弧多出两条半径。

            (7)Drawstring方法——画字符串DrawString(String, Font, Brush, PointF)在指定位置并且用指定的 Brush 和 Font 对象绘制指定的文本字符串。

    详细请参考:https://msdn.microsoft.com/zh-cn/library/system.drawing.graphics(v=vs.110).aspx

    展开全文

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 9,544
精华内容 3,817
关键字:

vb如何画图形