-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pybricks.parameters.Color: Make color instances iterable.
Fixes pybricks/support#1661
- Loading branch information
1 parent
ed3632f
commit 2a45f4e
Showing
6 changed files
with
93 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pybricks.parameters import Color | ||
|
||
# "enums" should be able to be used as hash values | ||
map = { | ||
Color.RED: "red", | ||
Color.GREEN: "green", | ||
Color.BLUE: "blue", | ||
} | ||
print(map[Color.RED]) | ||
print(map[Color.GREEN]) | ||
print(map[Color.BLUE]) | ||
|
||
# Iteration and subscription | ||
print(*Color.BLUE) | ||
h, s, v = Color.BLUE | ||
print(h, s, v) | ||
h = Color.BLUE[0] | ||
s = Color.BLUE[1] | ||
v = Color.BLUE[2] | ||
print(h, s, v) | ||
|
||
# Shifting. | ||
print(Color.RED >> 120 == Color.GREEN) | ||
print(Color.RED >> 720 == Color.RED) | ||
|
||
# Scaling | ||
light_red = Color(0, 100, 50) | ||
print(Color.RED * 0.5 == light_red) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
red | ||
green | ||
blue | ||
240 100 100 | ||
240 100 100 | ||
240 100 100 | ||
True | ||
True | ||
True |