@@ -152,24 +152,13 @@ def __init__(self, stroke: list[tuple[int, int]], options):
152152 self .color = options .primary_color
153153 self .pen_size = options .size
154154 self ._bounds = None
155- self .shadow_color = self ._calculate_shadow_color (self .color )
156155
157156 def draw (self , cr : cairo .Context , image_to_widget_coords : Callable [[int , int ], tuple [float , float ]], scale : float ):
158157 if len (self .stroke ) < 2 :
159158 return
160159 coords = [image_to_widget_coords (x , y ) for x , y in self .stroke ]
161- shadow_offset = 2 * scale
162160 line_width = self .pen_size * scale
163161 self ._build_path (cr , coords )
164- path = cr .copy_path ()
165- cr .save ()
166- cr .translate (shadow_offset , shadow_offset )
167- cr .append_path (path )
168- cr .set_source_rgba (* self .shadow_color )
169- cr .set_line_width (line_width )
170- cr .stroke ()
171- cr .restore ()
172- cr .append_path (path )
173162 cr .set_source_rgba (* self .color )
174163 cr .set_line_width (line_width )
175164 cr .stroke ()
@@ -197,14 +186,20 @@ def get_bounds(self) -> QuadBounds:
197186 self ._bounds = QuadBounds .from_rect (0 , 0 , 0 , 0 )
198187 else :
199188 xs , ys = zip (* self .stroke )
200- padding = self .pen_size // 2 + 5
201- self ._bounds = QuadBounds .from_rect (min (xs ) - padding , min (ys ) - padding , max (xs ) + padding , max (ys ) + padding )
189+ padding = self .pen_size // 2
190+ self ._bounds = QuadBounds .from_rect (
191+ min (xs ) - padding ,
192+ min (ys ) - padding ,
193+ max (xs ) + padding ,
194+ max (ys ) + padding
195+ )
202196 return self ._bounds
203197
204198 def translate (self , dx : int , dy : int ):
205199 self .stroke = [(x + dx , y + dy ) for x , y in self .stroke ]
206200 self ._bounds = None
207201
202+
208203class ArrowAction (DrawingAction ):
209204 ARROW_HEAD_SIZE_MULTIPLIER = 5
210205 HEAD_WIDTH_RATIO = 0.6
@@ -227,7 +222,6 @@ def __init__(self, start: tuple[int, int], end: tuple[int, int], shift: bool, op
227222 self .color = options .primary_color
228223 self .arrow_head_size = options .size * self .ARROW_HEAD_SIZE_MULTIPLIER * 1.75
229224 self .width = options .size * 1.75
230- self .shadow_color = self ._calculate_shadow_color (self .color )
231225
232226 def draw (self , cr : cairo .Context , image_to_widget_coords : Callable [[int , int ], tuple [float , float ]], scale : float ):
233227 start_x , start_y = image_to_widget_coords (* self .start )
@@ -256,20 +250,12 @@ def draw(self, cr: cairo.Context, image_to_widget_coords: Callable[[int, int], t
256250 shaft_end_half = shaft_width
257251 head_half = head_width
258252
259- self ._build_arrow_path (cr , adjusted_start_x , adjusted_start_y , shaft_end_x , shaft_end_y ,
260- end_x , end_y , angle , shaft_start_half , shaft_end_half ,
261- head_half , perp_cos , perp_sin )
262- path = cr .copy_path ()
263-
264- shadow_offset = 3 * scale
265- cr .save ()
266- cr .translate (shadow_offset , shadow_offset )
267- cr .append_path (path )
268- cr .set_source_rgba (* self .shadow_color )
269- cr .fill ()
270- cr .restore ()
253+ self ._build_arrow_path (
254+ cr , adjusted_start_x , adjusted_start_y , shaft_end_x , shaft_end_y ,
255+ end_x , end_y , angle , shaft_start_half , shaft_end_half ,
256+ head_half , perp_cos , perp_sin
257+ )
271258
272- cr .append_path (path )
273259 cr .set_source_rgba (* self .color )
274260 cr .fill ()
275261
@@ -314,6 +300,7 @@ def translate(self, dx: int, dy: int):
314300 self .start = (self .start [0 ] + dx , self .start [1 ] + dy )
315301 self .end = (self .end [0 ] + dx , self .end [1 ] + dy )
316302
303+
317304class TextAction (DrawingAction ):
318305 PADDING_X_IMG = 4
319306 PADDING_Y_IMG = 2
@@ -503,22 +490,10 @@ def draw(self, cr: cairo.Context, image_to_widget_coords: Callable[[int, int], t
503490 end_x -= half_width * math .cos (angle )
504491 end_y -= half_width * math .sin (angle )
505492
506- shadow_offset = 2 * scale
507493 line_width = self .width * scale
508-
509494 cr .set_line_width (line_width )
510495 cr .move_to (start_x , start_y )
511496 cr .line_to (end_x , end_y )
512- path = cr .copy_path ()
513-
514- cr .save ()
515- cr .translate (shadow_offset , shadow_offset )
516- cr .append_path (path )
517- cr .set_source_rgba (* self .shadow_color )
518- cr .stroke ()
519- cr .restore ()
520-
521- cr .append_path (path )
522497 cr .set_source_rgba (* self .color )
523498 cr .stroke ()
524499
@@ -542,6 +517,7 @@ def get_bounds(self) -> QuadBounds:
542517
543518 return QuadBounds (p1 , p2 , p3 , p4 )
544519
520+
545521class RectAction (DrawingAction ):
546522 def __init__ (self , start : tuple [int , int ], end : tuple [int , int ], shift : bool , options ):
547523 self .start = start
0 commit comments