This file contains hidden or 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 python.less9.mrcm import * | |
from python.less9.transformations import rotation | |
_size = 300 | |
sierp_transformations = [[np.identity(3) for x in range(3)], | |
[rotation(90), np.identity(3), rotation(-90)], | |
[rotation(180), np.identity(3), rotation(180)], | |
[rotation(-90), np.identity(3), rotation(90)], | |
[np.identity(3), rotation(180), np.identity(3)], |
This file contains hidden or 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 copy | |
import numpy as np | |
from python.common.point import Point | |
from python.common.svg import Svg | |
from python.less9.transformations import scaling | |
def star(size, iterations=1000): |
This file contains hidden or 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 copy | |
from python.common.point import Point | |
from python.common.svg import Svg | |
from python.less9.transformations import * | |
def fern(size, iterations): | |
transformations = [np.matrix([[0.849, 0.037, 0.075], | |
[-0.037, 0.849, 0.183], |
This file contains hidden or 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 copy | |
from math import sqrt | |
from python.common.polygon import Polygon | |
from python.common.polygon_group import PolygonGroup | |
from python.common.svg import Svg | |
from python.less9.transformations import * | |
def triangle(size, origin=False): | |
pol = Polygon([(0, 0), (1, 0), (0.5, sqrt(3) / 2), (0, 0)]) |
This file contains hidden or 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 python.common.polygon import Polygon | |
from python.common.svg import Svg | |
from python.less9.transformations import * | |
def transform(transformation, polygon, repeats, name="trans"): | |
_svg = Svg() | |
for i in range(repeats): | |
for _line in polygon.lines(): | |
_svg.add_line(_line) |
This file contains hidden or 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 radians, cos, sin | |
import numpy as np | |
def combine(*transformations): | |
result = transformations[0] | |
for transformation in transformations[1:]: | |
result = np.dot(result, transformation) |
This file contains hidden or 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 sys import maxsize | |
from PIL import Image | |
from python.less7.madelbrot import rgb | |
def newt_1(z): | |
return z ** 3 - 1 |
This file contains hidden or 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 sys | |
import math | |
import multiprocessing as mp | |
import time | |
import os | |
from PIL import Image | |
def mandelbrot_p(width, steps=25, zoom=((-2, -1), (1, 1)), c=None, name="fractal.png", number_processes=mp.cpu_count()): |
This file contains hidden or 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
class PolygonGroup: | |
def __init__(self, polygons=None): | |
self.polygons = [] | |
if polygons is not None: | |
self.polygons.extend(polygons) | |
def apply_transformation(self, transformation): | |
list(map(lambda x: x.apply_transformation(transformation), self.polygons)) | |
def draw_to_svg(self, svg): |
This file contains hidden or 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 numpy as np | |
from python.common.line import Line | |
class Polygon: | |
def __init__(self, points=None): | |
self.points = [] | |
if points is not None: | |
self.points.extend(points) |