Python Turtle Art – How to draw

In this tutorial, we will learn How to draw an art with the help of the Python Turtle and we will also cover different examples related to Turtle Art. And, we will cover these topics.

  • Python Turtle Art
  • Python Turtle Pixel Art
  • Python Turtle Art Code
  • Python Turtle Art Example

Python Turtle Art

In this section, we will learn how to draw an art with the help of a turtle in a python turtle.

Before moving forward, we should have a piece of knowledge about art. Art is a skill of drawing beautiful shapes, pictures, etc. Turtle art is the same as normal art.

Code:

In the following code, we import the turtle library from turtle import *, import turtle as tur we define some function and draw beautiful art with the help of a turtle.

  • ws.speed(100) is used to manage the speed of the turtle.
  • ws.color(“pink”) is used to give the color to shapes.
  • ws.shape(“turtle”) is used to give the turtle shape.
from turtle import *
import turtle as tur 

def petal1(t1, r, ang):
    for i in range(2):
        t1.circle(r, ang)
        t1.left(180 - ang)
        
def flower1(t1, n, r, ang):
    for i in range(n):
        petal1(t1, r, ang)
        t1.left(360.0 / n)
        
def move(t1, len):
    win = tur.Screen()
    win.bgcolor("cyan")
    t1.pu()
    t1.fd(len)
    t1.pd()
    
ws = tur.Turtle()
ws.speed(100)

ws.color("pink")
ws.shape("turtle")
move(ws, -150)
ws.begin_fill()
flower1(ws, 7, 50.0, 50.0)
ws.end_fill()

ws.color("blue")
move(ws, 150)
ws.begin_fill()
flower1(ws, 9, 20.0, 60.0)
ws.end_fill()

ws.color("green")
move(ws, 150)
ws.begin_fill()
flower1(ws, 13, 60.0, 40.0)
ws.end_fill()

tur.mainloop()

Output:

After running the above code, we get the following output in which we see some shapes are drawn which show a beautiful turtle art.

Python turtle art
Python turtle art Output

Read: Draw colored filled shapes using Python Turtle

READ:  How NumPy Filter 2D Array by Condition in Python [6 Methods]

Python Turtle Pixel Art

In this section, we will learn how to draw Turtle Pixel Art in python turtle.

Pixel art is a digital art form that is created through the use of software and images are edited at the pixel level.

Code:

In the following code, we create a screen inside the screen we draw pixel art with the background color “white“. And also get some knowledge about the pixel of the picture.

  • turtle.Screen() is used for creating a screen.
  • ws.bgcolor(“white”) is used for giving white background color.
  • ws.speed(6) is used for giving the normal speed to the turtle.
  • ws.forward(30) is used for moving the turtle in the forward direction.
from turtle import *
import turtle

ws=turtle.Screen()
ws.bgcolor("white")
ws=turtle.Turtle()
ws.speed(6)
ws.pensize(5)
def square():
  for a in range(6):
    ws.forward(30)
    ws.right(90)

def tetris_piece():
  for a in range(6):
   ws.begin_fill()
   square()
   ws.color("cyan")
   ws.end_fill()
   ws.color("black")
   ws.forward(30)
   
tetris_piece()

ws.penup()
ws.forward(90)
ws.pendown()

Output:

After running the above code, we get the following output in which we see pixel art is shown on the screen.

Python turtle pixel art
Python turtle pixel art Output

Read: How to Create a Snake game in Python using Turtle

Python Turtle Art Code

In this section, we will learn about how to create an art code in Python turtle.

An Art code is any art that is used for building a code. By creating a code we draw an art with the help of a turtle.

Code:

In the following code, we create a screen inside the screen we draw art that attracts the people’s eye.

  • import turtle is a library used to draw art.
  • ws.bgcolor(“black”) is used to give the background color.
  • sk.color(“cyan”) is used to give the color to the turtle.
from turtle import *
import turtle 
ws = turtle.Screen()
ws.bgcolor("black")
sk = turtle.Turtle()
sk.color("cyan")

def squarefunc(size):
	for i in range(4):
		sk.fd(size)
		sk.left(90)
		size = size + 6

squarefunc(7)
squarefunc(27)
squarefunc(47)
squarefunc(67)
squarefunc(87)
squarefunc(107)
squarefunc(127)
squarefunc(147)

Output:

READ:  NumPy Reverse Array in Python [6 Methods]

After running the above code we get the following output in which we see a beautiful art is drawn with background-color”black”.

Python turtle art code
Python turtle art code Output

Read: How to attach an image in Turtle Python

Python Turtle Art Example

In this section, we will learn about Turtle Art Example in Python turtle.

As we know Turtle Art is the skill of drawing beautiful shapes, pictures, etc. In Turtle Art, we can drag and drop the images from any software and website.

Code:

In the following code, we import the turtle library for drawing art on the screen.

  • painting.pencolor(“red”) is used for giving the color to the pen.
  • painting.forward(60) is used for moving the turtle in the forward direction.
  • painting.left(133) is used for moving the cursor in a clockwise direction.
from turtle import *
import turtle 

painting = turtle.Turtle()

painting.pencolor("red")

for x in range(60):
    painting.forward(60)
    painting.left(133)
    
painting.pencolor("blue")
for x in range(60):
    painting.forward(100)
    painting.left(133)
    
turtle.done()

Output:

After running the above code, we get the following output in which we see turtle art is drawn with two beautiful colors.

Python turtle art example
Python turtle art example Output

Also, take a look at some more tutorials related to Python Turtle.

So, in this tutorial, we discussed Python Turtle Art and we have also covered different examples related to its implementation. Here is the list of examples that we have covered.

  • Python Turtle Art
  • Python Turtle Pixel Art
  • Python Turtle Art Code
  • Python Turtle Art Example