Beispiel #1
0
def make_layer():
    x = layers.Noise(8).add(layers.Constant(0.6)).clamp()
    x = x.translate(random.random() * 1000, random.random() * 1000)
    x = x.scale(0.25, 0.25)
    x = x.power(1.5)
    # x = x.subtract(layers.Distance(W / 2, H / 2, min(W, H) / 2, 4))
    return x
Beispiel #2
0
def find_path(layer, points, threshold):
    x = layers.Noise(4).add(layers.Constant(0.6)).clamp()
    x = x.translate(random.random() * 1000, random.random() * 1000)
    x = x.scale(0.01, 0.01)
    g = graph.make_graph(points, threshold, x)
    end = max(points, key=lambda p: layer.get(*p))
    points.sort(key=lambda p: math.hypot(p[0] - end[0], p[1] - end[1]))
    for start in reversed(points):
        path = graph.shortest_path(g, end, start)
        if path:
            return path
Beispiel #3
0
def make_layer():
    x = layers.Noise(8).add(layers.Constant(0.6)).clamp()
    x = x.translate(random.random() * 1000, random.random() * 1000)
    x = x.scale(0.005, 0.005)
    x = x.subtract(layers.Distance(256, 256, 256))
    return x