Posts

Showing posts from October, 2023

Amazing Design on Python turtle

Image
  import turtle turtle . setup ( width = 600 , height = 900 ) turtle . reset () turtle . hideturtle () turtle . speed ( 0 ) turtle . bgcolor ( 'black' ) c = 0 x = 0 colors = [     ( 1.00 , 0.00 , 0.00 ), ( 1.00 , 0.03 , 0.00 ), ( 1.00 , 0.05 , 0.00 ), ( 1.00 , 0.07 , 0.00 ),     ( 1.00 , 0.10 , 0.00 ), ( 1.00 , 0.12 , 0.00 ), ( 1.00 , 0.15 , 0.00 ), ( 1.00 , 0.17 , 0.00 ),     ( 1.00 , 0.20 , 0.00 ), ( 1.00 , 0.23 , 0.00 ), ( 1.00 , 0.25 , 0.00 ), ( 1.00 , 0.28 , 0.00 ),     ( 1.00 , 0.30 , 0.00 ), ( 1.00 , 0.33 , 0.00 ), ( 1.00 , 0.35 , 0.00 ), ( 1.00 , 0.38 , 0.00 ),     ( 1.00 , 0.40 , 0.00 ), ( 1.00 , 0.42 , 0.00 ), ( 1.00 , 0.45 , 0.00 ), ( 1.00 , 0.47 , 0.00 ),     ( 1.00 , 0.50 , 0.00 ), ( 1.00 , 0.53 , 0.00 ), ( 1.00 , 0.55 , 0.00 ), ( 1.00 , 0.57 , 0.00 ),     ( 1.00 , 0.60 , 0.00 ), ( 1.00 , 0.62 , 0.00 ), ( 1.00 , 0.65 , 0.00 ), ( 1.00 , 0.68 , 0.00 ),     ( 1.00 , 0.70 , 0.00 ), ( 1.00 , 0.72 , 0.00 ), ( 1.00 , 0.75 , 0.00 ), ( 1.00 , 0.78 , 0.00 ),     ( 1.0

Python Heart Animation

Image
  import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * import math def draw_heart(): glBegin(GL_TRIANGLES) for i in range(0, 360, 1): theta1 = math.radians(i) theta2 = math.radians(i + 1) x1 = 16 * math.sin(theta1) ** 3 y1 = 13 * math.cos(theta1) - 5 * math.cos(2 * theta1) - 2 * math.cos(3 * theta1) - math.cos(4 * theta1) z1 = 0 x2 = 16 * math.sin(theta2) ** 3 y2 = 13 * math.cos(theta2) - 5 * math.cos(2 * theta2) - 2 * math.cos(3 * theta2) - math.cos(4 * theta2) z2 = 0 x3 = 0 y3 = 0 z3 = -20 # Depth of the heart shape # Assign colors based on sections of the heart shape if i < 90: glColor3f(1, 0, 0) # Red color for the top section elif i < 180: glColor3f(0, 1, 0) # Green color for the left section elif i < 270: glColor3f(0, 0, 1) # Blue color for