当前位置:网站首页>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
是一个重载,值得注意的是:传的参数要不一样
边栏推荐
- 论数据库的传统与未来之争之溯源溯本----AWS系列专栏
- The postgraduate entrance examination in these areas is crazy! Which area has the largest number of candidates?
- C language 99 multiplication table
- Distributed ID generation system
- QT两种方法实现定时器
- Case description: the competition score management system needs to count the competition scores obtained by previous champions and record them in the file. The system has the following requirements: -
- 好物推薦:移動端開發安全工具
- 0 basic C language (2)
- Feitian +cipu body brings more imagination to the metauniverse
- 剑指 Offer II 091. 粉刷房子
猜你喜欢

慕课11、微服务的用户认证与授权

【贝叶斯分类4】贝叶斯网

vue中缓存组件keep-alive

慕课8、服务容错-Sentinel

MySQL - database creation and management

Introduction to single chip microcomputer one-on-one learning strategy, independent development program immediately after reading

Gee: calculate the maximum and minimum values of pixels in the image area
Mongodb implements creating and deleting databases, creating and deleting tables (sets), and adding, deleting, modifying, and querying data

leetcode刷题:字符串02( 反转字符串II)

阿里云个人镜像仓库日常基本使用
随机推荐
论数据库的传统与未来之争之溯源溯本----AWS系列专栏
Leetcode question brushing: String 01 (inverted string)
【最详细】最新最全Redis面试大全(70道)
Disruptor本地线程队列_使用transProcessor处理器和WorkPool两种方式进行消费对比---线程间通信工作笔记005
Super VRT
Leetcode question brushing: String 02 (reverse string II)
【山东大学】考研初试复试资料分享
基于SSH框架的学生信息管理系统
Swagger: how to generate beautiful static document description pages
[Shandong University] information sharing for the first and second examinations of postgraduate entrance examination
Leetcode question brushing: String 05 (Sword finger offer 58 - ii. left rotation string)
mysql存储过程
Arrête d'être un bébé géant.
Developer survey: rust/postgresql is the most popular, and PHP salary is low
leetcode刷题:字符串05(剑指 Offer 58 - II. 左旋转字符串)
Detailed explanation of stored procedures in MySQL
Looking back at the moon
Is it safe to open an online account in case of five-year exemption?
[most detailed] the latest and complete redis interview (70)
开发者调查:Rust/PostgreSQL 最受喜爱,PHP 薪水偏低