-
-
Notifications
You must be signed in to change notification settings - Fork 82
pbio/drv/display, pybricks.parameters: Improve conversion from HSV to pixel value. #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pybricks/parameters/pb_type_image.c
Outdated
| uint16_t h = pbio_int_math_bind(hsv->h, 0, 359); | ||
| uint8_t s = pbio_int_math_bind(hsv->s, 0, 100); | ||
| uint8_t v = pbio_int_math_bind(hsv->v, 0, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range of these values should already be guaranteed. If not, we could have problems elsewhere as well. Maybe just an assert() here instead to catch problems in debug builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is at least Color.NONE which is defined with a negative V:
const pb_type_Color_obj_t pb_Color_NONE_obj = {
{&pb_type_Color},
.hsv = {0, 0, -40}
};There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think #421 fixes that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I made the change.
… pixel value.
Use a mapping trying to match the real pixel color, select the nearest
pixel value according to the input color.
Small test program:
from pybricks.hubs import ThisHub
from pybricks.parameters import Color
from pybricks.tools import wait
hub = ThisHub()
i = hub.screen
for y in range(i.height):
for x in range(i.width):
i.draw_pixel(x, y, Color(0, y * 100 / (i.height - 1), x * 100 / (i.width - 1)))
wait(50000)
Closes: pybricks/support#2442
|
Thank you! |
Use a mapping trying to match the real pixel color, select the nearest pixel value according to the input color.
Small test program:
Closes: pybricks/support#2442