@@ -237,16 +237,14 @@ defmodule Scenic.Primitive.Style.Paint.Color do
237
237
# ============================================================================
238
238
# data verification and serialization
239
239
240
- # --------------------------------------------------------
241
- # verify that a color is correctly described
242
- @ doc false
240
+ @ doc """
241
+ Verify that a color is correctly described
242
+ """
243
243
def verify ( color ) do
244
- try do
245
- normalize ( color )
246
- true
247
- rescue
248
- _ -> false
249
- end
244
+ normalize ( color )
245
+ true
246
+ rescue
247
+ _ -> false
250
248
end
251
249
252
250
# --------------------------------------------------------
@@ -280,7 +278,7 @@ defmodule Scenic.Primitive.Style.Paint.Color do
280
278
def to_rgba ( { :clear , _ } ) , do: to_rgba ( :transparent )
281
279
def to_rgba ( :clear ) , do: to_rgba ( :transparent )
282
280
283
- def to_rgba ( { r , g , b } ) , do: { r , g , b , 0xFF }
281
+ def to_rgba ( { r , g , b } ) , do: to_rgba ( { r , g , b , 0xFF } )
284
282
285
283
def to_rgba ( { r , g , b , a } )
286
284
when is_uint8 ( r ) and is_uint8 ( g ) and is_uint8 ( b ) and is_uint8 ( a ) do
@@ -290,12 +288,13 @@ defmodule Scenic.Primitive.Style.Paint.Color do
290
288
def to_rgba ( << r :: size ( 8 ) , g :: size ( 8 ) , b :: size ( 8 ) , a :: size ( 8 ) >> ) , do: { r , g , b , a }
291
289
292
290
def to_rgba ( named_color ) when is_atom ( named_color ) do
293
- name_to_rgb ( named_color )
291
+ named_color
292
+ |> name_to_rgb ( )
294
293
|> to_rgba ( )
295
294
end
296
295
297
296
def to_rgba ( { named_color , alpha } )
298
- when is_atom ( named_color ) and is_integer ( alpha ) and alpha >= 0 and alpha <= 255 do
297
+ when is_atom ( named_color ) and is_uint8 ( alpha ) do
299
298
{ r , g , b } = name_to_rgb ( named_color )
300
299
{ r , g , b , alpha }
301
300
end
0 commit comments