Skip to content
Snippets Groups Projects
Verified Commit 83d75b82 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

add gradient of color for the ongoing path

parent 82759a2b
Branches
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ COLORS = {
"cell": (0, 128, 0),
"link": (0, 102, 0),
"walls": (200, 200, 200),
"path": (100, 0, 0),
"path": (200, 0, 0),
"path link": (80, 0, 0),
"path ends link": (255 * 0.7, 165 * 0.7, 0),
"path start": (255, 165, 0),
......@@ -227,9 +227,17 @@ class Canva:
width=int(maze["size"] * STYLE["link width"]),
)
else:
p = i / len(path)
rs, gs, bs = COLORS["path"]
re, ge, be = (0, 0, 0)
c = (
p * rs + (1 - p) * re,
p * gs + (1 - p) * ge,
p * bs + (1 - p) * be,
)
pygame.draw.line(
self.screen,
COLORS["path link"],
c,
(x_a, y_a),
(x_b, y_b),
width=int(maze["size"] * STYLE["link width"]),
......@@ -253,7 +261,15 @@ class Canva:
)
pygame.draw.rect(self.screen, c, a, border_radius=r)
else:
pygame.draw.rect(self.screen, COLORS["path"], a, border_radius=r)
p = i / len(path)
rs, gs, bs = COLORS["path"]
re, ge, be = (0, 0, 0)
c = (
p * rs + (1 - p) * re,
p * gs + (1 - p) * ge,
p * bs + (1 - p) * be,
)
pygame.draw.rect(self.screen, c, a, border_radius=r)
# walls
h = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment