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] * 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 = 36 # フォント1文字の横幅が 12 と想定 bar_box.y_axis_label_gap = int(0.25 * GRID_UNIT) bar_box.rate_text_gap = int(0.2 * GRID_UNIT) # 円レール circle_rail.range = int(bar_box.height2 / 2) # バー箱の左 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 + 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 = (bar_box.left - CIRCLE_DISTANCE, 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 # 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) inner_circle.area_size = (int(6 * GRID_UNIT), int(6 * GRID_UNIT)) inner_circle.phases = PHASE_COUNTS outer_circle.area_size = (int(7 * GRID_UNIT), int(7 * GRID_UNIT)) outer_circle.phases = PHASE_COUNTS return bar_box, circle_rail, inner_circle, outer_circle
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
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
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