rgba
1 Overview
2 Predicates
rgba/  color?
rgba/  alpha?
3 Structure Type
rgba
4 Conversion
rgba->string
string->rgba
9.1

rgba🔗ℹ

Hans Dijkema <hans@dijkewijk.nl>

 (require rgba)

RGBA color support used by the webview library.

This module exports a transparent rgba structure together with predicates and conversion procedures for working with CSS-style color values.

1 Overview🔗ℹ

An rgba value represents a color using red, green, blue, and alpha components.

The module provides:

  • the rgba structure type

  • predicates for validating component values

  • conversion from strings to rgba values

  • conversion from rgba values to CSS color strings

The intended external representation is the CSS form:

"rgba(r,g,b,a)"

2 Predicates🔗ℹ

procedure

(rgba/color? v)  boolean?

  v : any/c
Recognizes valid red, green, and blue component values.

A valid color component is an exact integer in the range from 0 to 255, inclusive.

procedure

(rgba/alpha? v)  boolean?

  v : any/c
Recognizes valid alpha component values.

A valid alpha component is a real number in the range from 0 to 1, inclusive.

3 Structure Type🔗ℹ

struct

(struct rgba (r g b a))

  r : rgba/color?
  g : rgba/color?
  b : rgba/color?
  a : rgba/alpha?
Represents one RGBA color value.

The fields r, g, and b are the red, green, and blue components. The field a is the alpha component.

The structure is transparent.

4 Conversion🔗ℹ

procedure

(rgba->string c)  string?

  c : rgba?
Converts c to a CSS color string.

The result has the form:

"rgba(r,g,b,a)"

procedure

(string->rgba s)  (or/c rgba? #f)

  s : string?
Attempts to parse s as a CSS RGBA color string.

If parsing succeeds, the result is an rgba value. If parsing fails, the result is #f.

The accepted input format is the one produced by rgba->string, namely:

"rgba(r,g,b,a)"