foresight_palette
foresight_palette, gnuplot color palettes: gray levels (0 to 1) to colors, for images and color boxes.
As gnuplot 6.0 (values checked against its test palette tables): rgbformulae R,G,B (the default 7,5,15: sqrt, cube, sin 2pi) with gnuplot's 37 formulae, a negative number meaning the formula of 1 - gray; defined (v1 c1, ...) interpolating linearly in RGB between colors (#rrggbb or a gnuplot color name) at increasing values; gray (gray to the power 1/1.5, gnuplot's gamma); viridis; negative reverses the gray axis; maxcolors N quantizes: band k = floor(gray N) takes the color of gray k / (N - 1). Channels are rounded to 8 bits.
Source: src/lib/foresight_palette.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
PAL_FORMULAE | integer(kind=I4P) | parameter | rgbformulae. |
PAL_DEFINED | integer(kind=I4P) | parameter | defined. |
PAL_GRAY | integer(kind=I4P) | parameter | gray. |
PAL_VIRIDIS | integer(kind=I4P) | parameter | viridis. |
VIRIDIS | character(len=*) | parameter | viridis, 256 colors as rrggbb (gnuplot 6.0 set palette viridis). |
Derived Types
palette_object
Color palette.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
mode | integer(kind=I4P) | Palette kind. | |
formulae | integer(kind=I4P) | gnuplot rgbformulae, R, G, B. | |
negative | logical | Gray axis reversed. | |
maxcolors | integer(kind=I4P) | Colors of a quantized palette, 0 for continuous. | |
positions | real(kind=R8P) | allocatable | defined positions, increasing. |
colors | real(kind=R8P) | allocatable | defined colors (RGB 0..1, position). |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
is_default | pass(self) | Whether the palette is gnuplot's default. |
rgb | pass(self) | Color of a gray level, 8-bit channels. |
Subroutines
named_color
Channels of a color: #rrggbb or one of gnuplot's names (black, white, red, green, blue, yellow, cyan, magenta, gray, grey, orange, purple, dark-green, dark-blue, brown, violet, navy).
Attributes: pure
subroutine named_color(name, c, ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
name | character(len=*) | in | Color. | |
c | integer(kind=I4P) | out | Red, green, blue, 0..255. | |
ok | logical | out | Color known. |
Call graph
palette_words
Update palette from gnuplot set palette words: none (the default), rgbformulae R , G , B (rgb), defined (v c, ...), gray/grey, color, viridis, positive, negative, maxcolors N, model RGB; bad is the first word not understood.
subroutine palette_words(words, palette, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
words | character(len=*) | in | Words, blank separated (a defined list one word). | |
palette | type(palette_object) | inout | Palette. | |
bad | character(len=:) | out | allocatable | First word not understood, empty if none. |
Call graph
Functions
is_default
Whether the palette has gnuplot's default colors: rgbformulae 7,5,15, positive (quantized or not).
Attributes: elemental
Returns: logical
function is_default(self) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(palette_object) | in | Palette. |
Call graph
rgb
Color of the gray level gray (clamped to 0..1), 8-bit channels.
Attributes: pure
Returns: integer(kind=I4P)
function rgb(self, gray) result(c)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(palette_object) | in | Palette. | |
gray | real(kind=R8P) | in | Gray level. |
Call graph
hex_color
#rrggbb of the 8-bit channels c.
Attributes: pure
Returns: character(len=7)
function hex_color(c) result(hex)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
c | integer(kind=I4P) | in | Red, green, blue. |
hex_channels
Channels of rrggbb (0..255, as reals).
Attributes: pure
Returns: real(kind=R8P)
function hex_channels(hex) result(c)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
hex | character(len=6) | in | Hexadecimal color. |
Call graph
formula
gnuplot rgbformula n (-36..36, negative for the formula of 1 - x) at x, clamped to 0..1.
Attributes: pure
Returns: real(kind=R8P)
function formula(n, x) result(f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
n | integer(kind=I4P) | in | Formula number. | |
x | real(kind=R8P) | in | Gray level. |
Call graph