A lot of video calling software like Zoom and Google Hangouts now let users use a virtual background behind them. In this project, we'll show you how to make your own virtual background graphic in Python with Turtle that you can use in your video calls!
In this walkthrough, we will be drawing flowers on the screen, but you could do anything you would like to with your Python Turtle. We’ll look at how to set colors, add randomness, and more.
Who is this project for?
This project falls under our Juni Python Level 1 coding class for kids. This beginner Python with Turtle tutorial is for students that want a easy/medium challenge project, about ~50 lines long. You should review functions, loops, and drawing basic shapes with Python Turtle beforehand to get the most out of this project.
For learning outcomes, you'll get a lot of practice with functions and loops. This project is estimated to take you about 15 minutes, but you should move faster or slower at your own pace!
Before getting started, see how our finished project works for reference. Watch the video, or click run to see the project yourself!
You can also view my project solution code if you get stuck.
What to keep in mind before you start:
Consider how the shape of a flower can be drawn using different shapes.
Steps to Code the Project:
- Plan out how you'd draw a flower.
- Draw a petal.
- Draw a flower.
- Draw the scene.
How do we do each of these steps?
Step 1: First off, we’ll begin by thinking about how we can draw a flower.
- What are the key parts of drawing a flower? The most accentuated portion of the flower could be their colorful petals. Let’s draw a flower’s petals together–you can add on a stem, center, and more if you would like.
Step 2: Draw a petal.
- Let’s begin by drawing a petal. We can start with half of a petal. What does it look like?
- One way to think about half a petal is that it looks like it is a cut-off top piece of a circle.
- We can therefore combine two of these cut-off pieces at their edges, creating a petal!
- For a visual explanation, check out the video!
- We can use the
turtle.circle(radius, extent)function in order to draw a circle with that radius, and drawn to that "extent", a value from 0 to 360 – e.g. 60 would draw 1/6th of the circle, as 60/360 = 1/6.
Step 3: Draw a flower.
- We then take our petal, and make it into a function to draw it as many times as we want!
- We should therefore make the code to draw a petal into a function, so we can reuse it and make sure that our code stays consistent.
- Once we have the function to draw the petals, how do we draw the entire flower?
- We can draw petals that all go out from the same point, with small rotations in between our petals. We can also calculate how much we need to rotate via 360 /
numPetalsto figure out how much we need to rotate before moving on.
- We can also randomize color, radius, and number of petals to draw a random flower each time the function is called!
Step 4: Draw the scene.
- We can color the background by using a special turtle named a
Screen– this allows us to do
screenTurtle.bgcolor("light blue"), for instance. If you want more custom colors, you can also use RGB values to select a specific color!
- We can start by drawing a couple of flowers in random areas with random sizes and color.
Challenge Yourself with Extra Features
- Play around with the
.circle(radius, extent)function and see what happens!
- If you like having shapes in a certain area of the image, you can use the functions we defined to put them in specific locations.
- Try your entirely own kind of background image!
Great job! Check out more coding tutorials.
Thanks for watching and hope you had fun making this project with me! Every week, we’ll be posting project tutorials like this one, for different coding languages and experience levels, as well as math tutorials.
Check out our step-by-step coding projects to find our other tutorials in Python and more coding languages!
Need more help, or want to keep learning?
Looking up your coding questions is one of the best ways to learn! Another great way to learn is from an experienced coder or instructor.
Juni Learning Coding Instructors like Gabriel work closely with students ages 8-18, and are specially trained to adapt to each child's unique learning style, pace, and interests.