Pythondex
Turtle Python Programs

Python Program To Draw Hulk

Published August 29, 2023 by Jarvis Silva

The Incredible Hulk one of the most powerful and dangerous character from the MCU and it is one of my favourite character so today I will show you how to create a python program to draw hulk.

Drawing hulk in python is not an easy job so we will use pywhatkit and turtle library in python they will help us draw hulk in python so before moving forward make sure to install them both.

Command to install pywhatkit


pip install pywhatkit

Command to install turtle


pip install turtle

Use the above commands to install both the libraries, Now create a new folder and a python file for this program and now let’s see the code.

Python code to draw the Hulk


from pywhatkit import image_to_ascii_art as sac
import turtle as t 

pic = 'hulk.jpg'
text = "hulk"        
sac(pic, text)


a_x = -170              
a_y = 350

p = t.Pen()
t.setup(430,768)
t.bgcolor('black')
p.speed(45)
p.up()
p.width(3)
f_n = 0
d_n = 4

def set_color(c):
    sym = {".": 'green', "S" : 'black', "#" : 'black', "&" : 'black', "@":'black', "$" : 'black', "%" : 'black', "!":'black', ":" :'black', "*":'black'}
    color = sym[c]
    p.pencolor(color)

def b(n, a_sym):
     p.up()
     if a_sym != '\n':
         set_color(a_sym)

     p.goto(a_x- n, a_y )
     p.down()
     p.forward(1)

text = open('hulk.txt','r')
te = text.readlines()
for i in te:
    for j in i:
        b(f_n, j)
        f_n -= 4
    a_y -= 8
    a_x = -170    
    f_n = 0
    d_n = 4

t.done()

Above is the complete python code for drawing the hulk, If you take a look at the code we have used turtle and image to ascii function from pywhatkit this function will take a image and print it in ascii form.

So we give that function a image of hulk then it generates a ascii txt file of that image and it is then rendered using turtle module, You can download the image I have used for this program below:

After downloading the image move it in your program folder and add the name of the file in the pic variable, Now you can run this program and it will open a new window and start drawing hulk, Below is the final output of this program.

Hulk Drawing edited

As you can see we successfully drawn hulk using python programming, I hope you found this program interesting and amazing, we have more drawing programs like this you will find interesting below are some of them:

Thank you for reading, Have a nice day 🙂