简单图形库介绍
图形坐标系、像素 3 : 。。 . ······|········· 0。。。 ●●。 ●●。。。。 ······→…··········· 。 ●。●。·。 。● ·····················⊙·· ●。 ··.···········● e。。。。。 .·····.······ ······················ ●。 。。。 。 ●·················· 0
第三方图形库 ■C语言本身不提供图形绘制功能。 借助于第三方提供的图形库,可实现图形的绘 制。 图形库以C原码形式,或者以二进制目标码形式提 供 在应用第三方图形库时,不需要了解其具体的实现, 只需了解其基本功能和图形绘制流程。 直接调用相关图形库函数来实现具体的图形绘 制。 注意:图形库接口头文件应当被包含到源文件中 头文件包含了相关图形库函数的原型
C语言本身不提供图形绘制功能。 借助于第三方提供的图形库,可实现图形的绘 制。 ▪ 图形库以C原码形式,或者以二进制目标码形式提 供。 ▪ 在应用第三方图形库时,不需要了解其具体的实现, 只需了解其基本功能和图形绘制流程。 直接调用相关图形库函数来实现具体的图形绘 制。 ▪ 注意:图形库接口头文件应当被包含到源文件中。 ▪ 头文件包含了相关图形库函数的原型
基本图形函数 Init Graphics Initializes the graphics package, open the window for renderin MovePen(, y) Moves the pen to an absolute position Draws a line from current position to a relative DrawLine(dx, dy) coordinates DrawArc(r, start, sweep) Draws an arc specified by a radius and two angles GetWindow Width Returns the width of the graphics window GetWindowHeightO Returns the height of the graphics window GetcurrentXO Returns the current x-coordinate of the pen GetcurrentYo Returns the current y-coordinate of the pen
InitGraphics() Initializes the graphics package, open the window for rendering MovePen(x, y) Moves the pen to an absolute position DrawLine(dx, dy) Draws a line from current position to a relative coordinates DrawArc(r, start, sweep) Draws an arc specified by a radius and two angles GetWindowWidth() Returns the width of the graphics window GetWindowHeight() Returns the height of the graphics window GetCurrentX() Returns the current x-coordinate of the pen GetCurrentY() Returns the current y-coordinate of the pen
初始化 本课程采用的第三方图形库是基于 windows系 统的Win32AP 在Win3AP中,第一个C函数是 Win main(),而不 是 main),且要遵循 Windows编程规范—一这 需要花很多时间去学习 为了方面初学者使用,在第三方图形库中,已 实现了通用的 Win maing)基本功能 应用程序所要做的相关初始化工作只需写在Main( 函数中即可 在Main函数中,首先要调用 I Init Graphic50来初始化 图形窗口,以便绘制图形
本课程采用的第三方图形库是基于windows系 统的Win32API. 在Win32API中, 第一个C函数是WinMain(), 而不 是 main(),且要遵循windows编程规范——这 需要花很多时间去学习. 为了方面初学者使用,在第三方图形库中,已 实现了通用的WinMain()基本功能 ▪ 应用程序所要做的相关初始化工作只需写在Main() 函数中即可. ▪ 在Main()函数中,首先要调用InitGraphics()来初始化 图形窗口,以便绘制图形