在Python中使用 Arcade 绘制圆弧
街机库是一个高科技Python包,其中包含一组先进的工具,用于制作具有抓人眼球的图形和声音的 2D 游戏。它是面向对象的,专为Python 3.6 及以上版本构建。
Arcade 有两个用于绘制圆弧的内置函数:
1:arcade.draw_arc_outline():这个函数用来画一个圆弧,对画曲线很有用
Syntax: arcade.draw_arc_outline(center_x , center_y, width , height, color, start_angle, end_angle , border_width, tilt_angle, num_segments)
Parameters:
- center_x : x position that is the center of the arc.
- center_y : y position that is the center of the arc.
- width : width of the arc.
- height : height of the arc.
- color : Outline color of the arc.
- start_angle : start angle of the arc in degrees.
- end_angle : end angle of the arc in degrees.
- border_width : width of line in pixels.
- tilt_angle : angle the arc is tilted.
- num_segments : Higher is the num of segments ,better is the quality .
让我们看看下面的例子:-
Python3
import arcade
# Open the window. Set the window title and
# dimensions (width and height)
arcade.open_window(600, 600, "Draw an arc for GfG ")
arcade.set_background_color(arcade.color.WHITE)
# Start the render process.
arcade.start_render()
arcade.draw_arc_outline(150, 81, 15, 36,
arcade.color.BLACK, 90, 360)
arcade.finish_render()
arcade.run()
Python3
# import arcade 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 a background color
arcade.set_background_color(arcade.color.WHITE)
# Start the render process.
arcade.start_render()
# function for drawing arc
arcade.draw_arc_filled(150, 144, 85, 86,
arcade.color.BOTTLE_GREEN, 90, 360, 45, 54)
# finished drawing
arcade.finish_render()
# to diaplay everything
arcade.run()
输出:
2: arcade.draw_arc_filled():这个函数用来绘制一个填充有颜色的圆弧,这对于绘制楔形或吃豆人很有用。
Syntax: arcade.draw_arc_outline(center_x , center_y, width , height, color, start_angle, end_angle , tilt_angle, num_segments)
Parameters:
- center_x : x position that is the center of the arc.
- center_y : y position that is the center of the arc.
- width : width of the arc.
- height : height of the arc.
- color : color to be filled in the arc.
- start_angle : start angle of the arc in degrees.
- end_angle : end angle of the arc in degrees.
- tilt_angle : angle the arc is tilted.
- num_segments : Number of line segments used to draw the arc.
让我们举一个例子来清楚地了解功能。
蟒蛇3
# import arcade 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 a background color
arcade.set_background_color(arcade.color.WHITE)
# Start the render process.
arcade.start_render()
# function for drawing arc
arcade.draw_arc_filled(150, 144, 85, 86,
arcade.color.BOTTLE_GREEN, 90, 360, 45, 54)
# finished drawing
arcade.finish_render()
# to diaplay everything
arcade.run()
输出: