embroidery.py

Created by gianfranco-oddenino

Created on July 09, 2018

227 Bytes

The script draws a different embroidery depending on the value of n passed as a parameter. Prime numbers provide more complex structures. Numbers that have 2 as a divisor have less complexity and a smaller periodicity. The values of n must be between 1 and 255.


from math import *
from kandinsky import *

# try n = 1 ... 255
def draw(n=1):
  draw_string(str(n),136,56)
  for x in range(128):
    for y in range(128):
      c=(x*x+y*y)*n
      set_pixel(x,y,color(c,c,c))