Exemplo n.º 1
0
def main():
    """RGB値の仕組みが分かるgifアニメ画像を出力します
    """

    # 連番
    seq = 0

    size = len(BAR_RATES)
    for i in range(0, size):
        bar_rates = BAR_RATES[i]
        tone_name = TONE_NAME[i]

        # 描画:トーン名と バー箱 の紹介
        inner_circle = OuterCircle()
        outer_circle = OuterCircle()
        for _ in range(0, 10):  # Wait frames
            canvas = make_canvas()
            bar_box, _circle_rail, _inner_circle, _outer_circle = make_scene1(
                bar_rates, inner_circle, outer_circle)
            draw_grid(canvas)
            bar_box.draw_outline(canvas)
            bar_box.draw_rank2_box(canvas)
            bar_box.draw_bar_rate_rank2(canvas)  # バー率テキスト
            draw_tone_name(canvas, bar_box, tone_name)
            # 書出し
            canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1

        # 描画:色相環のアニメーション表示
        seq, canvas = make_circle(canvas, seq, bar_rates, tone_name)

        for _ in range(0, 10):  # Wait frames
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1
Exemplo n.º 2
0
def make_circle(canvas, seq, bar_rates, tone_name):
    """色相環一周分の画像を出力"""

    outer_circle = OuterCircle()

    for phase in range(0, PHASE_COUNTS):
        theta = 360/PHASE_COUNTS*phase
        canvas = make_canvas()
        bar_box, circle_rail, outer_circle = make_scene1(
            bar_rates, outer_circle)
        outer_circle.phase = phase

        # 円周上の点の位置
        circle_rail.theta = theta

        # バーR
        bar_box.step1_rect[0].left_top = (
            bar_box.red_left, circle_rail.red_p[1])
        bar_box.step1_rect[0].right_bottom = (
            bar_box.red_left+bar_box.one_width, bar_box.top3)
        # バーG
        bar_box.step1_rect[1].left_top = (
            bar_box.green_left, circle_rail.green_p[1])
        bar_box.step1_rect[1].right_bottom = (
            bar_box.green_left+bar_box.one_width, bar_box.top3)
        # バーB
        bar_box.step1_rect[2].left_top = (
            bar_box.blue_left, circle_rail.blue_p[1])
        bar_box.step1_rect[2].right_bottom = (
            bar_box.blue_left+bar_box.one_width, bar_box.top3)
#        print(
#            f"red={bar_box.step1_rect[0].debug_string} \
# green={bar_box.step1_rect[1].debug_string} \
# blue={bar_box.step1_rect[2].debug_string}")

        bar_box.delta_3bars_height = calc_step2(
            bar_box.create_step1_3bars_height(),
            bar_box.height2
        )

        # 外環状
        theta = outer_circle.phase * outer_circle.unit_arc
        outer_color = convert_3heights_to_3bytes(
            bar_box.create_rank23d_3bars_height(), bar_box.height)
        outer_circle.color_list.append(outer_color)
        #

        draw_grid(canvas)  # 罫線
        bar_box.draw_outline(canvas)  # 箱の輪郭
        canvas = draw_canvas(canvas, bar_box, circle_rail,
                             outer_circle)
        draw_tone_name(canvas, bar_box, tone_name)  # トーン名

        # 書出し
        canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
        cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
        seq += 1

    return seq, canvas
Exemplo n.º 3
0
def update_circle(canvas, seq, vertical_parcent, tone_name):
    """色相環一周分の画像を出力"""

    outer_circle = OuterCircle()

    for phase in range(0, PHASE_COUNTS):
        canvas = make_canvas()
        bar_box, circle_rail, outer_circle, inscribed_triangle, clock_hand = update_scene1(
            vertical_parcent, outer_circle)
        update_scene1_with_rotate(vertical_parcent, phase, bar_box,
                                  circle_rail, outer_circle,
                                  inscribed_triangle, clock_hand)

        draw_grid(canvas)  # 罫線
        bar_box.draw_outline(canvas)  # 箱の輪郭
        canvas = draw_canvas(canvas, bar_box, circle_rail, outer_circle,
                             inscribed_triangle, clock_hand)
        draw_tone_name(canvas, bar_box, tone_name)  # トーン名

        # 書出し
        canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
        cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
        seq += 1

    return seq, canvas
Exemplo n.º 4
0
def main():
    """RGB値の仕組みが分かるgifアニメ画像を出力します
    """

    # 連番
    seq = 0

    for (_, record) in enumerate(L_M_U_NAME_LIST):

        # 描画:トーン名と バー箱 の紹介
        outer_circle = OuterCircle()
        for _ in range(0, 10):  # Wait frames
            canvas = make_canvas()
            bar_rate = (record[0], record[1], record[2])
            bar_box, circle_rail, _outer_circle, _inscribed_triangle, _clock_hand = update_scene1(
                bar_rate, outer_circle)
            draw_grid(canvas)
            circle_rail.draw_circle(canvas)  # 円レール
            draw_border(circle_rail, canvas)  # 背景の上限、下限の線
            bar_box.draw_outline(canvas)
            bar_box.draw_rank2_box(canvas)
            bar_box.draw_bars_rate(canvas)  # バー率テキスト
            draw_tone_name(canvas, bar_box, record[3])
            # 書出し
            canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1

        # 描画:色相環のアニメーション表示
        seq, canvas = update_circle(canvas, seq, bar_rate, record[3])

        for _ in range(0, 10):  # Wait frames
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1
Exemplo n.º 5
0
def main():
    """RGB値の仕組みが分かるgifアニメ画像を出力します
    """

    # 連番
    seq = 0

    size = len(VERTICAL_PARCENT)
    for i in range(0, size):
        vertical_parcent = VERTICAL_PARCENT[i]
        tone_name = TONE_NAME[i]

        # 描画:トーン名と バー箱 の紹介
        outer_circle = OuterCircle()
        for _ in range(0, 10):  # Wait frames
            canvas = make_canvas()
            bar_box, circle_rail, _outer_circle, _inscribed_triangle, _clock_hand = update_scene1(
                vertical_parcent, outer_circle)
            draw_grid(canvas)
            circle_rail.draw_circle(canvas)  # 円レール
            circle_rail.draw_border(canvas)  # 背景の上限、下限の線
            bar_box.draw_outline(canvas)
            bar_box.draw_rank2_box(canvas)
            bar_box.draw_bars_rate(canvas)  # バー率テキスト
            draw_tone_name(canvas, bar_box, tone_name)
            # 書出し
            canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1

        # 描画:色相環のアニメーション表示
        seq, canvas = update_circle(canvas, seq, vertical_parcent, tone_name)

        for _ in range(0, 10):  # Wait frames
            cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
            seq += 1
Exemplo n.º 6
0
def make_circle(canvas, seq, bar_rates, tone_name):
    """色相環一周分の画像を出力"""

    inner_circle = OuterCircle()
    outer_circle = OuterCircle()

    for phase in range(0, PHASE_COUNTS):
        theta = 360 / PHASE_COUNTS * phase
        canvas = make_canvas()
        bar_box, circle_rail, inner_circle, outer_circle = make_scene1(
            bar_rates, inner_circle, outer_circle)
        inner_circle.phase = phase
        outer_circle.phase = phase

        # 円周上の点の位置
        circle_rail.theta = theta

        # バーR
        bar_box.step1_rect[0].left_top = (bar_box.red_left,
                                          circle_rail.red_p[1])
        bar_box.step1_rect[0].right_bottom = (bar_box.red_left +
                                              bar_box.one_width, bar_box.top3)
        # バーG
        bar_box.step1_rect[1].left_top = (bar_box.green_left,
                                          circle_rail.green_p[1])
        bar_box.step1_rect[1].right_bottom = (bar_box.green_left +
                                              bar_box.one_width, bar_box.top3)
        # バーB
        bar_box.step1_rect[2].left_top = (bar_box.blue_left,
                                          circle_rail.blue_p[1])
        bar_box.step1_rect[2].right_bottom = (bar_box.blue_left +
                                              bar_box.one_width, bar_box.top3)
        #        print(
        #            f"red={bar_box.step1_rect[0].debug_string} \
        # green={bar_box.step1_rect[1].debug_string} \
        # blue={bar_box.step1_rect[2].debug_string}")

        longest_step1_bar_height = bar_box.get_max_step1_height()
        zoom = longest_step1_bar_height / bar_box.height2
        step1_3bars_height = bar_box.create_step1_3bars_height()
        red_add_px = int(step1_3bars_height[0] / zoom) - \
            step1_3bars_height[0]
        green_add_px = int(step1_3bars_height[1] / zoom) - \
            step1_3bars_height[1]
        blue_add_px = int(step1_3bars_height[2] / zoom) - \
            step1_3bars_height[2]
        bar_box.addition_3bars_height = (red_add_px, green_add_px, blue_add_px)

        # 内環状
        theta = inner_circle.phase * inner_circle.unit_arc
        color_rate = calc_step1(theta)
        inner_step1_color_rate = append_rank3_to_color_rate(
            color_rate, bar_box.rates)
        inner_color = convert_3rates_to_3bytes(inner_step1_color_rate)
        inner_circle.color_list.append(inner_color)

        # 外環状
        theta = outer_circle.phase * outer_circle.unit_arc
        color_rate = calc_step1(theta)
        outer_step1_color_rate = append_rank3_to_color_rate(
            color_rate, bar_box.rates)
        outer_color = convert_3rates_to_3bytes(outer_step1_color_rate)
        outer_color = calc_step2(outer_color, bar_box.get_max_rank23_height(),
                                 bar_box.height, bar_box.height1,
                                 bar_box.height3)
        outer_circle.color_list.append(outer_color)
        #

        draw_grid(canvas)  # 罫線
        bar_box.draw_outline(canvas)  # 箱の輪郭
        canvas = draw_canvas(canvas, bar_box, circle_rail, inner_circle,
                             outer_circle)
        bar_box.draw_rank2_box(canvas)
        draw_tone_name(canvas, bar_box, tone_name)

        # 書出し
        canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
        cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
        seq += 1

    return seq, canvas
Exemplo n.º 7
0
def make_circle(canvas, seq, bar_rates, tone_name):
    """色相環一周分の画像を出力"""

    inner_circle = OuterCircle()
    outer_circle = OuterCircle()

    for phase in range(0, PHASE_COUNTS):
        theta = 360 / PHASE_COUNTS * phase
        canvas = make_canvas()
        bar_box, circle_rail, inner_circle, outer_circle = make_scene1(
            bar_rates, inner_circle, outer_circle)
        inner_circle.phase = phase
        outer_circle.phase = phase

        # 円周上の点の位置
        circle_rail.theta = theta

        # バーR
        bar_box.step1_red_bar_p1 = (bar_box.red_left, circle_rail.red_p[1])
        bar_box.step1_red_bar_p2 = (bar_box.red_left + bar_box.one_width,
                                    bar_box.top3)
        # バーG
        bar_box.step1_green_bar_p1 = (bar_box.green_left,
                                      circle_rail.green_p[1])
        bar_box.step1_green_bar_p2 = (bar_box.green_left + bar_box.one_width,
                                      bar_box.top3)
        # バーB
        bar_box.step1_blue_bar_p1 = (bar_box.blue_left, circle_rail.blue_p[1])
        bar_box.step1_blue_bar_p2 = (bar_box.blue_left + bar_box.one_width,
                                     bar_box.top3)

        upper_bound_px = bar_box.get_step1_upper_bound_y()
        longest_rank2_bar_height = bar_box.top3 - upper_bound_px
        # print(
        #    f"longest_rank2_bar_height={longest_rank2_bar_height} bar_box.height={bar_box.height}")
        zoom = longest_rank2_bar_height / bar_box.height2
        # print(f"zoom={zoom}")
        red_add = int(bar_box.red_step1_height / zoom) - \
            bar_box.red_step1_height
        green_add = int(bar_box.green_step1_height / zoom) - \
            bar_box.green_step1_height
        blue_add = int(bar_box.blue_step1_height / zoom) - \
            bar_box.blue_step1_height
        #print(f"red_add={red_add} green_add={green_add} blue_add={blue_add}")

        bar_box.red_addition = red_add
        bar_box.green_addition = green_add
        bar_box.blue_addition = blue_add

        # バーR追加部分
        bar_box.addition_red_bar_p1 = (bar_box.red_left,
                                       bar_box.step1_red_bar_p1[1] -
                                       bar_box.red_addition)  # yは逆さ
        bar_box.addition_red_bar_p2 = (bar_box.red_left + bar_box.one_width,
                                       circle_rail.red_p[1])
        # バーG追加部分
        bar_box.addition_green_bar_p1 = (bar_box.green_left,
                                         bar_box.step1_green_bar_p1[1] -
                                         bar_box.green_addition)
        bar_box.addition_green_bar_p2 = (bar_box.green_left +
                                         bar_box.one_width,
                                         circle_rail.green_p[1])
        # バーB追加部分
        bar_box.addition_blue_bar_p1 = (bar_box.blue_left,
                                        bar_box.step1_blue_bar_p1[1] -
                                        bar_box.blue_addition)
        bar_box.addition_blue_bar_p2 = (bar_box.blue_left + bar_box.one_width,
                                        circle_rail.blue_p[1])

        ceil_height = bar_box.ceil_height_rgb_value
        base_line = bar_box.base_line_rgb_value

        # 内環状
        theta = inner_circle.phase * inner_circle.unit_arc
        color = calc_step1(theta)
        inner_color = append_rank3_to_color(color, bar_box.rates)
        inner_circle.color_list.append(inner_color)

        # 外環状
        theta = outer_circle.phase * outer_circle.unit_arc
        color = calc_step1(theta)
        outer_color = append_rank3_to_color(color, bar_box.rates)
        outer_upper_bound = outer_circle.get_upper_bound_value(bar_box.rates)
        outer_color = calc_step2(outer_color, outer_upper_bound, 255,
                                 ceil_height, base_line)
        outer_circle.color_list.append(outer_color)
        #

        draw_grid(canvas)  # 罫線
        bar_box.draw_outline(canvas)  # 箱の輪郭
        canvas = draw_canvas(canvas, bar_box, circle_rail, inner_circle,
                             outer_circle)
        bar_box.draw_rank2_box(canvas)
        draw_tone_name(canvas, bar_box, tone_name)

        # 書出し
        canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB)  # BGRをRGBにする
        cv2.imwrite(f"./@share/out-cstep4-{seq}.png", canvas)
        seq += 1

    return seq, canvas
Exemplo n.º 8
0
def make_scene1(bar_rates):
    """オブジェクトの位置とキャンバスを返します
    """

    bar_box = BarBox()
    bar_window = BarWindow()
    circle_rail = CircleRail()
    brush_point = BrushPoint()
    outer_circle = OuterCircle()

    # バー
    # RGBバーの1段目、2段目、3段目の高さ(20分率)
    bar_box.top1 = BAR_TOP1
    bar_box.rates = bar_rates
    bar_box.height1 = int(bar_box.rates[0] * 20 * GRID_INTERVAL_H)
    bar_box.height2 = int(bar_box.rates[1] * 20 * GRID_INTERVAL_H)
    bar_box.height3 = int(bar_box.rates[2] * 20 * GRID_INTERVAL_H)
    bar_box.one_width = 24
    # 円レール
    circle_rail.range = int(bar_box.height2 / 2)
    # 塗った円
    brush_point.distance = circle_rail.range + 2*GRID_INTERVAL_H
    brush_point.range = int(1.5*GRID_INTERVAL_H)

    # バー箱の左
    bar_window.one_width = 24
    bar_window.interval = 1
    bar_window_space = 3*bar_window.one_width + \
        2*bar_window.interval+4*GRID_INTERVAL_H
    range_width = 10
    outer_circle_margin = 2
    width = 2 * (range_width + outer_circle_margin)
    bar_box.left = int(CRAIL_LEFT + width*GRID_INTERVAL_H +
                       2*brush_point.range+bar_window_space)
    # バーの筋
    bar_box.font_height = 20
    bar_box.font_scale = 0.6
    bar_box.line_type = 2
    bar_box.font = cv2.FONT_HERSHEY_SIMPLEX
    bar_box.red_left = bar_box.left
    bar_box.green_left = bar_box.red_left + bar_box.one_width + 1
    bar_box.blue_left = bar_box.green_left + bar_box.one_width + 1
    bar_box.right = bar_box.blue_left + bar_box.one_width
    # レールとなる円 circle rail
    circle_rail.top = BAR_TOP1 + bar_box.height1
    circle_rail.center = (CRAIL_LEFT+circle_rail.range,
                          circle_rail.top+circle_rail.range)  # x, y
    brush_point.origin = (circle_rail.center[0], circle_rail.center[1])
    outer_circle.origin = (circle_rail.center[0], circle_rail.center[1])
    circle_rail.point_range = 4
    # RGBバー2段目
    bar_box.top2 = circle_rail.top
    bar_box.rank1_p1 = (bar_box.left, BAR_TOP1)
    bar_box.rank1_p2 = (bar_box.right, bar_box.top2)
    # バー2段目(レールとなる円と水平線を合わす)
    bar_box.top3 = bar_box.top2 + bar_box.height2
    bar_box.bottom = bar_box.top3 + bar_box.height3
    bar_box.height = bar_box.height1 + bar_box.height2 + bar_box.height3
    # RGBバー2段目領域
    bar_box.rank2_p1 = (bar_box.left, bar_box.top2)
    bar_box.rank2_p2 = (bar_box.right, bar_box.top3)
    # RGBバー3段目
    bar_box.rank3_p1 = (bar_box.left, bar_box.top3)
    bar_box.rank3_p2 = (bar_box.right, bar_box.bottom)

    # バー窓の左(円レールが決まった後)
    bar_window.left_top = (
        int(CRAIL_LEFT + width*GRID_INTERVAL_H + 2*brush_point.range),
        circle_rail.top)
    bar_window.right_bottom = (
        bar_window.left_top[0] + 3*bar_window.one_width+2*bar_window.interval,
        circle_rail.top+2*circle_rail.range)

    outer_circle.area_size = (brush_point.distance+2*GRID_INTERVAL_H,
                              brush_point.distance+2*GRID_INTERVAL_H)

    return bar_box, circle_rail, brush_point, bar_window, outer_circle