Package: gdk

Function gdk:rgba-parse

Lambda List

gdk:rgba-parse (str)

Arguments

str -- a string specifying the color

Return Value

The newly created gdk:rgba instance with the filled in values, or nil.

Details

Parses a textual representation of a color, and returns a RGBA instance filling in the red, green, blue and alpha fields. If the given textual representation is not recognized, nil is returned. The string can be either one of:
  • A standard name taken from the CSS specification.
  • A hexadecimal value in the form #rgb, #rrggbb, #rrrgggbbb or #rrrrggggbbbb.
  • A hexadecimal value in the form #rgba, #rrggbbaa, or #rrrrggggbbbbaaaa.
  • A RGB color in the form rgb(r,g,b). In this case the color will have full opacity.
  • A RGBA color in the form rgba(r,g,b,a).
  • A HSL color in the form hsl(h,s,l.
  • A HSL color in the form hsl(h,s,l,a.
Where r, g, b and a are respectively the red, green, blue and alpha color values. In the last two cases, r, g and b are either integers in the range 0 to 255 or precentage values in the range 0% to 100%, and a is a floating point value in the range 0.0 to 1.0. The range for h is 0 to 360, and s, l can be either numbers in the range 0 to 100 or percentages.

Examples

(gdk:rgba-parse "LightGreen")
=> #S(GDK-RGBA :RED 0.5647059
               :GREEN 0.93333334
               :BLUE 0.5647059
               :ALPHA 1.0)
(gdk:rgba-parse "#90ee90")
=> #S(GDK-RGBA :RED 0.5647059
               :GREEN 0.93333334
               :BLUE 0.5647059
               :ALPHA 1.0)
(gdk:rgba-parse "unknown") => NIL    
 

See also

2026-08-01