3939stop_background_color = (0 , 0 , 255 )
4040
4141def create_ui_image ():
42- # Initialize arrow button images. This could be done with a single image
43- # that gets transposed and flipped, but ulab's transpose() doesn't support
44- # the axes argument:
45- # https://github.com/v923z/micropython-ulab/issues/731
46- # So we instead create separate images for vertical and horizontal arrows
47- img_arrow_vertical = np .zeros (button_shape , dtype = np .uint8 )
48- img_arrow_vertical [:, :] = arrow_background_color
49- img_arrow_horizontal = img_arrow_vertical .copy ()
50- img_arrow_vertical = cv .arrowedLine (
51- img_arrow_vertical ,
42+ # Initialize arrow button image
43+ img_arrow = np .zeros (button_shape , dtype = np .uint8 )
44+ img_arrow [:, :] = arrow_background_color
45+ img_arrow = cv .arrowedLine (
46+ img_arrow ,
5247 (button_cx , button_cy + arrow_length // 2 ),
5348 (button_cx , button_cy - arrow_length // 2 ),
5449 button_color ,
@@ -57,16 +52,6 @@ def create_ui_image():
5752 0 ,
5853 arrow_tip_length
5954 )
60- img_arrow_horizontal = cv .arrowedLine (
61- img_arrow_horizontal ,
62- (button_cx - arrow_length // 2 , button_cy ),
63- (button_cx + arrow_length // 2 , button_cy ),
64- button_color ,
65- arrow_thickness ,
66- cv .FILLED ,
67- 0 ,
68- arrow_tip_length
69- )
7055
7156 # Initialize stop button image
7257 img_button_stop = np .zeros (button_shape , dtype = np .uint8 )
@@ -92,25 +77,25 @@ def create_ui_image():
9277 img_ui [
9378 ui_cy - button_spacing - button_cy :ui_cy - button_spacing + button_cy ,
9479 ui_cx - button_cx :ui_cx + button_cx
95- ] = img_arrow_vertical
80+ ] = img_arrow
9681
9782 # Draw the backward arrow below the stop button
9883 img_ui [
9984 ui_cy + button_spacing - button_cy :ui_cy + button_spacing + button_cy ,
10085 ui_cx - button_cx :ui_cx + button_cx
101- ] = img_arrow_vertical [::- 1 , :] # Flip the arrow image vertically
102-
103- # Draw the right arrow to the right of the stop button
86+ ] = img_arrow [::- 1 , :] # Flip the arrow image vertically
87+
88+ # Draw the left arrow to the left of the stop button
10489 img_ui [
10590 ui_cy - button_cy :ui_cy + button_cy ,
106- ui_cx + button_spacing - button_cx :ui_cx + button_spacing + button_cx
107- ] = img_arrow_horizontal
91+ ui_cx - button_spacing - button_cx :ui_cx - button_spacing + button_cx
92+ ] = img_arrow . transpose (( 1 , 0 , 2 ))
10893
109- # Draw the left arrow to the left of the stop button
94+ # Draw the right arrow to the right of the stop button
11095 img_ui [
11196 ui_cy - button_cy :ui_cy + button_cy ,
112- ui_cx - button_spacing - button_cx :ui_cx - button_spacing + button_cx
113- ] = img_arrow_horizontal [:, ::- 1 ] # Flip the arrow image horizontally
97+ ui_cx + button_spacing - button_cx :ui_cx + button_spacing + button_cx
98+ ] = img_arrow . transpose (( 1 , 0 , 2 )) [:, ::- 1 ] # Flip the arrow image horizontally
11499
115100 # Return the UI image
116101 return img_ui
0 commit comments