Docsity

come fare un cuore animato in Python, Guide, Progetti e Ricerche di Informatica

Anteprima parziale del testo

Scarica come fare un cuore animato in Python e più Guide, Progetti e Ricerche in PDF di Informatica solo su Docsity!

( Chat IMINIO) (iS Federica Quaglia (Tu) © @ heart.py import turtle import math # Functions to calculate x and y coordinates for the heart shape def hearta(k): return 15 * math.sin(k) +* 3 def heartb(k): return 12 * math.cos(k) - 5 x math.cos(2 * k) -— 2 * math.cos(3 x k) - math.cos(4 * k) # Set up the window window = turtle.Screen() window, setup(800, 600) window. bgcolor("black") up the tle turtle. Turtle() range(6000) : ì * 10 # Scale i to a small step for smoothness (1) * 20 # Scale the heart shape (i) + 20 .gotolx, y) amic color based on ‘i' abs(math.sin(i x 300)) abs(math.sin(i + 200)) abs(math.sin(i x 100)) .pencolor(r, 9g, b) ndown() # Writing the text "Calsom", 24, "cursive"))