Пример #1
0
def example():
    draw = Draw(scale=80)
    offsets = list(
        map(
            float,
            "0.04885131 0.38705046 0.15540683 0.37524718 0.09360688 0.04554864 0.0424169"
            .split(" ")))
    grid = Multigrid(7, offsets)
    index_range = (-4, 4)
    plot_grid(grid, draw, *index_range)
    plot_intersections(grid, draw, *index_range)
    draw.show()
Пример #2
0
def plot_intersections(grid: Multigrid, draw: Draw, i1: int, i2: int):
    points = grid.calculate_intersections((i1, i2))
    for g1, g2 in triangle_iterator(grid.N):
        if 0 in (g1, g2) or 1 in (g1, g2):
            if 0 in (g1, g2) and 1 in (g1, g2):
                # continue
                color = "white"
            else:
                # continue
                color = "blue"
        else:
            # continue
            color = "red"
        for index in np.ndindex(points.shape[2:-1]):
            x, y, z = points[(g1, g2, *index)]
            draw.point(x, y, color=color)
Пример #3
0
def main():
    palette = ["#fa26a0", "#fff591", "#3b2e5a"]

    draw = Draw(scale=160,
                width=3 * 1280,
                height=3 * 1280,
                bg_color=palette[-1])
    draw.line_color = None
    index_range = (-8, 8)
    grid = multigrid.Pentagrid()
    L.info("Grid base: {}".format(list(grid.base_offset.flatten())))
    tiling_builder = TilingBuilder(grid)
    tiling_builder.prepare_grid(index_range)
    tiling_builder.generate_rhomb_list()

    for rhomb in tiling_builder._rhombs.values():
        c = int(rhomb.type() in (2, 3))
        draw.polygon(rhomb.xy(form="xy1"), color=palette[c])
        for a, b in rhomb.get_edges():
            draw.edge(a.get_xy(), b.get_xy(), color=palette[-1], width=8)

    draw.show()
Пример #4
0
def plot_grid(grid: Multigrid, draw: Draw, i1: int, i2: int):
    for g in range(grid.N):
        lines = grid.get_line_group(g, (i1, i2))
        for line in lines:
            draw.norm_line(line)
Пример #5
0
import multigrid
from ntiling import TilingBuilder
from drawing.pil_draw_simple import Draw

palette = [
    "#ffee7d",
    "#b767ff",
    "#44fadd",
    "#ffe0f7",
    "#fe91ca",
]
draw = Draw(scale=110, width=3 * 1280, height=3 * 1280, bg_color=palette[-2])
draw.line_color = None
index_range = (-3, 3)
grid = multigrid.Multigrid(17)
tiling_builder = TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

for rhomb in tiling_builder._rhombs.values():
    new = []
    for a, b in rhomb.get_edges():
        new.append((a.get_xy() + b.get_xy()) / 2)
    p1 = new[-1]
    for p2 in new:
        draw.edge(p2[:2], p1[:2], color=palette[-1], width=8)
        p1 = p2

draw.show()
Пример #6
0
import multigrid
from ntiling import TilingBuilder
from drawing.pil_draw_simple import Draw

palette = [
    "#7fb414",
    "#fac70b",
    "#127681",
    "#df0e62",
    "#21174a",
]
draw = Draw(scale=150, width=3 * 1280, height=3 * 1280, bg_color=palette[-1])
draw.line_color = None
index_range = (-2, 2)
grid = multigrid.Multigrid(9)
tiling_builder = TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

for rhomb in tiling_builder._rhombs.values():
    col = (rhomb.type() in (4, 5, 3, 6, 2, 7)) + (rhomb.type() in (
        3, 6, 2, 7)) + (rhomb.type() in (2, 7))
    if col != 0:
        new = []
        for a, b in rhomb.get_edges():
            new.append((a.get_xy(form="xy1") + b.get_xy(form="xy1")) / 2)
        # coords = rhomb.center(form="xy")
        draw.polygon(new, color=palette[col])
    else:
        draw.polygon(rhomb.xy(form="xy1"), color=palette[col])
Пример #7
0
import multigrid
import ntiling
from drawing.pil_draw_simple import Draw

draw = Draw(scale=140, width=3*1280, height=3*1280, bg_color="#fff591")
draw.line_color = None
index_range = (-7, 7)
grid = multigrid.Pentagrid()
tiling_builder = ntiling.TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

palette = [
    "#fa26a0",
    "#fff591",
    "#3b2e5a"
]

for rhomb in tiling_builder._rhombs.values():
    c = rhomb.type() in (2, 3)
    draw.polygon(rhomb.xy(form="xy1"), color=palette[c])
    for a, b in rhomb.get_edges():
        draw.edge(a.get_xy(form="xy"), b.get_xy(form="xy"), color=palette[-1], width=8)

draw.show()
Пример #8
0
import multigrid
from ntiling import TilingBuilder
from drawing.pil_draw_simple import Draw

palette = [
    "#293462",
    "#216583",
    "#00818a",
    "#f7be16",
]
draw = Draw(scale=90, width=3 * 1280, height=3 * 1280, bg_color=palette[-2])
draw.line_color = None
index_range = (-1, 1)
grid = multigrid.Multigrid(23)
tiling_builder = TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

for rhomb in tiling_builder._rhombs.values():
    for a, b in rhomb.get_edges():
        draw.edge(a.get_xy(homogenous=False),
                  b.get_xy(homogenous=False),
                  color=palette[-1],
                  width=4)

draw.show()
Пример #9
0
import numpy as np

import multigrid
import ntiling
from drawing.pil_draw_simple import Draw

palette = [
    "#222831",
    "#393e46",
    "#ffd369",
    "#eeeeee",
    # "#000000"
]

draw = Draw(scale=200, width=3 * 1280, height=3 * 1280, bg_color=palette[-2])
draw.line_color = None
index_range = (-6, 6)
grid = multigrid.Pentagrid()
tiling_builder = ntiling.TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

radius = (1 * np.sin(np.pi / 5) / 2.3, 1 * np.sin(np.pi / 5 * 2) / 2.3)

for rhomb in tiling_builder._rhombs.values():
    c = rhomb.type() in (2, 3)
    if not c:
        draw.polygon(rhomb.xy(form="xy1"), color=palette[-1])
    else:
        draw.polygon(rhomb.xy(form="xy1"), color=palette[c])
        for a, b in rhomb.get_edges():
Пример #10
0
import colorsys
import numpy as np

import multigrid
import ntiling
from drawing.pil_draw_simple import Draw

draw = Draw(scale=30,
            width=3 * 1280,
            height=3 * 1280,
            bg_color="#ffffff",
            color_mode="RGB")
draw.line_color = None
index_range = (-18, 18)
grid = multigrid.Pentagrid()
tiling_builder = ntiling.TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

# assign a color to each ribbon
base_colors = [colorsys.hsv_to_rgb(1 / 12 * i, 1, 1) for i in range(8, 13)]

# compute colors for each ribbon intersection type
palette = {}
for i, j in multigrid.triangle_iterator(5):
    c = [("0" + hex(int(a))[2:])[-2:] for a in ((
        (np.sqrt(base_colors[i]) + np.sqrt(base_colors[j])) / 2)**2) * 256]
    palette[(i, j)] = "#" + "".join(c)

for rhomb in tiling_builder._rhombs.values():
    c = tuple(rhomb.node[:2])
Пример #11
0
palette = [
    "#ffee7d",
    "#b767ff",
    "#44fadd",
    "#fe91ca",
    "#ffe0f7",
]
# palette = [
#     "#7fb414",
#     "#df0e62",
#     "#127681",
#     "#fac70b",
#     "#092a35",
# ]
draw = Draw(scale=90, width=4 * 1280, height=4 * 1280, bg_color=palette[-1])
draw.line_color = None
index_range = (-4, 4)
offsets = list(
    map(
        float,
        "0.04885131 0.38705046 0.15540683 0.37524718 0.09360688 0.04554864 0.0424169"
        .split(" ")))
grid = multigrid.Multigrid(7, offsets)
# grid = multigrid.Multigrid(7, [0.11071195, 0.40178219, 0.38167641, 0.05840904, 0.26593674, 0.30876262, 0.40169052])
tiling_builder = TilingBuilder(grid)
tiling_builder.prepare_grid(index_range)
tiling_builder.generate_rhomb_list()

for rhomb in tiling_builder._rhombs.values():
    c = (rhomb.type() in (1, 6, 2, 5)) + (rhomb.type() in (1, 6))