Arcade 内置函数在 Python3 中绘制多边形
街机库是一个高科技Python包,其中包含一组高级工具,可用于制作具有令人抓狂的图形和声音的 2D 游戏。它是面向对象的,专为Python 3.6 及以上版本构建。
Arcade 有两个用于绘制多边形的内置函数:
1. arcade.draw_polygon_outline( ) :该函数用于绘制多边形的轮廓。
Syntax: arcade.draw_polygon_outline (point_list, color, line_width )
Parameters:
- point_list: List of points making up the lines. Each point is in a list. So it is a list of lists.
- color (Color): specify color using arcade.color.COLOR NAME. (Note that color name should in Capital letters.)
- line_width:- Width of the line in pixels.
例子:
Python3
import arcade
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw a polygon for GfG ")
arcade.set_background_color(arcade.color.ORANGE)
# Start the render process.
arcade.start_render()
point_list = ((30, 240),
(45, 240),
(60, 255),
(60, 285),
(45, 300),
(30, 300))
arcade.draw_polygon_outline(point_list, arcade.color.SPANISH_VIOLET, 3)
arcade.finish_render()
arcade.run()
Python3
import arcade
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw a polygon for GfG ")
arcade.set_background_color(arcade.color.ORANGE)
# Start the render process.
arcade.start_render()
point_list = ((150, 240),
(165, 240),
(180, 255),
(180, 285),
(165, 300),
(150, 300))
arcade.draw_polygon_filled(point_list, arcade.color.SPANISH_VIOLET)
arcade.finish_render()
arcade.run()
输出:
2. arcade.draw_polygon_filled( ): Arcade 的这个内置函数用于绘制填充有颜色的多边形。
Syntax: arcade.draw_polygon_filled (point_list, color )
Parameters:
- point_list- It is basically List of points where each point is in a list. So it is a list of lists.
- Color – specify color using arcade.color.COLOR NAME. (Note that color name should in Capital letters. )
例子:
蟒蛇3
import arcade
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw a polygon for GfG ")
arcade.set_background_color(arcade.color.ORANGE)
# Start the render process.
arcade.start_render()
point_list = ((150, 240),
(165, 240),
(180, 255),
(180, 285),
(165, 300),
(150, 300))
arcade.draw_polygon_filled(point_list, arcade.color.SPANISH_VIOLET)
arcade.finish_render()
arcade.run()
输出: