mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
fix a bug
This commit is contained in:
parent
f5c67576aa
commit
6c25f6b1de
@ -896,7 +896,7 @@ static bool color32_from_hex_STATIC(int argc, py_Ref argv) {
|
||||
c11_color32 color;
|
||||
int res;
|
||||
if(hex.size == 7) {
|
||||
res = scanf(hex.data, "#%2hhx%2hhx%2hhx", &color.r, &color.g, &color.b);
|
||||
res = sscanf(hex.data, "#%2hhx%2hhx%2hhx", &color.r, &color.g, &color.b);
|
||||
if(res != 3) return ValueError("invalid hex color format");
|
||||
color.a = 255;
|
||||
} else {
|
||||
|
@ -12,6 +12,7 @@ assert a.with_a(255).a == 255 and a.with_a(255).g == a.g
|
||||
|
||||
assert a.to_hex() == '#64c8ff78'
|
||||
assert color32.from_hex('#64c8ff78') == a
|
||||
assert color32.from_hex('#64c8ff') == a.with_a(255)
|
||||
|
||||
assert rgb(100, 200, 255) != a
|
||||
assert rgba(100, 200, 255, 120 / 255) == a
|
||||
|
Loading…
x
Reference in New Issue
Block a user