COLOR_NAME2RGB(3f) - [M_color] returns the RGB values in the range 0 to 100 for a given known color name. (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
subroutine color_name2rgb(name,r,g,b,echoname)
character(len=20),intent(in) :: name real,intent(out) :: r,g,b character(len=20),intent(out) :: echoname
COLOR_NAME2RGB(3f) returns the RGB values in the range 0 to 100 for a given known color name. Most X11 Windows color names are supported. If the name is not found ECHONAME is set to "Unknown".Note that an integer converted to a string can be used to go sequentially thru the names until ECHONAME="Unknown"
name The name of the color to resolve to RGB values It may also be an integer from 1 to N, where N+1 will return echoname="Unknown"
r,g,b Integer values in the range of 0 to 100 representing the colors in terms of Red, Green, and Blue component values. echoname returns color name in ECHONAME. This is usually not useful as it just echoes the input name unless the input name was a numeric string.
A sample program:
program demo_color_name2rgb use M_color, only : hue, color_name2rgb implicit none ! ! list colors known to colorname2rgb(3f) & corresponding RGB values ! character(len=20) :: name character(len=20) :: echoname real :: red,green,blue integer :: i TRYALL: do i=1,10000 ! color names may be numeric strings from 1 to N write(name,(i0))i ! get the RGB values and English name of the color call color_name2rgb(name,red,green,blue,echoname) ! the last color name is "Unknown" so the loop should exit if(echoname == Unknown)exit TRYALL ! display the English name and RGB values for the name write(*,*)echoname,int([red,green,blue]) enddo TRYALL !write(*,*)Number of colors found is ,i-1 end program demo_color_name2rgb
John S. Urban
Public Domain
Nemo Release 3.1 | color_name2rgb (3) | February 23, 2025 |