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
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
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