diff --git a/__pycache__/cfd_animated_icon.cpython-312.pyc b/__pycache__/cfd_animated_icon.cpython-312.pyc index da42414..5922455 100644 Binary files a/__pycache__/cfd_animated_icon.cpython-312.pyc and b/__pycache__/cfd_animated_icon.cpython-312.pyc differ diff --git a/cfd_animated_icon.py b/cfd_animated_icon.py index 9bb9a29..8a874f7 100644 --- a/cfd_animated_icon.py +++ b/cfd_animated_icon.py @@ -153,6 +153,84 @@ class AnimatedIcon(tk.Canvas): start_angle2 = -self.angle * 180 / pi + 60 self.draw.arc(bbox_inner, start=start_angle2, end=start_angle2 + 150, fill=self.color_rgb, width=7) + def _draw_stopped_frame(self): + self.delete("all") + if self.use_pillow: + self._draw_pillow_stopped_frame() + else: + self._draw_canvas_stopped_frame() + + def _draw_canvas_stopped_frame(self): + if self.animation_type == "line": + self._draw_canvas_line_stopped() + elif self.animation_type == "double_arc": + self._draw_canvas_double_arc_stopped() + elif self.animation_type == "counter_arc": + self._draw_canvas_counter_arc_stopped() + + def _draw_canvas_line_stopped(self): + center_x, center_y = self.width / 2, self.height / 2 + for i in range(8): + angle = i * (pi / 4) + start_x = center_x + cos(angle) * (self.width * 0.2) + start_y = center_y + sin(angle) * (self.height * 0.2) + end_x = center_x + cos(angle) * (self.width * 0.4) + end_y = center_y + sin(angle) * (self.height * 0.4) + self.create_line(start_x, start_y, end_x, end_y, fill=self.highlight_color, width=2) + + def _draw_canvas_double_arc_stopped(self): + center_x, center_y = self.width / 2, self.height / 2 + radius = min(center_x, center_y) * 0.8 + bbox = (center_x - radius, center_y - radius, center_x + radius, center_y + radius) + self.create_arc(bbox, start=0, extent=359.9, style=tk.ARC, outline=self.highlight_color, width=2) + + def _draw_canvas_counter_arc_stopped(self): + center_x, center_y = self.width / 2, self.height / 2 + radius_outer = min(center_x, center_y) * 0.8 + bbox_outer = (center_x - radius_outer, center_y - radius_outer, center_x + radius_outer, center_y + radius_outer) + self.create_arc(bbox_outer, start=0, extent=359.9, style=tk.ARC, outline=self.highlight_color, width=2) + radius_inner = min(center_x, center_y) * 0.6 + bbox_inner = (center_x - radius_inner, center_y - radius_inner, center_x + radius_inner, center_y + radius_inner) + self.create_arc(bbox_inner, start=0, extent=359.9, style=tk.ARC, outline=self.color, width=2) + + def _draw_pillow_stopped_frame(self): + self.draw.rectangle([0, 0, self.width * 4, self.height * 4], fill=(0, 0, 0, 0)) + if self.animation_type == "line": + self._draw_pillow_line_stopped() + elif self.animation_type == "double_arc": + self._draw_pillow_double_arc_stopped() + elif self.animation_type == "counter_arc": + self._draw_pillow_counter_arc_stopped() + + resized_image = self.image.resize((self.width, self.height), Image.Resampling.LANCZOS) + self.photo_image = ImageTk.PhotoImage(resized_image) + self.create_image(0, 0, anchor="nw", image=self.photo_image) + + def _draw_pillow_line_stopped(self): + center_x, center_y = self.width * 2, self.height * 2 + for i in range(12): + angle = i * (pi / 6) + start_x = center_x + cos(angle) * (self.width * 0.8) + start_y = center_y + sin(angle) * (self.height * 0.8) + end_x = center_x + cos(angle) * (self.width * 1.6) + end_y = center_y + sin(angle) * (self.height * 1.6) + self.draw.line([(start_x, start_y), (end_x, end_y)], fill=self.highlight_color_rgb, width=6, joint="curve") + + def _draw_pillow_double_arc_stopped(self): + center_x, center_y = self.width * 2, self.height * 2 + radius = min(center_x, center_y) * 0.8 + bbox = (center_x - radius, center_y - radius, center_x + radius, center_y + radius) + self.draw.arc(bbox, start=0, end=360, fill=self.highlight_color_rgb, width=5) + + def _draw_pillow_counter_arc_stopped(self): + center_x, center_y = self.width * 2, self.height * 2 + radius_outer = min(center_x, center_y) * 0.8 + bbox_outer = (center_x - radius_outer, center_y - radius_outer, center_x + radius_outer, center_y + radius_outer) + self.draw.arc(bbox_outer, start=0, end=360, fill=self.highlight_color_rgb, width=7) + radius_inner = min(center_x, center_y) * 0.6 + bbox_inner = (center_x - radius_inner, center_y - radius_inner, center_x + radius_inner, center_y + radius_inner) + self.draw.arc(bbox_inner, start=0, end=360, fill=self.color_rgb, width=7) + def _animate(self): if self.running: self.angle += 0.1 @@ -167,5 +245,13 @@ class AnimatedIcon(tk.Canvas): self._animate() def stop(self): + self.running = False + self._draw_stopped_frame() + + def hide(self): self.running = False self.delete("all") + + def show_full_circle(self): + if not self.running: + self._draw_stopped_frame()