abstract_art_creator.py

Created by wperez274

Created on January 12, 2022

2.04 KB

Random Art Auto. key [+]/[-] = Increase / Decrease size.


from math import *
from kandinsky import *
from kandinsky import fill_rect as fill 
from ion import *
from time import *
from random import *

clear=False

def clear_s():
  global bg
  fill_rect(2,2,317,218,bg)

p_dir=randint(1,4)

left=False
right=False

bg=(randint(100,255),randint(100,255),randint(100,255))

x=100
y=100
w=10
h=10
eye_size=round(w/5)

clock=0

c1=(randint(0,125),randint(0,125),randint(0,125))
c2=(255,0,0)

fill_rect(2,2,317,218,bg)
fill_rect(0,0,322,2,"red")
fill_rect(0,220,322,2,"red")
fill_rect(0,0,2,222,"red")
fill_rect(319,0,2,222,"red")

while 1:
  clock+=1
  fill_rect(x,y,round(clock/2),round(clock/2),(round(clock),round(clock),round(clock)))
  #fill_rect(x+2,y+2,eye_size,eye_size,"cyan")
  fill_rect(x+w,y+h,eye_size,eye_size,"cyan")
  
  fill_rect(x+7,y+2,2,2,"cyan")
  
  if p_dir==1:
    sleep(.005)
    x-=1
    fill_rect(x+w,y,1,h,bg)
  if p_dir==2:
    sleep(.005)
    x+=1
    fill_rect(x-1,y,1,h,bg)
  if p_dir==3:
    sleep(.005)
    y-=1
    fill_rect(x,y+h,w,1,bg)
  if p_dir==4:
    sleep(.005)
    y+=1
    fill_rect(x,y-1,w,1,bg)
  
  if p_dir==5:
    sleep(.005)
    x-=1
    y-=1
    fill_rect(x+w,y,1,h,bg)
  if p_dir==6:
    sleep(.005)
    x+=1
    y-=1
    fill_rect(x+w,y,1,h,bg)
  if p_dir==7:
    sleep(.005)
    x-=1
    y+=1
    fill_rect(x+w,y,1,h,bg)
  if p_dir==8:
    sleep(.005)
    x+=1
    y+=1
    fill_rect(x+w,y,1,h,bg)
            
  if keydown(KEY_OK):
    sleep(0.05)
    p_dir=randint(1,8)
  
  if x<2:
    x=2
    p_dir=choice([2,3,4])
  if x+w>318:
    x=318-w
    p_dir=choice([1,3,4])
  if y<2:
    y=2
    p_dir=choice([1,2,4])
  if y+h>219:
    y>222
    p_dir=choice([1,2,3]) 
  if clock>randint(50,150):
    p_dir=choice([1,2,3,4,5,6,7,8])
    clock=0 
  if keydown(KEY_PLUS):
    fill_rect(0,0,322,222,bg)
    w+=1
    h+=1
    eye_size+=1
    

  if keydown(KEY_MINUS):
    fill_rect(0,0,322,222,bg)
    w-=1
    h-=1
    eye_size-=1
  if keydown(KEY_BACKSPACE):
    sleep(0.02)
    fill_rect(2,2,317,218,bg)

  if keydown(KEY_ANS):
    draw_string(str(eye_size),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.