当前位置:网站首页>VB.net类库(进阶——2 重载)
VB.net类库(进阶——2 重载)
2022-06-26 20:40:00 【小虞163】
这一次来看看一个函数如何带动不同的参数
我们看到:
绿色部分:1个(共2个)
我们在类库中的main中添加2段函数:
''' <summary>
''' 这是一个没有字母的坐标系
''' </summary>
''' <param name="picWidth">获取图片的长度</param>
''' <param name="picHeight">获取图片的高度</param>
''' <param name="AxisColor">坐标轴的颜色</param>
''' <param name="penwidth">笔的粗细</param>
''' <returns></returns>
Public Function CreateAxis(picWidth As Integer, picHeight As Integer, AxisColor As Color, penwidth As Single)
'使用红色绘制坐标轴
Dim p As New Pen(AxisColor, penwidth)
'坐标轴末尾箭头
p.EndCap = Drawing2D.LineCap.ArrowAnchor
'坐标原点
Dim originPointX As Point = New Point(0, picHeight / 2)
Dim originPointY As Point = New Point(picWidth / 2, picHeight)
'绘制横坐标
g.DrawLine(p, originPointX, New Point(picWidth, picHeight / 2))
'绘制纵坐标--http://blog.csdn.net/uruseibest
g.DrawLine(p, originPointY, New Point(picWidth / 2, 0))
'g.DrawString("y", New Font("宋体", 10, FontStyle.Italic), New SolidBrush(AxisColor), New Point(185, 1))
'g.DrawString("x", New Font("宋体", 10, FontStyle.Italic), New SolidBrush(AxisColor), New Point(390, 205))
Return Image
End Function
''' <summary>
''' 相比较之前的函数要多处一个坐标系字母,即 X O Y
''' </summary>
''' <param name="picWidth">获取图片的长度</param>
''' <param name="picHeight">获取图片的高度</param>
''' <param name="AxisColor">坐标轴的颜色</param>
''' <param name="penwidth">笔的粗细</param>
'''<param name="font">字体</param>
''' <returns></returns>
Public Overridable Function CreateAxis(picWidth As Integer, picHeight As Integer, AxisColor As Color, penwidth As Single, font As Font)
Dim brush As New SolidBrush(AxisColor)
'使用红色绘制坐标轴
Dim p As New Pen(AxisColor, penwidth)
'坐标轴末尾箭头
p.EndCap = Drawing2D.LineCap.ArrowAnchor
'坐标原点
Dim originPointX As Point = New Point(0, picHeight / 2)
Dim originPointY As Point = New Point(picWidth / 2, picHeight)
'绘制横坐标
g.DrawLine(p, originPointX, New Point(picWidth, picHeight / 2))
'绘制纵坐标--http://blog.csdn.net/uruseibest
g.DrawLine(p, originPointY, New Point(picWidth / 2, 0))
g.DrawString("y", font, brush, New Point(picWidth / 2 - 15, 1))
g.DrawString("x", font, brush, New Point(picWidth - 10, picHeight / 2 + 10))
g.DrawString("o", font, brush, New Point(picWidth / 2 - 10, picHeight / 2 + 10))
Return Image
End Function
其中第二段:Public Overridable Function CreateAxis(picWidth As Integer, picHeight As Integer, AxisColor As Color, penwidth As Single, font As Font)
end function
是一个重载,值得注意的是:传的参数要不一样
边栏推荐
- 开发者调查:Rust/PostgreSQL 最受喜爱,PHP 薪水偏低
- GameFi 活跃用户、交易量、融资额、新项目持续性下滑,Axie、StepN 能摆脱死亡螺旋吗?链游路在何方?
- leetcode刷题:字符串03(剑指 Offer 05. 替换空格)
- Developer survey: rust/postgresql is the most popular, and PHP salary is low
- [Bayesian classification 2] naive Bayesian classifier
- 回首望月
- Disruptor local thread queue_ Use transprocessor processor and workpool to compare consumption - Notes on inter thread communication 005
- Yonghui released the data of Lantern Festival: the sales of Tangyuan increased significantly, and several people's livelihood products increased by more than 150%
- 0 basic C language (3)
- mysql存储过程
猜你喜欢
Leetcode: String 04 (reverse the words in the string)
C language 99 multiplication table
回首望月
MongoDB实现创建删除数据库、创建删除表(集合)、数据增删改查
IDEA 报错:Process terminated【已解决】
这些地区考研太疯狂!哪个地区报考人数最多?
[serial] shuotou O & M monitoring system 01 overview of monitoring system
Gee: calculate the maximum and minimum values of pixels in the image area
【贝叶斯分类3】半朴素贝叶斯分类器
第2章 构建自定义语料库
随机推荐
【 protobuf 】 quelques puits causés par la mise à niveau de protobuf
定长内存池
C primer plus学习笔记 —— 3、字符的IO(输入/输出)
30. 串联所有单词的子串
0基础学c语言(3)
Serial port application program based on gd32
0基础c语言(0)
windows系统下怎么安装mysql8.0数据库?(图文教程)
leetcode刷题:字符串04(颠倒字符串中的单词)
Developer survey: rust/postgresql is the most popular, and PHP salary is low
QT两种方法实现定时器
0 basic C language (2)
When are global variables initialized before entering the main function?
Disruptor local thread queue_ Use transprocessor processor and workpool to compare consumption - Notes on inter thread communication 005
回溯思路详解
Stringutils judge whether the string is empty
12个MySQL慢查询的原因分析
MySQL stored procedure
Two methods of QT to realize timer
Is it safe to open an online account in case of five-year exemption?