sierpinski.py

Created by gianfranco-oddenino

Created on September 16, 2019

142 Bytes

This script draws an approximation of the Sierpinski triangle using the logical conjunction on Cartesian coordinates interpreted as binary numbers. If the result of x & y is 0, the pixel is left blank, otherwise the result is used as the background color.


from kandinsky import *

for x in range(320):
  for y in range(222):
    c = x & y 
    if c:
      set_pixel(x, y, (0,0,c))