📜  在 Python3 中使用 Arcade 绘制圆

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

在 Python3 中使用 Arcade 绘制圆

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

Arcade 内置函数来绘制圆圈:-

1. arcade.draw_circle_outline( ) :该函数用于绘制圆的轮廓。

举个例子——

Python3
#import module
import arcade
 
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw  an arc  for GfG ")
 
#set background
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
#function to draw a circle
arcade.draw_circle_outline(300, 285, 88, arcade.color.GREEN, 9,-1)
 
#finish drawing
arcade.finish_render()
 
#to display everything
arcade.run()


Python3
#import module
import arcade
 
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw  an arc  for GfG ")
 
# set background color
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# function for designing olympic flag
arcade.draw_circle_outline(100, 285, 88, arcade.color.BLUE, 9, -1)
arcade.draw_circle_outline(300, 285, 88, arcade.color.BLACK, 9, -1)
arcade.draw_circle_outline(500, 285, 88, arcade.color.RED, 9, -1)
arcade.draw_circle_outline(200, 185, 88, arcade.color.YELLOW, 9, -1)
arcade.draw_circle_outline(400, 185, 88, arcade.color.GREEN, 9, -1)
 
# finished drawing
arcade.finish_render()
 
# to display everything
arcade.run()


Python3
#import module
import arcade
 
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw  a circle  for GfG ")
 
# set background
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# draw circle
arcade.draw_circle_filled(300, 450, 78, arcade.color.PINK, 0)
 
 
# finish drawing
arcade.finish_render()
 
# to display everything
arcade.run()


Python3
#import module
import arcade
 
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw  a circle  for GfG ")
 
# set background
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# snowman upper part
arcade.draw_circle_filled(300, 450, 68, arcade.color.SKY_BLUE, 0)
 
# snowman eyes
arcade.draw_circle_filled(289, 475, 8, arcade.color.BLACK, 0)
arcade.draw_circle_filled(329, 475, 8, arcade.color.BLACK, 0)
 
# snowman lower part
arcade.draw_circle_filled(300, 350, 88, arcade.color.BLUE, 0)
arcade.draw_circle_filled(300, 250, 108, arcade.color.SKY_BLUE, 0)
 
# finish drawing
arcade.finish_render()
 
# to display everything
arcade.run()



输出:

因为,现在您知道如何绘制圆形的简单轮廓。让我们使用这个 arcade.draw_circle_outline( ) 绘制奥林匹克旗帜。

蟒蛇3

#import module
import arcade
 
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw  an arc  for GfG ")
 
# set background color
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# function for designing olympic flag
arcade.draw_circle_outline(100, 285, 88, arcade.color.BLUE, 9, -1)
arcade.draw_circle_outline(300, 285, 88, arcade.color.BLACK, 9, -1)
arcade.draw_circle_outline(500, 285, 88, arcade.color.RED, 9, -1)
arcade.draw_circle_outline(200, 185, 88, arcade.color.YELLOW, 9, -1)
arcade.draw_circle_outline(400, 185, 88, arcade.color.GREEN, 9, -1)
 
# finished drawing
arcade.finish_render()
 
# to display everything
arcade.run()

输出:

2. arcade.draw_circle_fill():该函数用于绘制彩色实心圆。

举个例子——

蟒蛇3

#import module
import arcade
 
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Draw  a circle  for GfG ")
 
# set background
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# draw circle
arcade.draw_circle_filled(300, 450, 78, arcade.color.PINK, 0)
 
 
# finish drawing
arcade.finish_render()
 
# to display everything
arcade.run()

输出:

因为,现在您知道如何绘制圆形的简单轮廓。让我们用这个 arcade.draw_circle_filled( ) 画一个雪人。

蟒蛇3

#import module
import arcade
 
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw  a circle  for GfG ")
 
# set background
arcade.set_background_color(arcade.color.WHITE)
 
# Start the render process.
arcade.start_render()
 
# snowman upper part
arcade.draw_circle_filled(300, 450, 68, arcade.color.SKY_BLUE, 0)
 
# snowman eyes
arcade.draw_circle_filled(289, 475, 8, arcade.color.BLACK, 0)
arcade.draw_circle_filled(329, 475, 8, arcade.color.BLACK, 0)
 
# snowman lower part
arcade.draw_circle_filled(300, 350, 88, arcade.color.BLUE, 0)
arcade.draw_circle_filled(300, 250, 108, arcade.color.SKY_BLUE, 0)
 
# finish drawing
arcade.finish_render()
 
# to display everything
arcade.run()

输出: