]> gitweb.factorcode.org Git - factor.git/commitdiff
colors.hex: adding an invalid-hex-color error.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 17 Aug 2020 15:04:04 +0000 (08:04 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 17 Aug 2020 15:04:04 +0000 (08:04 -0700)
basis/colors/hex/hex.factor

index ba42206a30ac32368b30b4f9f39d29d20128757f..334a067afcd1f38f5bc9529d04c1dafc60707294 100644 (file)
@@ -6,12 +6,15 @@ lexer math math.parser sequences ;
 
 IN: colors.hex
 
+ERROR: invalid-hex-color hex ;
+
 : hex>rgba ( hex -- rgba )
     dup length {
         { 6 [ 2 group [ hex> 255 /f ] map first3 1.0 ] }
         { 8 [ 2 group [ hex> 255 /f ] map first4 ] }
         { 3 [ [ digit> 15 /f ] { } map-as first3 1.0 ] }
         { 4 [ [ digit> 15 /f ] { } map-as first4 ] }
+        [ drop invalid-hex-color ]
     } case <rgba> ;
 
 : rgba>hex ( rgba -- hex )