Exemplo n.º 1
0
def draw():
    background(0.95, 0.95, 0.95, 1.0)
    color(0, 0, 0, 1)

    border = 50
    border_sQ = border * 2
    num_lines = 18
    y_step = float((height - border_sQ) / num_lines)
    x_step = float((width - border_sQ) / num_lines)
    y_offset = y_step / 2.0
    x_offset = x_step / 2.0
    un_offset = 10
    my_lines = []

    for i in range(num_lines):
        for j in range(num_lines - 1):
            if j == 0:
                p1 = vec2([
                    x_step * j + x_offset +
                    random.uniform(-x_offset, x_offset) + border, y_step * i +
                    y_offset + random.uniform(-y_offset, y_offset) + border
                ])
                p2 = vec2([
                    x_step * (j + 1) + x_offset +
                    random.uniform(-x_offset, x_offset) + border, y_step * i +
                    y_offset + random.uniform(-y_offset, y_offset) + border
                ])
                my_lines.append(Line(p1[0], p1[1], p2[0], p2[1]))
            else:
                p1 = vec2([
                    my_lines[(j + (num_lines - 1) * i) - 1].p1[0],
                    my_lines[(j + (num_lines - 1) * i) - 1].p1[1]
                ])
                p2 = vec2([
                    x_step * (j + 1) + x_offset +
                    random.uniform(-x_offset, x_offset) + border, y_step * i +
                    y_offset + random.uniform(-y_offset, y_offset) + border
                ])
                my_lines.append(Line(p1[0], p1[1], p2[0], p2[1]))

    index = 0
    for i in range(num_lines):
        index = index + 1
        for j in range(num_lines - 1):
            if i != 0:
                lerp_lines = int(map(i, 0, num_lines, 1, 12)) + 1
                for k in range(lerp_lines):
                    p0 = my_lines[(j + (num_lines - 1) * (i - 1))].get_lerp(
                        math.pow(map(k, 0, lerp_lines - 1, 0, 1), 1))
                    p1 = my_lines[(j + (num_lines - 1) * i)].get_lerp(
                        math.pow(map(k, 0, lerp_lines - 1, 0, 1), 1))
                    Line(p0[0], p0[1], p1[0], p1[1]).draw()
                    stroke()

    for line in my_lines:
        line.draw()
        stroke()
Exemplo n.º 2
0
def draw():
    background(0.95, 0.95, 0.95, 1.0)
    color(0, 0, 0, 0.01)

    for k in range(100):
        step = 100 / 4
        for j in range(0, width + 100, 100):
            for i in range(0, height + 100, 100):
                r = randint(-4, 4)
                offset_x = step / r if r != 0 else 0
                r = randint(-4, 4)
                offset_y = step / r if r != 0 else 0
                Circle(i + offset_x, j + offset_y, 10)
                stroke()
def draw():
    background(0.95, 0.95, 0.95, 1.0)
    color(0, 0, 0, 1)

    grid_x, grid_y = 1, 1
    x_step, y_step = width//grid_x, height//grid_y
    x_offset, y_offset = x_step//2, y_step//2

    n_loop = []
    offset = []
    num_layers = 40
    s = (x_offset // num_layers)

    for xxx in range(grid_x):
        for yyy in range(grid_y):
            center_x = xxx * x_step + x_offset
            center_y = yyy * y_step + y_offset
            for layer in range(num_layers):
                offset = random.randint(0, 360)
                n_loop.append(NoiseLoop(map(layer, 0, num_layers, 1, 4), s*layer, s*layer+s))
                num_points = 360
                for i in range(num_points):
                    r = n_loop[layer].get_value(i)
                    x = r * math.cos(math.radians(i)) + center_x
                    y = r * math.sin(math.radians(i)) + center_y
                    # Think of a better way to do this
                    config.Context.line_to(x, y)
                config.Context.close_path()
                stroke()

                if layer != 0:
                    num_lines = map(layer, 0, num_layers, 16, 2)
                    num_points = 360 / num_lines
                    for i in range(int(num_points)):
                        r = n_loop[layer].get_value(i*num_lines+offset)
                        x = r * math.cos(math.radians(i*num_lines+offset)) + center_x
                        y = r * math.sin(math.radians(i*num_lines+offset)) + center_y

                        r = n_loop[layer-1].get_value(i*num_lines+offset)
                        xx = r * math.cos(math.radians(i*num_lines+offset)) + center_x
                        yy = r * math.sin(math.radians(i*num_lines+offset)) + center_y
                        Line(xx, yy, x, y)
                        stroke()
Exemplo n.º 4
0
def draw():
    background(0.95, 0.95, 0.95, 1.0)
    color(0, 0, 0, 1)

    connector_lines = []

    num_lines_x = 20
    num_lines_y = 3
    x_step = float((width - 100) // num_lines_x)
    y_step = float(height // num_lines_y)
    x_offset = (x_step // 2) + 50
    y_offset = y_step // 2

    for h in range(num_lines_y):
        for i in range(num_lines_x):
            x = x_step * i + x_offset
            y = y_step * h + y_offset
            yy = random.randint(25, 100)
            p0 = vec2([
                x + random.uniform(-(x_step // 2) + 10, (x_step // 2) + 10),
                random.uniform(y - 50, y + 50) + yy
            ])
            p1 = vec2([
                x + random.uniform(-(x_step // 2) + 10, (x_step // 2) + 10),
                random.uniform(y - 50, y + 50) - yy
            ])
            connector_lines.append(Line(p0[0], p0[1], p1[0], p1[1]))

            if i != 0:
                num_lines = 21
                l1 = i + num_lines_x * h
                l2 = (i + num_lines_x * h) + 1

                while l2 == l1:
                    l2 = random.randint(0, len(connector_lines))

                for j in range(num_lines + 1):
                    p0 = connector_lines[l1 - 1].get_lerp(
                        math.pow(map(j, 0, num_lines, 0, 1), 1))
                    p1 = connector_lines[l2 - 1].get_lerp(
                        math.pow(map(j, 0, num_lines, 0, 1), 1))
                    Line(p0[0], p0[1], p1[0], p1[1])
                    stroke()
Exemplo n.º 5
0
 def draw(self):
     color(0.15, 0.15, 0.15, 1)
     draw_line(self.p0[0], self.p0[1], self.p1[0], self.p1[1])
     stroke()
Exemplo n.º 6
0
 def draw(self):
     if self.draw_stroke is not False:
         line_width(0.9)
         Line(self.lx, self.ly, self.x, self.y)
         stroke()
Exemplo n.º 7
0
def draw():
    # Draw stuff here
    background(0.95, 0.95, 0.95, 1.0)
    color(0, 0, 0, 1.0)
    Circle(width * 0.5, height * 0.5, 250)
    stroke()
 def draw(self):
     color(0.0, 0.0, 0.0, 1.0)
     draw_line(self.p0[0], self.p0[1], self.p1[0], self.p1[1])
     stroke()