Draw an arc using Arcade in Python
The arcade library is a high-tech Python Package with an advanced set of tools for making 2D games with gripping graphics and sound. It is Object-oriented and is specially built for Python 3.6 and above versions.
Arcade has two inbuilt functions for drawing arc:
1: arcade.draw_arc_outline ( ): This function is used to draw an arc which is useful for drawing curved lines
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 .
Let’s see the below example:-
Python3
import arcade
arcade.open_window( 600 , 600 , "Draw an arc for GfG " )
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()
arcade.draw_arc_outline( 150 , 81 , 15 , 36 ,
arcade.color.BLACK, 90 , 360 )
arcade.finish_render()
arcade.run()
|
Output:
2: arcade.draw_arc_filled( ): This function is used to draw a arc filled with color which are useful for drawing pie-wedges, or Pac-Man.
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.
Let’s take an example to get a clear picture of the functionality.
Python3
import arcade
arcade.open_window( 600 , 600 , "Draw an arc for GfG " )
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()
arcade.draw_arc_filled( 150 , 144 , 85 , 86 ,
arcade.color.BOTTLE_GREEN, 90 , 360 , 45 , 54 )
arcade.finish_render()
arcade.run()
|
Output:
Last Updated :
03 Nov, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...