random_art.py

Created by ferr0fluidmann

Created on September 18, 2018

619 Bytes

Type scribble(), press enter, and watch the color-show.


from math import *
from random import *
from kandinsky import *

def scribble():
  x = [0,320,160]
  y = [0,0,221]
  c = [
    color(255,0,0),
    color(0,255,0),
    color(0,0,255)]
  
  while 1:
    for i in range(len(x)):
      xm=randint(-1,1)
      ym=randint(-1,1)
      if x[i]<=0:
        x[i]+=1
      elif x[i]>=320:
        x[i]-=1
      else:
        x[i]+=xm
      if y[i]<=0:
        y[i]+=1
      elif y[i]>=221:
        y[i]-=1
      else:
        y[i]+=ym
      col = get_pixel(x[i],y[i])
      if col==color(255,255,255):
        col=color(0,0,0)
      set_pixel(x[i],y[i],col|c[i])