cool.py

Created by mathieu-croslacoste

Created on September 15, 2025

1.77 KB

just a satisfying script. Mode 1 generate normal squares, Mode 2 is more satisfing but slower as the squares grow in size. Submode 1 generate squares of growing size and then loop back, while Submode 2 is random. The delay time is the pause time in miliseconds after a square is drawn. ok to clear screen, keep shift pressed to stop.


from math import *
from kandinsky import *
from ion import *
from random import *
from time import *

print("mode ? (1 or 2)")
mode=int(input())
while mode!=1 and mode!=2:
  print("must be 1 or 2")
  mode=int(input())
print("submode ? (1 or 2)")
submode=int(input())
while submode!=1 and submode!=2:
  print("must be 1 or 2")
  submode=int(input())
print("delay time ? (in miliseconds)")
delay=int(input())/1000
draw_string("COOL ?",130,20,color(200,50,200),color(255,255,255))
draw_string("[EXE] to start,",94,50,color(200,50,200),color(255,255,255))
draw_string("keep [shift] down to stop,",42,80,color(200,50,200),color(255,255,255))
draw_string("[OK] to reset.",100,110,color(200,50,200),color(255,255,255))
while not keydown(52): pass
while keydown(52): pass
fill_rect(0,0,330,230,color(0,0,0))
if mode==1:
  while not keydown(KEY_SHIFT):
    for y in range(15,50):
      if submode==1:
        fill_rect(randint(0,330),randint(0,230),y,y,color(randint(0,255),randint(0,255),randint(0,255)))
      else:
        x=randint(15,50)
        fill_rect(randint(0,330),randint(0,230),x,x,color(randint(0,255),randint(0,255),randint(0,255)))
      sleep(delay)
      if keydown(4):
        fill_rect(0,0,330,230,color(0,0,0))  
else:  
  while not keydown(KEY_SHIFT):
    for y in range(20,50):
      a=randint(y*2-20,620)
      b=randint(y*2-20,420)
      c=randint(1,256)
      d=randint(1,256)
      e=randint(1,256)
      if submode==1:
        for z in range(1,y):
          fill_rect(a//2-z//2,b//2-z//2,z,z,color(c-z*2,d-z*2,e-z*2))
          sleep(0.001)
      else:
        x=randint(20,50)
        for z in range(1,x):
          fill_rect(a//2-z//2,b//2-z//2,z,z,color(c-z*2,d-z*2,e-z*2))
          sleep(0.001)
      sleep(delay)
      if keydown(4):
        fill_rect(0,0,330,230,color(0,0,0))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.