Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
ff6d5d8a
Commit
ff6d5d8a
authored
6 months ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Cache rotated and resized images
parent
421f22dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!110
V1.2.0 changes
,
!104
Resolve "Faster Drawing"
Pipeline
#58978
failed
6 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cooperative_cuisine/pygame_2d_vis/drawing.py
+28
-35
28 additions, 35 deletions
cooperative_cuisine/pygame_2d_vis/drawing.py
with
28 additions
and
35 deletions
cooperative_cuisine/pygame_2d_vis/drawing.py
+
28
−
35
View file @
ff6d5d8a
...
...
@@ -358,33 +358,26 @@ class Visualizer:
pos: The position of the center of the image, given in pixels.
rot_angle: Optional angle to rotate the image around.
"""
cache_entry
=
f
"
{
img_path
}
"
if
cache_entry
+
(
"
-burnt
"
if
burnt
else
""
)
in
self
.
image_cache_dict
:
image
=
self
.
image_cache_dict
[
cache_entry
+
(
"
-burnt
"
if
burnt
else
""
)
]
cache_entry
=
f
"
{
img_path
}
-
{
size
}
-
{
rot_angle
}
"
+
(
"
-burnt
"
if
burnt
else
""
)
if
cache_entry
in
self
.
image_cache_dict
:
image
=
self
.
image_cache_dict
[
cache_entry
]
else
:
image
=
pygame
.
image
.
load
(
ROOT_DIR
/
"
pygame_2d_vis
"
/
img_path
).
convert_alpha
()
if
burnt
:
if
cache_entry
in
self
.
image_cache_dict
:
normal_image
=
self
.
image_cache_dict
[
cache_entry
]
else
:
normal_image
=
pygame
.
image
.
load
(
ROOT_DIR
/
"
pygame_2d_vis
"
/
img_path
).
convert_alpha
()
self
.
image_cache_dict
[
cache_entry
]
=
normal_image
image
=
grayscale
(
normal_image
)
self
.
image_cache_dict
[
cache_entry
+
"
-burnt
"
]
=
image
else
:
image
=
pygame
.
image
.
load
(
ROOT_DIR
/
"
pygame_2d_vis
"
/
img_path
).
convert_alpha
()
self
.
image_cache_dict
[
cache_entry
]
=
image
# TODO: smoothscale or not???
# image = pygame.transform.smoothscale(image, (size, size))
image
=
pygame
.
transform
.
scale
(
image
,
(
size
,
size
))
# TODO cache rotation
if
rot_angle
!=
0
:
image
=
pygame
.
transform
.
rotate
(
image
,
rot_angle
)
image
=
grayscale
(
image
)
# TODO: smoothscale or not???
# image = pygame.transform.smoothscale(image, (size, size))
image
=
pygame
.
transform
.
scale
(
image
,
(
size
,
size
))
if
rot_angle
!=
0
:
image
=
pygame
.
transform
.
rotate
(
image
,
rot_angle
)
self
.
image_cache_dict
[
cache_entry
]
=
image
rect
=
image
.
get_rect
()
rect
.
center
=
np
.
floor
(
pos
)
rect
.
center
=
np
.
round
(
pos
)
screen
.
blit
(
image
,
rect
)
def
draw_cook
(
...
...
@@ -805,17 +798,17 @@ class Visualizer:
counter_type
=
counter
[
"
type
"
]
if
counter_type
.
endswith
(
"
Dispenser
"
)
and
"
Plate
"
not
in
counter_type
:
#
if "item_offset" in self.config["Dispenser"].keys():
#
offset_vec = pygame.math.Vector2(
#
self.config["Dispenser"]["item_offset"]
#
)
#
offset_vec.rotate_ip(
#
offset_vec.angle_to(
#
pygame.math.Vector2(counter["orientation"])
#
)
#
+ 180
#
)
#
item_pos += offset_vec
if
"
item_offset
"
in
self
.
config
[
"
Dispenser
"
].
keys
():
offset_vec
=
pygame
.
math
.
Vector2
(
self
.
config
[
"
Dispenser
"
][
"
item_offset
"
]
)
offset_vec
.
rotate_ip
(
offset_vec
.
angle_to
(
pygame
.
math
.
Vector2
(
counter
[
"
orientation
"
])
)
+
180
)
item_pos
+=
offset_vec
if
"
item_scale
"
in
self
.
config
[
"
Dispenser
"
].
keys
():
item_scale
=
self
.
config
[
"
Dispenser
"
][
"
item_scale
"
]
...
...
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