Categories: Turtle

Turtle Rotating Rectangles

Drawing Rotating Rectangles

Here is another Python turtle example showing how to edit the background color of turtle screen and how to use RGB mode.

This example can give you a good understanding of RGB channels in images.

Here is a simply code that uses requests, json and webbrowser libraries:

import turtle
import random

x = 1
SN = turtle.Screen()
SN.bgcolor("gray")
a = turtle.Turtle()
a.speed(100)

i = 0
while x < 256:

    r = random.randint(0,255)
    g = 100
    b = 150
    
    turtle.colormode(255)
    a.pencolor(i,g,b)
    if x<252:
        a.pensize(1)
        a.forward(50 + x)
        a.right(91.5)
       
    x = x+1
    i = (i+1)%255    

turtle.done()   

Code below will print a bunch of other information regarding cocktails such as: Instructions and Ingredients and it will also open the cocktail image in a browser.

import turtle

a = turtle.Turtle()
for i in range(240):
    a.forward(2+i/4)
    a.left(30-i/12)

turtle.done()

If you need a refresher on Python Turtle, here is a link to our Python Turtle lesson.

Usag1r

Share
Published by
Usag1r

Recent Posts

Benefits of Bokeh over Python visualization libraries like Seaborn, Matplotlib & Plotly

ContentsIntroductionBokeh vs Seaborn & MatplotlibBokeh vs PlotlySummary Introduction As computer science activity booms, you might…

11 months ago

History of Speech-to-Text AI models

History of Speech-to-Text Models​ & Current Infrastructure As speech technology continues to advance, so too…

1 year ago

Advanced Level Python Tips & Tricks

Python Tips & Tricks (Part III) Advanced Level HolyPython.com Here are more Python tips about…

1 year ago

Intermediate Level Python Tips & Tricks

Python Tips & Tricks (Part II) Intermediate Level HolyPython.com The list continues with slightly more…

1 year ago

When is Python 4 Coming Out?

Almost 15 years after the release of Python 3 many people are wondering when Python…

2 years ago

How to Create an app with a 3D model using VIKTOR

Introduction We are going to need smart engineering solutions to solve our planet's problems (and…

2 years ago