Пример #1
0
def update_scene1(vertical_parcent, outer_circle):
    """オブジェクトの位置とキャンバスを返します
    """

    bar_box = BarBox()
    circle_rail = CircleRail()
    inscribed_triangle = InscribedTriangle()

    # バー
    # RGBバーの1段目、2段目、3段目の高さ(20分率)
    bar_box.top1 = BAR_TOP1
    bar_box.rates = vertical_parcent
    bar_box.height1 = int(bar_box.rates[0] * 10 * GRID_UNIT)
    bar_box.height2 = int(bar_box.rates[1] * 10 * GRID_UNIT)
    bar_box.height3 = int(bar_box.rates[2] * 10 * GRID_UNIT)
    bar_box.one_width = 30  # フォント1文字の横幅が 10 と想定
    bar_box.y_axis_label_gap = int(0.25 * GRID_UNIT)
    bar_box.rate_text_gap = int(0.2 * GRID_UNIT)

    # バー箱の左
    bar_box.left = BAR_BOX_LEFT
    # バーの筋
    bar_box.font_scale = FONT_SCALE
    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
    bar_box.blue_left = bar_box.green_left + bar_box.one_width
    bar_box.right = bar_box.blue_left + bar_box.one_width
    # レールとなる円 circle rail
    circle_rail.top = BAR_TOP1 + bar_box.height1

    # 円レール
    circle_rail.range1 = int(bar_box.height2 / 2)
    circle_rail.border_left = GRID_UNIT
    circle_rail.border_right = bar_box.left - GRID_UNIT

    circle_rail.center = (bar_box.left - CIRCLE_DISTANCE,
                          circle_rail.top + circle_rail.range1)  # x, y
    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_rect.left_top = (bar_box.left, BAR_TOP1)
    bar_box.rank1_rect.right_bottom = (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
    # print(f"bar_box.height={bar_box.height}")
    # RGBバー2段目領域
    bar_box.rank2_rect.left_top = (bar_box.left, bar_box.top2)
    bar_box.rank2_rect.right_bottom = (bar_box.right, bar_box.top3)
    # RGBバー3段目
    bar_box.rank3_rect.left_top = (bar_box.left, bar_box.top3)
    bar_box.rank3_rect.right_bottom = (bar_box.right, bar_box.bottom)

    outer_circle.area_size = (int(7 * GRID_UNIT), int(7 * GRID_UNIT))
    outer_circle.phases = PHASE_COUNTS

    return bar_box, circle_rail, outer_circle, inscribed_triangle
Пример #2
0
def update_scene1(vertical_parcent, outer_circle):
    """オブジェクトの位置とキャンバスを返します
    """

    # RGBバー
    bar_box = BarBox()
    bar_box.rates = vertical_parcent
    width1 = int(bar_box.rates[0] * 20 * GRID_UNIT)
    width2 = int(bar_box.rates[1] * 20 * GRID_UNIT)
    width3 = int(bar_box.rates[2] * 20 * GRID_UNIT)
    bar_box.left = BAR_BOX_LEFT
    bar_box.lower_x = bar_box.left + width3
    bar_box.upper_x = bar_box.lower_x + width2
    bar_box.right = bar_box.upper_x + width1
    bar_box.top = BAR_BOX_TOP
    bar_box.bottom = bar_box.top + 90
    bar_box.label_gap = int(-0.75 * GRID_UNIT)
    bar_box.font_scale = FONT_SCALE
    bar_box.line_type = 2
    bar_box.font = cv2.FONT_HERSHEY_SIMPLEX

    # レールとなる円 circle rail
    circle_rail = CircleRail()
    circle_rail.drawing_top = bar_box.bottom + GRID_UNIT
    circle_rail.drawing_bottom = CANVAS_HEIGHT - GRID_UNIT
    circle_rail.range1 = int(width2 / 2)

    circle_rail.center = (int((bar_box.lower_x + bar_box.upper_x) / 2),
                          bar_box.bottom + CIRCLE_DISTANCE + circle_rail.range1
                          )  # x, y
    circle_rail.border_rect = Rectangle(
        bar_box.lower_x, circle_rail.center[1] - circle_rail.range1,
        bar_box.upper_x, circle_rail.center[1] + circle_rail.range1)
    circle_rail.point_range = 4

    # 外環状
    outer_circle.origin = (circle_rail.center[0], circle_rail.center[1])
    outer_circle.area_size = (int(bar_box.width * 9 / 10),
                              int(bar_box.width * 9 / 10))
    outer_circle.phases = PHASE_COUNTS
    outer_circle.tickness = int(1.5 * GRID_UNIT)

    inscribed_triangle = InscribedTriangle()

    # 時計の針
    clock_hand = ClockHand()
    clock_hand.center = (circle_rail.center[0], circle_rail.center[1])
    clock_hand.unit_arc = outer_circle.unit_arc
    clock_hand.tickness = 2
    clock_hand.rng1 = circle_rail.range1  # 1st range
    rng2_expected = bar_box.width * 9 / 10
    clock_hand.rng2 = int(rng2_expected - outer_circle.tickness / 2 -
                          clock_hand.tickness)  # 2nd range
    clock_hand.rng3 = int(rng2_expected + outer_circle.tickness / 2 +
                          clock_hand.tickness)  # 3rd range

    return bar_box, circle_rail, outer_circle, inscribed_triangle, clock_hand
Пример #3
0
def update_scene1(bar_rate, outer_circle):
    """オブジェクトの位置とキャンバスを返します
    """

    # RGBバー
    bar_box = BarBox()
    bar_box.rates = bar_rate
    left_box_width = bar_box.rates[0] * 20 * GRID_UNIT
    middle_box_width = bar_box.rates[1] * 20 * GRID_UNIT
    right_box_width = bar_box.rates[2] * 20 * GRID_UNIT
    bar_box.left = BAR_BOX_LEFT
    bar_box.lower_x = bar_box.left + left_box_width
    bar_box.upper_x = bar_box.lower_x + middle_box_width
    bar_box.right = bar_box.upper_x + right_box_width
    bar_box.top = BAR_BOX_TOP
    bar_box.bottom = bar_box.top + 90
    bar_box.label_gap = -0.75 * GRID_UNIT
    bar_box.font_scale = FONT_SCALE
    bar_box.line_type = 2
    bar_box.font = cv2.FONT_HERSHEY_SIMPLEX

    # レールとなる円 circle rail
    circle_rail = CircleRail()
    circle_rail.drawing_top = bar_box.bottom + GRID_UNIT
    circle_rail.drawing_bottom = CANVAS_HEIGHT - GRID_UNIT
    circle_rail.radius = middle_box_width / 2

    circle_rail.center = ((bar_box.lower_x + bar_box.upper_x) / 2,
                          bar_box.bottom + CIRCLE_DISTANCE +
                          bar_box.width * 4 / 10)
    circle_rail.border_rect = Rectangle(
        bar_box.lower_x, circle_rail.center[1] - circle_rail.radius,
        bar_box.upper_x, circle_rail.center[1] + circle_rail.radius)
    circle_rail.point_range = 4

    radius2_expected = bar_box.width * 9 / 10

    # 外環状
    outer_circle.origin = (circle_rail.center[0], circle_rail.center[1])
    outer_circle.radius = radius2_expected
    outer_circle.phases = PHASE_COUNTS
    outer_circle.tickness = 5.0 * GRID_UNIT  # 3.0*GRID_UNIT  # 1.5*GRID_UNIT

    # 長方形に内接する大きな正三角形
    large_triangle = Triangle()
    large_triangle.edge_color = GRAY
    large_triangle.nodes_color = (RED, GREEN, BLUE)
    large_triangle.node_radius = GRID_UNIT / 2
    large_triangle.center_color = GRAY

    # 時計の針
    clock_hand = ClockHand()
    clock_hand.center = (circle_rail.center[0], circle_rail.center[1])
    clock_hand.unit_arc = outer_circle.unit_arc
    clock_hand.tickness = 2
    clock_hand.radius1 = circle_rail.radius  # 1st range
    clock_hand.radius2 = radius2_expected - \
        outer_circle.tickness / 2 - clock_hand.tickness  # 2nd range
    clock_hand.radius3 = radius2_expected + \
        outer_circle.tickness / 2 + clock_hand.tickness  # 3rd range

    return bar_box, circle_rail, outer_circle, large_triangle, clock_hand
Пример #4
0
def make_scene1(bar_rates, inner_circle, outer_circle):
    """オブジェクトの位置とキャンバスを返します
    """

    bar_box = BarBox()
    circle_rail = CircleRail()

    # バー
    # 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 = 30  # フォント1文字の横幅が 10 と想定
    bar_box.rate_text_gap = int(0.5 * GRID_INTERVAL_H)
    # 円レール
    circle_rail.range = int(bar_box.height2 / 2)

    # バー箱の左
    range_width = 10
    outer_circle_margin = 3
    width = 2 * (range_width + outer_circle_margin)
    bar_box.left = int(CRAIL_LEFT + width * GRID_INTERVAL_H +
                       2 * int(1.5 * GRID_INTERVAL_H))
    # バーの筋
    bar_box.font_scale = FONT_SCALE
    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
    inner_circle.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_rect.left_top = (bar_box.left, BAR_TOP1)
    bar_box.rank1_rect.right_bottom = (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_rect.left_top = (bar_box.left, bar_box.top2)
    bar_box.rank2_rect.right_bottom = (bar_box.right, bar_box.top3)
    # RGBバー3段目
    bar_box.rank3_rect.left_top = (bar_box.left, bar_box.top3)
    bar_box.rank3_rect.right_bottom = (bar_box.right, bar_box.bottom)

    inner_circle.area_size = (int(circle_rail.range + 2 * GRID_INTERVAL_H +
                                  1.6 * GRID_INTERVAL_H),
                              int(circle_rail.range + 2 * GRID_INTERVAL_H +
                                  1.6 * GRID_INTERVAL_H))
    inner_circle.phases = PHASE_COUNTS
    outer_circle.area_size = (int(circle_rail.range + 3 * GRID_INTERVAL_H +
                                  3 * GRID_INTERVAL_H),
                              int(circle_rail.range + 3 * GRID_INTERVAL_H +
                                  3 * GRID_INTERVAL_H))
    outer_circle.phases = PHASE_COUNTS

    return bar_box, circle_rail, inner_circle, outer_circle
Пример #5
0
def make_canvas_scene1(bar_rate):
    """アニメの1コマを作成します
    """
    # キャンバス
    canvas = np.full((CANVAS_HEIGHT, CANVAS_WIDTH, CHANNELS),
                     MONO_BACKGROUND,
                     dtype=np.uint8)

    # 水平線グリッド
    for i in range(0, int(CANVAS_HEIGHT / GRID_INTERVAL_H)):
        y_num = GRID_INTERVAL_H * i
        cv2.line(canvas, (0, y_num), (CANVAS_WIDTH, y_num),
                 PALE_GRAY,
                 thickness=1)

    bar_box = BarBox()
    circle_rail = CircleRail()
    brush_point = BrushPoint()
    # バー
    # RGBバーの1段目、2段目、3段目の高さ(20分率)
    bar_box.height1 = int(bar_rate[0] * 20 * GRID_INTERVAL_H)
    bar_box.height2 = int(bar_rate[1] * 20 * GRID_INTERVAL_H)
    bar_box.height3 = int(bar_rate[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 = 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_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
    circle_rail.point_range = 6
    # 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バー(中部)領域
    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)

    return canvas, bar_box, circle_rail, brush_point
Пример #6
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
Пример #7
0
def update_scene1(vertical_parcent, outer_circle):
    """オブジェクトの位置とキャンバスを返します
    """

    # RGBバー
    bar_box = BarBox()
    bar_box.rates = vertical_parcent
    height1 = int(bar_box.rates[0] * 10 * GRID_UNIT)
    height2 = int(bar_box.rates[1] * 10 * GRID_UNIT)
    height3 = int(bar_box.rates[2] * 10 * GRID_UNIT)
    bar_box.top = BAR_TOP1
    bar_box.upper_y = bar_box.top + height1
    bar_box.lower_y = bar_box.upper_y + height2
    bar_box.bottom = bar_box.lower_y + height3
    bar_box.label_gap = int(0.25 * GRID_UNIT)
    bar_box.left = BAR_BOX_LEFT
    bar_box.right = bar_box.left + 90
    bar_box.font_scale = FONT_SCALE
    bar_box.line_type = 2
    bar_box.font = cv2.FONT_HERSHEY_SIMPLEX

    # レールとなる円 circle rail
    circle_rail = CircleRail()
    circle_rail.top = bar_box.upper_y
    circle_rail.range1 = int(height2 / 2)
    circle_rail.border_left = GRID_UNIT
    circle_rail.border_right = bar_box.left - GRID_UNIT

    circle_rail.center = (bar_box.left - CIRCLE_DISTANCE,
                          circle_rail.top + circle_rail.range1)  # x, y
    circle_rail.point_range = 4

    outer_circle.origin = (circle_rail.center[0], circle_rail.center[1])
    outer_circle.area_size = (int(7 * GRID_UNIT), int(7 * GRID_UNIT))
    outer_circle.phases = PHASE_COUNTS

    inscribed_triangle = InscribedTriangle()

    return bar_box, circle_rail, outer_circle, inscribed_triangle