Esempio n. 1
0
    def change_colorset(self, new_colorset, transition_time=10.):
        old_colorset = self.colors
        t0, t1 = self.t, self.t + transition_time
        v0, v1 = 0, max(len(new_colorset), len(old_colorset)) + 1

        t_fun = create_linear_transition_fun(v0, v1, t0, t1)
        t_fun_round = lambda t: round(t_fun(t))
        self.color_fun = lambda t: new_colorset[:t_fun_round(
            t)] + old_colorset[t_fun_round(t):]
Esempio n. 2
0
def scene_size_with_scale():
    colorset = chinskie
    # colorset = to_zdjecie
    random.seed(12)
    random.shuffle(colorset)
    # colorset = chinskie
    # r = Rhombus(200, 200, 100, 200)
    x, y = 400, 400
    rhombus_list = []
    p_fun = lambda t: sin(t / 8) * 50 + 100
    q_fun = lambda t: sin(t / 4) * 100 + 300
    # p_fun = lambda t: 300
    q_fun = lambda t: 300
    p_fun = lambda t: 200
    f = create_smooth_transition_fun(1., 7.4, 0., 15)
    f2 = create_smooth_transition_fun(7.4, 1, 20, 30)

    # scale_time_fun = lambda t: ((cos(t/4) * 3. + 3.5), (400, 650))
    def scale_time_fun(t):
        if t < 15:
            return f(t), (450, 450)
        else:
            return f2(t), (450, 450)

    # scale_time_fun = lambda t: (f(t), (450, 450))
    # scale_time_fun = None

    scale_size_fun = create_linear_transition_fun(0., 1., 0, 20000)
    x_s = [150, 450, 750]
    y_s = [100, 300, 500, 700]
    rs_lvl_1 = []

    for x, y in itertools.product(x_s, y_s):
        rs_lvl_1.append(RhombusFractal(x, y, p_fun, q_fun, colorset))

    rs_lvl_2 = []
    for r in rs_lvl_1:
        rs_lvl_2 += r.get_objects_down()
    rs_lvl_3 = []
    for r in rs_lvl_2:
        rs_lvl_3 += r.get_objects_down()
    for r in rs_lvl_2:
        rs_lvl_3 += r.get_objects_down()

    rhombus_list = rs_lvl_1 + rs_lvl_2 + rs_lvl_3
    for r in rhombus_list:
        r.scale_size_fun = scale_size_fun
        r.scale_time_fun = scale_time_fun
    s = Scene(rhombus_list, bg_color=colorset[1])
    output_dir = 'out/movie_2/scene_scale_3'
    # output_dir = None
    s.animate(0.05, output_dir=output_dir, save_range=(0, 900))
Esempio n. 3
0
def scene_1_1():
    colorset = chinskie
    # colorset = schiele_1
    # random.shuffle(colorset)
    # r = Rhombus(200, 200, 100, 200)
    x, y = 1960 / 2, 1080 / 2
    rhombus_list = []
    fun_q = lambda t: 400
    fun_p2 = lambda t: -sin((t * pi)) * 90. + 200
    # fun_p2 = lambda t: pow(2, cos(t / 2 + (pi / 2.))) * 90. + 308
    fun_p = lambda t: (sin((t * pi*2))) * 90. + 300





    pos = get_rhombus_tiling_positions(x, y)
    # fun_reverse_in = [1,2,7,8,9,10]
    border_squares = [0, 1, 2, 3, 5, 6, 9, 10, 12, 13, 14, 15]
    inside_squares = 4, 7, 8, 11
    for i, (x_r, y_r) in enumerate(pos):
        if i in inside_squares:
            fp, fq = fun_p2, fun_q
        else:
            fp, fq = fun_p, fun_q
        rhombus_list.append(RhombusFractal(x_r, y_r, fp, fq, colorset))

    scale_size_fun = create_linear_transition_fun(0., 1., 0, 30000)
    scale_t_fun = create_smooth_transition_fun(.2, 1., 0., 12., slope_param=3)
    scale_time_fun = lambda t: (scale_t_fun(t), None)
    for r in rhombus_list:
        r.scale_time_fun = scale_time_fun
        r.scale_size_fun = scale_size_fun

    # r4 = RhombusFractal(400+300/4, 400, (300/2.)*(3./5.), 300/2, colorset)
    # s = Scene([r1,r2,r3, r4], bg_color=colorset[0])
    s = Scene(rhombus_list, bg_color=colorset[1], img_size=(1920, 1080))
    output_dir = 'out/movie_2/scene_1_1'


    output_dir = None
    files = glob.glob('{}/*'.format(output_dir))

    if output_dir:
        for f in files:
            os.remove(f)
    s.animate(1 / 60, output_dir=output_dir, save_range=(0, 60 * 16))
Esempio n. 4
0
def scene_3_2():
    colorset = chinskie
    # colorset = schiele_1
    # random.shuffle(colorset)
    x, y = 1960 / 2, 1080 / 2
    rhombus_list = []
    fun_q = lambda t: 400
    f_down = create_smooth_transition_fun(1, 0, 0, 5, slope_param=3)
    fun_p2 = lambda t: 200
    fun_p = lambda t: 300

    pos = []
    pos += get_rhombus_tiling_positions(x + 1600, y)
    pos += get_rhombus_tiling_positions(x - 1600, y - 1600)
    pos += get_rhombus_tiling_positions(x + 1600, y + 1600)
    pos += get_rhombus_tiling_positions(x + 2400, y + 800)

    border_squares = [0, 1, 2, 3, 5, 6, 9, 10, 12, 13, 14, 15]
    inside_squares = 4, 7, 8, 11
    f1 = create_smooth_transition_fun(1, 1.5, 0., 4., slope_param=16)
    f2 = create_smooth_transition_fun(1.5, 2.5, 4, 8, slope_param=16)
    f3 = create_smooth_transition_fun(2.5, 5, 8, 12)

    def f_s(t):
        # print(t)
        if t < 4:
            return f1(t)

        elif 4 <= t < 8:
            return f2(t)
        else:
            return f3(t)

    f_t_x = create_smooth_transition_fun(-2000, -2000, 0, 2.5)
    f_t_y = create_smooth_transition_fun(-1000, -1000, 0, 2.5)
    translations_fun = lambda t: (f_t_x(t), f_t_y(t))

    rec_center_pos = x, y
    ft_scale = lambda t: (f_s(t), (x, y))

    for i, (x_r, y_r) in enumerate(pos):
        if i in inside_squares:
            fp, fq = fun_p2, fun_q
        else:
            fp, fq = fun_p, fun_q

        if i < 16 * 5:
            colorset = chinskie
            # random.seed(2197)

            # colorset = random.sample(chinskie, len(chinskie))
        else:
            # colorset = blue_crystal_vienna
            colorset = random.sample(chinskie, len(chinskie))
        rhombus_list.append(
            RhombusFractal(x_r, y_r, fp, fq, colorset, debug=False))

    # del rhombus_list[52]
    rhombus_list[58].colorset = chinskie
    lv2 = rhombus_list[58].get_objects_down(
    ) + rhombus_list[52].get_objects_down()

    lv3 = []
    for r in lv2:
        lv3 += r.get_objects_down()

    lvls_down = lv2 + lv3
    scale_size_fun = create_linear_transition_fun(0., 1., 0, 30000)
    for r in lvls_down:
        r.scale_size_fun = scale_size_fun

    rhombus_list += lvls_down

    for r in rhombus_list:
        r.scale_time_fun = ft_scale
        r.translations_fun = translations_fun

    s = Scene(rhombus_list, bg_color=chinskie[1], img_size=(1920, 1080))
    output_dir = 'out/movie_2/scene_3_2'
    # output_dir = None

    files = glob.glob('{}/*'.format(output_dir))

    if output_dir:
        for f in files:
            os.remove(f)
    dt = 1 / 60
    # dt = 0.1
    s.animate(dt, output_dir=output_dir, save_range=(0, 60 * 16))
Esempio n. 5
0
def scene_3_1_5():
    x, y = 1960 / 2, 1080 / 2
    rhombus_list = []
    fun_q = lambda t: 400
    fun_p2 = lambda t: 200
    fun_p = lambda t: 300

    pos = []
    pos += get_rhombus_tiling_positions(x + 1600, y)
    pos += get_rhombus_tiling_positions(x - 1600, y - 1600)
    pos += get_rhombus_tiling_positions(x + 1600, y + 1600)
    pos += get_rhombus_tiling_positions(x + 2400, y + 800)

    f_t_x = create_smooth_transition_fun(-2000, -2000, 0, 2.5)
    f_t_y = create_smooth_transition_fun(-1000, -1000, 0, 2.5)
    translations_fun = lambda t: (f_t_x(t), f_t_y(t))

    for i, (x_r, y_r) in enumerate(pos):

        fp, fq = fun_p, fun_q

        if i < 16 * 5:
            colorset = chinskie
            # random.seed(2197)
            # colorset = random.sample(chinskie, len(chinskie))
        else:
            # colorset = blue_crystal_vienna
            colorset = random.sample(chinskie, len(chinskie))
        rhombus_list.append(
            RhombusFractal(x_r, y_r, fp, fq, colorset, debug=False))

    down_index_list = [58, 52, 53]
    lv2 = []
    for ind in down_index_list:
        lv2 += rhombus_list[ind].get_objects_down()
    #lv2 = [rhombus_list[ind].get_objects_down() for ind in down_index_list]

    # lv2 = rhombus_list[58].get_objects_down() + rhombus_list[52].get_objects_down()
    # lv2= []
    # lv3 = []
    # for r in lv2:
    #    lv3 += r.get_objects_down()

    lvls_down = lv2
    scale_size_fun = create_linear_transition_fun(0., 1., 0, 30000)
    scale_t_fun = create_smooth_transition_fun(1., 1., 0., 4., slope_param=3)
    scale_time_fun = lambda t: (scale_t_fun(t), None)
    for r in lvls_down:
        r.scale_time_fun = scale_time_fun
        r.scale_size_fun = scale_size_fun

    rhombus_list += lvls_down
    for r in rhombus_list:
        # r.scale_time_fun = scale_time_fun
        r.translations_fun = translations_fun

    s = Scene(rhombus_list, bg_color=chinskie[1], img_size=(1920, 1080))
    output_dir = 'out/movie_2/scene_3_1_5'
    output_dir = None

    files = glob.glob('{}/*'.format(output_dir))

    if output_dir:
        for f in files:
            os.remove(f)
    dt = 1 / 60
    # dt = 0.1
    s.animate(dt, output_dir=output_dir, save_range=(0, 60 * 8))