📜  Arcade 内置函数在 Python3 中绘制点

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

Arcade 内置函数在 Python3 中绘制点

Arcade 库是一个现代Python模块,广泛用于开发具有引人入胜的图形和声音的 2D 视频游戏。 Arcade 是一个面向对象的库。它可以像任何其他Python包一样安装。

在本文中,我们将学习什么是 Arcade 内置函数来绘制点。

Arcade 库是一个现代框架,通过其内置功能可以非常轻松地绘制插图。在街机中,我们有两个内置函数来绘制点。

1. arcade.draw_point( ):用于绘制一个点,您甚至可以通过多次调用该函数来绘制多个点。

使用 arcade.draw_point 绘制点的方法:

  1. 导入 Arcade 模块
  2. 打开窗口并设置窗口参数。
  3. 设置输出窗口的背景颜色。(可选)
  4. 开始渲染过程
  5. 使用指定的参数实现 arcade.draw_point()。
  6. 完成渲染
  7. 保持窗户向上直到你关闭它。

程序一:(画单点的程序)

Python3
import arcade
 
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw  a point for GfG ")
 
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# Draw a point
arcade.draw_point(60, 495, arcade.color.RED, 10)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()


Python3
import arcade
 
# Open the window
arcade.open_window(600, 600, "Draw  a point for GfG ")
arcade.set_background_color(arcade.color.BLUE)
 
# Start the render process
arcade.start_render()
 
# Draw a point
arcade.draw_point(60, 495, arcade.color.RED, 10)
 
# Draw a point
arcade.draw_point(80, 500, arcade.color.YELLOW, 10)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()


Python3
import arcade
 
# Open the window
arcade.open_window(600, 600, "Draw  a point for GfG ")
 
arcade.set_background_color(arcade.color.ORANGE)
 
# Start the render process.
arcade.start_render()
 
# Draw a points
point_list = ((165, 495),
              (165, 480),
              (165, 465),
              (195, 495),
              (195, 480),
              (195, 465))
arcade.draw_points(point_list, arcade.color.GREEN , 10)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()


输出:

程序2:(绘制多个点的程序)

蟒蛇3

import arcade
 
# Open the window
arcade.open_window(600, 600, "Draw  a point for GfG ")
arcade.set_background_color(arcade.color.BLUE)
 
# Start the render process
arcade.start_render()
 
# Draw a point
arcade.draw_point(60, 495, arcade.color.RED, 10)
 
# Draw a point
arcade.draw_point(80, 500, arcade.color.YELLOW, 10)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()

输出:

2. arcade.draw_points():使用此函数,可以更容易地以特定模式绘制多个点。

程序:

蟒蛇3

import arcade
 
# Open the window
arcade.open_window(600, 600, "Draw  a point for GfG ")
 
arcade.set_background_color(arcade.color.ORANGE)
 
# Start the render process.
arcade.start_render()
 
# Draw a points
point_list = ((165, 495),
              (165, 480),
              (165, 465),
              (195, 495),
              (195, 480),
              (195, 465))
arcade.draw_points(point_list, arcade.color.GREEN , 10)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()

输出: