@@ -237,16 +237,14 @@ defmodule Scenic.Primitive.Style.Paint.Color do
237237 # ============================================================================
238238 # data verification and serialization
239239
240- # --------------------------------------------------------
241- # verify that a color is correctly described
242- @ doc false
240+ @ doc """
241+ Verify that a color is correctly described
242+ """
243243 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
250248 end
251249
252250 # --------------------------------------------------------
@@ -280,7 +278,7 @@ defmodule Scenic.Primitive.Style.Paint.Color do
280278 def to_rgba ( { :clear , _ } ) , do: to_rgba ( :transparent )
281279 def to_rgba ( :clear ) , do: to_rgba ( :transparent )
282280
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 } )
284282
285283 def to_rgba ( { r , g , b , a } )
286284 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
290288 def to_rgba ( << r :: size ( 8 ) , g :: size ( 8 ) , b :: size ( 8 ) , a :: size ( 8 ) >> ) , do: { r , g , b , a }
291289
292290 def to_rgba ( named_color ) when is_atom ( named_color ) do
293- name_to_rgb ( named_color )
291+ named_color
292+ |> name_to_rgb ( )
294293 |> to_rgba ( )
295294 end
296295
297296 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
299298 { r , g , b } = name_to_rgb ( named_color )
300299 { r , g , b , alpha }
301300 end
0 commit comments