This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import izip, product | |
import wx | |
BITS = 6 | |
SIZE = int(((2 ** BITS) ** 3) ** 0.5) | |
STEP = 2 ** (8 - BITS) | |
def color_func(color): | |
r, g, b = color | |
r, g, b = 0.30 * r, 0.59 * g, 0.11 * b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx | |
class View(wx.Panel): | |
def __init__(self, parent): | |
super(View, self).__init__(parent) | |
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) | |
self.Bind(wx.EVT_SIZE, self.on_size) | |
self.Bind(wx.EVT_PAINT, self.on_paint) | |
self.Bind(wx.EVT_CHAR_HOOK, self.on_char) | |
self.bitmap = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import wx | |
SIZE = 4096 | |
LOOKUP = [ | |
[0, 1, 4, 5, 2, 3, 6, 7], | |
[1, 0, 5, 4, 3, 2, 7, 6], | |
[2, 3, 6, 7, 0, 1, 4, 5], | |
[3, 2, 7, 6, 1, 0, 5, 4], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sin, cos, radians | |
import cairo | |
import random | |
import re | |
class System(object): | |
def __init__(self, rules): | |
self.rules = rules | |
self.pattern = re.compile('|'.join('(%s)' % x for x in rules)) | |
def step(self, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sin, cos, tan, pi, atan2 | |
import cairo | |
import random | |
COLORS = [ | |
0x477984, | |
0xEEAA4D, | |
0xC03C44, | |
0xFEF5EB, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tile import Model, Shape | |
def normalize(x, y): | |
return (round(x + 3.5, 6), round(y + 3.5, 6)) | |
def create_model(): | |
model = Model(width=700, height=700, scale=100) | |
model.append(Shape(6)) | |
a = model.add(0, range(6), 4) | |
b = model.add(a, 1, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import hypot, atan2, sin, cos, pi, radians | |
import cairo | |
import colorsys | |
import random | |
class Model(object): | |
def __init__(self): | |
self.particles = [] | |
def add(self, x, y, m=1.0): | |
self.particles.append((x, y, m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import pi, sin, cos, hypot, floor | |
import cairocffi as cairo | |
import random | |
R = 0.012 | |
class Grid(object): | |
def __init__(self, r): | |
self.r = r | |
self.size = r / 2 ** 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import pi, sin, cos, hypot, floor | |
from pyhull.voronoi import VoronoiTess | |
from shapely.geometry import Polygon | |
import cairocffi as cairo | |
import colorsys | |
import random | |
R = 0.02 | |
FILL = 0x422B36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split(values, func): | |
group = [] | |
previous = None | |
for value in values: | |
if previous and func(previous, value): | |
yield group | |
group = [] | |
group.append(value) | |
previous = value | |
if group: |
OlderNewer