Arcade inbuilt functions to draw point(s) in Python3
Last Updated :
05 Oct, 2021
The Arcade library is a modern Python Module used widely for developing 2D video games with compelling graphics and sound. Arcade is an object-oriented library. It can be installed like any other Python Package.
In this article, we will learn what are the arcade inbuilt functions to draw point.
Arcade library is a modern framework, which makes drawing illustrations very easily through its inbuilt functions. In the arcade, we have two inbuilt functions to draw point.
1. arcade.draw_point( ): It is used to draw a point and you can even draw multiple points using this function by calling it as many times you want to.
Syntax: arcade.draw_point(x , y, color , size)
Parameters:
- x – is position of point.
- y -is position of point.
- Color – specify color using arcade.color.COLOR NAME. (Note that color name should in Capital letters.)
- Size – Size of the point in pixels.
Approach For drawing a point using arcade.draw_point:
- Import Arcade module
- Open the window and Set the window parameters.
- Set the background color of the output window.(optional)
- Start the render process
- Implement arcade.draw_point() with its specified parameters.
- Finish rendering
- Keep the window up until you close it.
Program 1: (Program to draw a single point)
Python3
import arcade
arcade.open_window( 600 , 600 , "Draw a point for GfG " )
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()
arcade.draw_point( 60 , 495 , arcade.color.RED, 10 )
arcade.finish_render()
arcade.run()
|
Output:
Program 2: (Program to draw multiple points)
Python3
import arcade
arcade.open_window( 600 , 600 , "Draw a point for GfG " )
arcade.set_background_color(arcade.color.BLUE)
arcade.start_render()
arcade.draw_point( 60 , 495 , arcade.color.RED, 10 )
arcade.draw_point( 80 , 500 , arcade.color.YELLOW, 10 )
arcade.finish_render()
arcade.run()
|
Output:
2. arcade.draw_points ( ): With this function, it is easier to draw multiple points that to in a particular pattern.
Syntax: arcade.draw_points(point_list , color , size)
Parameters:
- point_list – It is basically list of points where each point is in a list. So it is a list of lists.
- Color -specify color using arcade.color.COLOR NAME. (Note that color name should in Capital letters.)
- Size– Size of the point in pixels.
Program:
Python3
import arcade
arcade.open_window( 600 , 600 , "Draw a point for GfG " )
arcade.set_background_color(arcade.color.ORANGE)
arcade.start_render()
point_list = (( 165 , 495 ),
( 165 , 480 ),
( 165 , 465 ),
( 195 , 495 ),
( 195 , 480 ),
( 195 , 465 ))
arcade.draw_points(point_list, arcade.color.GREEN , 10 )
arcade.finish_render()
arcade.run()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...