Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Trees
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
1MAE002 - ALGORITHM AND COMPUTING
Advanced
Trees
Commits
82759a2b
Verified
Commit
82759a2b
authored
Jul 30, 2024
by
STEVAN Antoine
Browse files
Options
Downloads
Patches
Plain Diff
use gradient of colors in path
parent
0a20aaaf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ui/maze.py
+23
-14
23 additions, 14 deletions
src/ui/maze.py
with
23 additions
and
14 deletions
src/ui/maze.py
+
23
−
14
View file @
82759a2b
...
...
@@ -25,9 +25,9 @@ COLORS = {
"
walls
"
:
(
200
,
200
,
200
),
"
path
"
:
(
100
,
0
,
0
),
"
path link
"
:
(
80
,
0
,
0
),
"
path ends
"
:
(
255
,
165
,
0
),
"
path ends link
"
:
(
255
*
0.7
,
165
*
0.7
,
0
),
"
path ends ends
"
:
(
255
,
0
,
255
),
"
path start
"
:
(
255
,
165
,
0
),
"
path end
"
:
(
165
,
0
,
255
),
"
pause
"
:
(
255
,
0
,
0
),
}
STYLE
=
{
...
...
@@ -211,9 +211,17 @@ class Canva:
y_b
=
(.
5
+
b
//
maze
[
"
width
"
])
*
maze
[
"
size
"
]
if
complete
:
p
=
i
/
(
len
(
path
)
-
1
)
rs
,
gs
,
bs
=
COLORS
[
"
path start
"
]
re
,
ge
,
be
=
COLORS
[
"
path end
"
]
c
=
(
p
*
rs
+
(
1
-
p
)
*
re
,
p
*
gs
+
(
1
-
p
)
*
ge
,
p
*
bs
+
(
1
-
p
)
*
be
,
)
pygame
.
draw
.
line
(
self
.
screen
,
COLORS
[
"
path ends link
"
]
,
c
,
(
x_a
,
y_a
),
(
x_b
,
y_b
),
width
=
int
(
maze
[
"
size
"
]
*
STYLE
[
"
link width
"
]),
...
...
@@ -227,24 +235,25 @@ class Canva:
width
=
int
(
maze
[
"
size
"
]
*
STYLE
[
"
link width
"
]),
)
for
i
,
a
in
enumerate
(
path
):
x_a
=
(.
5
+
a
%
maze
[
"
width
"
])
*
maze
[
"
size
"
]
y_a
=
(.
5
+
a
//
maze
[
"
width
"
])
*
maze
[
"
size
"
]
d
=
int
(
maze
[
"
size
"
]
*
STYLE
[
"
grid
"
].
m
)
r
=
int
(
maze
[
"
size
"
]
*
STYLE
[
"
grid
"
].
r
)
a
=
(
x_a
-
d
//
2
,
y_a
-
d
//
2
,
d
,
d
)
b
=
(
x_b
-
d
//
2
,
y_b
-
d
//
2
,
d
,
d
)
if
complete
:
if
i
==
0
:
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path ends ends
"
],
a
,
border_radius
=
r
)
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path end
s
"
]
,
b
,
border_radius
=
r
)
elif
i
==
len
(
path
)
-
2
:
p
ygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path ends
"
],
a
,
border_radius
=
r
)
p
ygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path ends ends
"
],
b
,
border_radius
=
r
)
else
:
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path ends
"
],
a
,
border_radius
=
r
)
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path ends
"
]
,
b
,
border_radius
=
r
)
p
=
i
/
(
len
(
path
)
-
1
)
rs
,
gs
,
bs
=
COLORS
[
"
path start
"
]
re
,
ge
,
be
=
COLORS
[
"
path end
"
]
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
)
else
:
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path
"
],
a
,
border_radius
=
r
)
pygame
.
draw
.
rect
(
self
.
screen
,
COLORS
[
"
path
"
],
b
,
border_radius
=
r
)
# walls
h
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment