示例#1
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
示例#2
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
示例#3
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