blueloveTH 10 ay önce
ebeveyn
işleme
6c25f6b1de
2 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 1 1
      src/modules/vmath.c
  2. 1 0
      tests/80_color32.py

+ 1 - 1
src/modules/vmath.c

@@ -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 {

+ 1 - 0
tests/80_color32.py

@@ -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