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])

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.