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 a happy face using Arcade Library in Python
Next article icon

Draw a tree using arcade library in Python

Last Updated : 15 Nov, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

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, we are drawing a pine tree made up of a rectangle and a triangle. So, you can use the inbuilt arcade function to rectangle and triangle.
def draw_tree(x, y):     # Draw the triangle on top of the trunk    arcade.draw_triangle_filled(x + 40, y,                                x, y - 100,                                x + 80, y - 100,                                arcade.color.DARK_GREEN)    # Draw the trunk    arcade.draw_lrtb_rectangle_filled(x + 30, x + 50, y - 100, y - 140,                                      arcade.color.DARK_BROWN)
  • Now, since we have defined the function to tree, let’s define the main function and under which define arcade.open_window() to specify the screen width, height, and title. Also, use arcade.start_render() and arcade.finish_render to instruct arcade module when to start and stop drawing. Finally, add the arcade.run() to specify the ending.
def main():    # Open the window    arcade.open_window(600, 600,"TREE")    arcade.set_background_color(arcade.color.SKY_BLUE)     # Start the render process.     arcade.start_render()     # Call our drawing functions.    draw_tree(50, 250)     # Finish the render.    arcade.finish_render()     # keep the window up .    arcade.run()    main()

 Example 1:

Python3




import arcade
 
 
def draw_tree(x, y):
 
    # Draw the triangle on top of the trunk
    arcade.draw_triangle_filled(x + 40, y,
                                x, y - 100,
                                x + 80, y - 100,
                                arcade.color.DARK_GREEN)
 
    # Draw the trunk
    arcade.draw_lrtb_rectangle_filled(x + 30, x + 50, y - 100, y - 140,
                                      arcade.color.DARK_BROWN)
 
 
def main():
 
    # Open the window
    arcade.open_window(600, 600, "TREE")
    arcade.set_background_color(arcade.color.SKY_BLUE)
 
    # Start the render process.
    arcade.start_render()
 
    # Call our drawing functions.
    draw_tree(50, 250)
 
    # Finish the render.
    arcade.finish_render()
 
    # Keep the window up.
    arcade.run()
 
 
main()
 
 

Output:

Example 2: 

Python3




#import module
import arcade
 
# specify spacing
Column_spacing = 20
Row_spacing = 20
Left_margin = 110
Bottom_margin = 400
 
# Open the window and set the background
arcade.open_window(700, 700, "BOX")
 
# set background color
arcade.set_background_color(arcade.color.BABY_PINK)
 
# Start the render process. This must be done before any drawing commands.
arcade.start_render()
 
# Loop for each row
for row in range(8):
    # Loop for each column
    for column in range(8):
        # Calculate our location
        x = column * Column_spacing + Left_margin
        y = row * Row_spacing + Bottom_margin
 
        # Draw the item
    arcade.draw_triangle_filled(x + 40, y,
                                x, y - 100,
                                x + 80, y - 100,
                                arcade.color.DARK_GREEN)
 
arcade.draw_lrtb_rectangle_filled(x + 30, x + 50, 300, 230,
                                      arcade.color.DARK_BROWN)
 
# Finish the render.
arcade.finish_render()
 
# Keep the window up until someone closes it.
arcade.run()
 
# This code is contributed by pulkitagarwal03pulkit
 
 

Output:-



Next Article
Draw a happy face using Arcade Library in Python

A

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

Similar Reads

  • 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
  • Draw an ellipse using Arcade library in Python
    Prerequisite: Arcade Library The Arcade library is a modern Python Module used for developing 2D video games with enthralling graphics and sound. It is an object-oriented library. It can be installed like any other Python Package in your IDE. Arcade Module has two inbuilt functions for drawing an el
    3 min read
  • 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 happy face using Arcade Library in Python
    Arcade is a Python module used for developing 2D games. For drawing a happy face, steps are as follows: Import arcade library.import arcade Open the window.arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) The function used with arcade is open_window. This command opens a window with a g
    3 min read
  • Draw a parabola using Arcade in Python3
    Arcade is a Python library which is used for developing 2Dimensional Games. Arcade needs support for OpenGL 3.3+. In 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 func
    3 min read
  • Binary Tree using dstructure library in Python
    The dstructure package is a Python library for dealing with data structure and algorithm. In this article, we will discuss how we can implement a binary tree and perform various operations using the dstructure library in Python. Installation To install dstructure open the terminal and write the belo
    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
  • Arcade Library in Python
    For many years, Python game programmers were limited to the Pygame Module. But, now we have other choices as well i.e Arcade Python Library. 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
    4 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
  • Draw Chess Board Using Turtle in Python
    Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. For drawing Ches
    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