Пример #1
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