fortplot_color_definitions Module

Color type definitions and constants for matplotlib-compatible color support

Provides: - Unified color type with RGBA support - Named color constants (CSS4/matplotlib standard) - Single letter color mappings - Utility functions for color validation



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: NUM_NAMED_COLORS = 20
character(len=12), public, parameter :: named_color_names(NUM_NAMED_COLORS) = ['red         ', 'green       ', 'blue        ', 'cyan        ', 'magenta     ', 'yellow      ', 'black       ', 'white       ', 'gray        ', 'orange      ', 'purple      ', 'brown       ', 'pink        ', 'olive       ', 'navy        ', 'lime        ', 'teal        ', 'silver      ', 'maroon      ', 'indigo      ']
real(kind=wp), public, parameter :: named_color_values(3,NUM_NAMED_COLORS) = reshape([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.5_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 1.0_wp, 0.5_wp, 0.5_wp, 0.5_wp, 1.0_wp, 0.647_wp, 0.0_wp, 0.5_wp, 0.0_wp, 0.5_wp, 0.647_wp, 0.165_wp, 0.165_wp, 1.0_wp, 0.753_wp, 0.796_wp, 0.5_wp, 0.5_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.5_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, 0.5_wp, 0.5_wp, 0.753_wp, 0.753_wp, 0.753_wp, 0.5_wp, 0.0_wp, 0.0_wp, 0.294_wp, 0.0_wp, 0.51_wp], [3, NUM_NAMED_COLORS])
character(len=1), public, parameter :: single_letters(8) = ['r', 'g', 'b', 'c', 'm', 'y', 'k', 'w']
integer, public, parameter :: letter_to_named(8) = [1, 2, 3, 4, 5, 6, 7, 8]

Derived Types

type, public ::  color_t

Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: r = 0.0_wp
real(kind=wp), public :: g = 0.0_wp
real(kind=wp), public :: b = 0.0_wp
real(kind=wp), public :: a = 1.0_wp
logical, public :: valid = .false.

Functions

public function clamp_to_unit(value) result(clamped)

Clamp value to [0,1] range

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: value

Return Value real(kind=wp)


Subroutines

public subroutine to_lowercase(str)

Convert string to lowercase in-place

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(inout), allocatable :: str

public subroutine to_lowercase_char(char)

Convert single character to lowercase

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(inout) :: char