
Introduction
Messi and Ronaldo, the dynamic duo of modern football, never fail to ignite excitement when they grace the field together. Their popularity knows no bounds, and as a devoted fan of both players, I’ve always wanted to add a touch of fun to my admiration.
Recently, an idea came to mind. I decided to bring Messi and Ronaldo to digital life through Python programming by creating their portraits. In this tutorial, I’ll guide you on how to draw colourful sketch of Messi vs Ronaldo using the Python Turtle module.
So, stay with me till the end, follow each step closely, and let’s bring these two football legends to code-fueled life!
👉Read Also: Creating a Colorful Sketch of Messi Using a Python Code
How does the Program work?
Well, for the starter, we will need a good-quality photo of Lionel Messi and Ronaldo. Since our program will give a cartoon outcome, converting the chosen image into a cartoon is necessary. You can use many tools available online or, for an extra dose of Python fun, try out our Python application to effortlessly cartoonize an image (Convert an image to a cartoon using Python OpenCV).
Now, we need to find out every single x-y coordinates of the face elements (eyes, ears, hair, nose, nostril, chin, face outline, etc.) from the image. But, how do we achieve this feat, you wonder? I’ve employed a Python program to achieve this task (Take a peek at – How to Get Coordinates of Clicked Points on an Image).
But the adventure doesn’t end there. Now, we need to store the coordinates of each face element in several text files with a corresponding name. Once all the files are ready, Our trusty turtle, imported into the Python program, will gracefully follow these plotted points, bringing the face to life stroke by stroke.
Lastly, we need to choose different colors for different facial features to make the sketch more gorgeous. These colors will fill the sketch while the turtle will be drawing.
If you’re curious about how the shades I’ve chosen from the image, there’s an online tool at your service — visit ImageResizer.com/color-picker. It offers to find out the RGB value of colors by selecting that (color) from an image.
I’ve generated a sum of 47 text files containing lists of coordinates, essential for drawing a colorful portrait of Messi and Ronaldo. The program relies on these files for proper execution. To get these files, please refer to the following sections.
Setting Up the Environment
Make sure that Python is installed on your system. You can download it from the Python official site (https://www.python.org/). Now install a module called `sketchpy` using the following command:
pip install sketchpy
Download the provided zip file and extract its contents. Within the unzipped folder, create three Python program files named messi.py
, ronaldo.py
, and main.py
.
You are now prepared to start coding.
Import the modules
In the main.py, import the `canvas` from the `sketchpy` module.
from sketchpy import canvas
Create an object
Now create an object of `canvas.sketch` class with the name `Turtle`.
Turtle = canvas.sketch(x_offset=290, y_offset=320)
messi.py
Copy and paste the provided code into the messi.py
program file.
def DrawMessi(Turtle): Turtle.draw_fn("outer-face", co=(226, 190, 183), mode=0) Turtle.draw_fn("beard-&-hair", co=(42, 42, 39), mode=0) Turtle.draw_fn("hair-shade1", co=(42, 42, 39), mode=0) Turtle.draw_fn("lips", co=(188, 154, 146), mode=0) Turtle.draw_fn("lips-reddish", co=(91, 16, 21), mode=0) Turtle.draw_fn("nostril", co=(7, 1, 2), mode=0) Turtle.draw_fn("nose-shade1", co=(146, 63, 60), mode=0) Turtle.draw_fn("right-eyebrow", co=(80, 44, 36), mode=0) Turtle.draw_fn("left-eyebrow", co=(79, 45, 36), mode=0) Turtle.draw_fn("upper-eye-shade", co=(19, 8, 7), mode=0) Turtle.draw_fn("front-eye-shade", co=(92, 46, 14), mode=0) Turtle.draw_fn("scelra", co=(252, 252, 253), mode=0) Turtle.draw_fn("eye-ball", co=(40, 20, 16), mode=0) Turtle.draw_fn("ear-outer-part", co=(241, 217, 199), mode=0) Turtle.draw_fn("inner-ear1", co=(58, 26, 19), mode=0) Turtle.draw_fn("inner-ear2", co=(186, 143, 121), mode=0) Turtle.draw_fn("inner-ear3", co=(186, 143, 121), mode=0) Turtle.draw_fn("inner-ear4", co=(186, 143, 121), mode=0) Turtle.draw_fn("inner-ear5", co=(150, 93, 76), mode=0) Turtle.draw_fn("inner-ear6", co=(226, 157, 154), mode=0) Turtle.draw_fn("throat", co=(207, 172, 163), mode=0) Turtle.draw_fn("beard-shade1", co=(174, 156, 142), mode=0) Turtle.draw_fn("beard-shade2", co=(98, 77, 60), mode=0) Turtle.draw_fn("t-shirt", co=(20, 79, 126), mode=0)
In the code above, we called the draw_fn
function twenty-four (24) times. Each call sketches the outline of individual face elements, utilizing the coordinates presented in the text files.
ronaldo.py
Similarly, paste the given code into the ronaldo.py
program file.
def DrawRonaldo(Turtle): Turtle.draw_fn("r-outer-face", co=(212, 170, 130), mode=0) Turtle.draw_fn("r-hair", co=(37, 28, 23), mode=0) Turtle.draw_fn("r-ear-outer", co=(193, 131, 86), mode=0) Turtle.draw_fn("r-ear-shade1", co=(55, 39, 34), mode=0) Turtle.draw_fn("r-ear-shade2", co=(60, 14, 3), mode=0) Turtle.draw_fn("r-ear-shade3", co=(99, 26, 10), mode=0) Turtle.draw_fn("r-eyebrow", co=(15, 10, 8), mode=0) Turtle.draw_fn("r-eye-outer-scelra", co=(106, 46, 27), mode=0) Turtle.draw_fn("r-scelra", co=(221, 221, 223), mode=0) Turtle.draw_fn("r-eyeball", co=(3, 1, 0), mode=0) Turtle.draw_fn("r-nostril", co=(16, 3, 2), mode=0) Turtle.draw_fn("r-nose-shade1", co=(164, 110, 55), mode=0) Turtle.draw_fn("r-lips", co=(133, 62, 41), mode=0) Turtle.draw_fn("r-mouth", co=(6, 3, 1), mode=0) Turtle.draw_fn("r-jacket", co=(94, 10, 4), mode=0) Turtle.draw_fn("r-face-shade1", co=(127, 80, 52), mode=0) Turtle.draw_fn("r-face-shade2", co=(165, 112, 63), mode=0) Turtle.draw_fn("r-eye-shade1", co=(106, 47, 5), mode=0) Turtle.draw_fn("r-forhead-shade1", co=(165, 114, 52), mode=0) Turtle.draw_fn("r-face-shade3", co=(198, 144, 106), mode=0)
Return to main.py
Having successfully created separate program files for Messi and Ronaldo to replicate their drawings, it’s time to call both of them in the main program file. Before that, ensure to import messi.py
and ronaldo.py
. Additionally, import the time
module for the sleep function.
import messi as lm10 import ronaldo as cr7 import time
Initially, we wrote a few lines of code within the main.py
program file. Now add the following code at the end.
lm10.DrawMessi(Turtle) cr7.DrawRonaldo(Turtle)
At this point, our program can successfully draw portraits of Messi and Ronaldo. To enhance the rivalry, add two more lines to include ‘vs’ between them.
Turtle.draw_fn("v", co=(213, 61, 75), mode=0) Turtle.draw_fn("s", co=(213, 61, 75), mode=0)
Include a sleep function to introduce a 5-second delay in program execution at the end.
time.sleep(5)
The main program is now ready to execute and it appears exactly as shown below:
from sketchpy import canvas import messi as lm10 import ronaldo as cr7 import time Turtle = canvas.sketch(x_offset=290, y_offset=320) lm10.DrawMessi(Turtle) cr7.DrawRonaldo(Turtle) Turtle.draw_fn("v", co=(213, 61, 75), mode=0) Turtle.draw_fn("s", co=(213, 61, 75), mode=0) time.sleep(5)
Output

Summary
In this tutorial, we crafted a colorful of Messi vs Ronaldo using Python Code. We previously stored a total of 47 text files that contain the coordinates of the face elements, and our program files must need these text files.
In the program, we employed the sketchpy
module that further uses the Python Turtle to trace the coordinates and draw each face segment and other elements. You can easily get those files through the Download button provided before.
For more lovely Python topics, explore our dedicated page exclusively designed for Cool Python Programs. Below are a few examples to spark your interest:
- How to Blink Caps Lock using Python Code
- Expressing I Love You in Python Code
- Wish Happy Birthday🎂 in Python Code
If you have any burning questions about this topic? Don’t be shy—drop them in the comments below! I’m here and ready to help you out.
Happy Sketching!