Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Draw an arc using Arcade in Python
Next article icon

Creating a radar sweep animation using arcade in Python

Last Updated : 19 Oct, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

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 arcade  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  RADIANS_PER_FRAME = 0.02  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.     on_draw.angle += RADIANS_PER_FRAME          # 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.      arcade.start_render()          # Draw the radar line     arcade.draw_line(CENTER_X, CENTER_Y, x, y,      arcade.color.OLIVE, 4)          # Draw the outline of the radar     arcade.draw_circle_outline(CENTER_X, CENTER_Y,      SWEEP_LENGTH, arcade.color.DARK_GREEN, 10)    # 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     arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT,      SCREEN_TITLE)     arcade.set_background_color(arcade.color.BLACK)          # Tell the computer to call the draw command at     # the specified interval.     arcade.schedule(on_draw, 1 / 80)          # Run the program     arcade.run()          #  close the window.     arcade.close_window()    main()
The radar sweep will looks like this -

Complete source code:

Python3
import arcade import math  # Set up the constants SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 SCREEN_TITLE = "Radar Sweep Example"  # These constants control the particulars  # about the radar CENTER_X = SCREEN_WIDTH // 2 CENTER_Y = SCREEN_HEIGHT // 2 RADIANS_PER_FRAME = 0.02 SWEEP_LENGTH = 250   def on_draw(_delta_time):      # Move the angle of the sweep.     on_draw.angle += RADIANS_PER_FRAME      # Calculate the end point of our radar sweep. Using math.     x = SWEEP_LENGTH * math.sin(on_draw.angle) + CENTER_X     y = SWEEP_LENGTH * math.cos(on_draw.angle) + CENTER_Y      # Start the render.     arcade.start_render()      # Draw the radar line     arcade.draw_line(CENTER_X, CENTER_Y, x, y, arcade.color.OLIVE, 4)      # Draw the outline of the radar     arcade.draw_circle_outline(CENTER_X, CENTER_Y, SWEEP_LENGTH,                                arcade.color.DARK_GREEN, 10)   on_draw.angle = 0   def main():      # Open up our window     arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)     arcade.set_background_color(arcade.color.BLACK)      # Tell the computer to call the draw command at the specified interval.     arcade.schedule(on_draw, 1 / 80)      # Run the program     arcade.run()      # close the window.     arcade.close_window()  main() 

Output:


Next Article
Draw an arc using Arcade in Python

P

pulkitagarwal03pulkit
Improve
Article Tags :
  • Python
  • Python-Arcade
Practice Tags :
  • python

Similar Reads

  • Draw a triangle using Arcade in Python
    Arcade is a Python library that is used for developing 2Dimensional Games. Arcade needs support for OpenGL 3.3+. In the arcade, basic drawing does not require knowledge on how to define functions or classes or how to do loops, simply we have inbuilt functions for drawing primitives. Arcade inbuilt f
    2 min read
  • Draw a tree using arcade library in Python
    Drawing a tree isn't a tough task in Python using the turtle module. But, what if you can draw it using Arcade Module as well. Arcade is an object-oriented library. It can be installed like any other Python Package using an import arcade. Approach: Import arcade.Define a function to draw trees. Here
    3 min read
  • 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
    2 min read
  • 3D Modeling & Animation App Using Python
    In recent times, Python has become widely recognized as a potent language for a variety of uses beyond the traditional realm of software development. One such domain is 3D modeling and animation, where Python's flexibility and user-friendly nature can be exploited to develop strong applications. Thi
    9 min read
  • Draw a circle using Arcade in Python3
    The arcade library is a high-tech Python Package with advanced set of tools for making 2D games with gripping graphics and sound. It is Object-oriented and is especially built for Python 3.6 and above versions. Arcade inbuilt functions to draw circle :- 1. arcade.draw_circle_outline( ) : This functi
    3 min read
  • Python | Animation in Kivy using .kv file
    Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, Linux, and Windows, etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications. Animation: Animation and AnimationTransition are used to anima
    3 min read
  • Create an Animated GIF Using Python Matplotlib
    In this article, we will discuss how to create an animated GIF using Matplotlib in Python. Matplotlib can be used to create mathematics-based animations only. These can include a point moving on the circumference of the circle or a sine or cosine wave which are just like sound waves. In Matplotlib w
    3 min read
  • MoviePy – Creating Animation Using Matplotlib
    In this article we will see how we create animations in MoviePy using matplotlib. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Video is formed by the frames, combination of frames creates a video each frame is an individual image. Matplotl
    3 min read
  • Draw a sun using arcade library Python
    You might have drawn Sun using famous Python module like turtle but here we discuss how the same approach can be achieved using arcade module. 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 libra
    2 min read
  • How to show a timer on screen using arcade in Python3?
    Prerequisite: Arcade library Arcade is a modern framework, which is used to make 2D video games. In this, article, you will learn how to show an on-screen timer using the arcade module of Python. Displaying a timer on screen  is not tough job, just follow the below steps:- Step 1: First of all impor
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences