📜  Arcade 内置函数在 Python3 中绘制多边形

📅  最后修改于: 2022-05-13 01:54:51.967000             🧑  作者: Mango

Arcade 内置函数在 Python3 中绘制多边形

街机库是一个高科技Python包,其中包含一组高级工具,可用于制作具有令人抓狂的图形和声音的 2D 游戏。它是面向对象的,专为Python 3.6 及以上版本构建。

Arcade 有两个用于绘制多边形的内置函数:

1. arcade.draw_polygon_outline( ) :该函数用于绘制多边形的轮廓。

例子:

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 的这个内置函数用于绘制填充有颜色的多边形。

例子:

蟒蛇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()

输出: