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

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.