# Creating a radar sweep animation using arcade in Python

The Radar Sweep are used for displays of single level sweeps of radar data, and their display appears in the Main Display window. With the help of arcade module of Python, it is possible to perform a radar sweep animation. Before starting, it is highly recommended to revise concepts of arcade library.

To perform a radar sweep animation, follow the below steps:-

Step 1: Import arcade as well math module in you respective Ide.

import math

Step 2: Specify the parameters for the output window.

# Set up the constants
WIDTH = 800
_HEIGHT = 600
TITLE = "Radar Sweep"

Step 3: These constants control the particulars about the radar.

CENTER_X = SCREEN_WIDTH // 2
CENTER_Y = SCREEN_HEIGHT // 2
SWEEP_LENGTH = 250

Step 4: Define a on_draw function, under which move the angle of the sweep and calculate the end point of our radar sweep, using math . Lastly draw the outline of the radar.

def on_draw(_delta_time):
# Move the angle of the sweep.

# Calculate the end point of our radar sweep.
x = SWEEP_LENGTH * math.sin(on_draw.angle) + CENTER_X
y = SWEEP_LENGTH * math.cos(on_draw.angle) + CENTER_Y

# Start the render.

# Draw the radar line
arcade.draw_line(CENTER_X, CENTER_Y, x, y,

# Draw the outline of the radar

# This is a function-specific variable i.e
# we need to give them initial
# values.
on_draw.angle = 0

Step 5: Define main function.

def main():

# Open up our window
SCREEN_TITLE)

# Tell the computer to call the draw command at
# the specified interval.
arcade.schedule(on_draw, 1 / 80)

# Run the program

#  close the window.
main()

The radar sweep will looks like this –

Complete source code: