demo_color Program

Uses

  • program~~demo_color~~UsesGraph program~demo_color demo_color module~forimage forimage program~demo_color->module~forimage module~forcolor forcolor module~forimage->module~forcolor module~forimage_parameters forimage_parameters module~forimage->module~forimage_parameters module~lut lut module~forimage->module~lut module~pnm pnm module~forimage->module~pnm module~forcolor->module~forimage_parameters module~forcolor->module~pnm iso_fortran_env iso_fortran_env module~forimage_parameters->iso_fortran_env module~pnm->module~forimage_parameters

Calls

program~~demo_color~~CallsGraph program~demo_color demo_color proc~convert color%convert program~demo_color->proc~convert proc~find_nearest color%find_nearest program~demo_color->proc~find_nearest proc~get color%get program~demo_color->proc~get proc~print_available_colors color%print_available_colors program~demo_color->proc~print_available_colors proc~save_available_colors color%save_available_colors program~demo_color->proc~save_available_colors proc~set color%set program~demo_color->proc~set proc~cmyk_to_rgb cmyk_to_rgb proc~convert->proc~cmyk_to_rgb proc~decimal_to_rgb decimal_to_rgb proc~convert->proc~decimal_to_rgb proc~hex_to_rgb hex_to_rgb proc~convert->proc~hex_to_rgb proc~hsl_to_rgb hsl_to_rgb proc~convert->proc~hsl_to_rgb proc~hsv_to_rgb hsv_to_rgb proc~convert->proc~hsv_to_rgb proc~rgb_to_cmyk rgb_to_cmyk proc~convert->proc~rgb_to_cmyk proc~rgb_to_decimal rgb_to_decimal proc~convert->proc~rgb_to_decimal proc~rgb_to_hex rgb_to_hex proc~convert->proc~rgb_to_hex proc~rgb_to_hsl rgb_to_hsl proc~convert->proc~rgb_to_hsl proc~rgb_to_hsv rgb_to_hsv proc~convert->proc~rgb_to_hsv proc~rgb_to_xyz rgb_to_xyz proc~convert->proc~rgb_to_xyz proc~xyz_to_rgb xyz_to_rgb proc~convert->proc~xyz_to_rgb proc~get_rgb color%get_rgb proc~find_nearest->proc~get_rgb proc~initialize_colors initialize_colors proc~find_nearest->proc~initialize_colors proc~get_cmyk color%get_cmyk proc~get->proc~get_cmyk proc~get_decimal color%get_decimal proc~get->proc~get_decimal proc~get_hex color%get_hex proc~get->proc~get_hex proc~get_hsl color%get_hsl proc~get->proc~get_hsl proc~get_hsv color%get_hsv proc~get->proc~get_hsv proc~get_name color%get_name proc~get->proc~get_name proc~get->proc~get_rgb proc~get_xyz color%get_xyz proc~get->proc~get_xyz proc~print_available_colors->proc~initialize_colors proc~save_available_colors->proc~initialize_colors proc~set_by_name color%set_by_name proc~set->proc~set_by_name proc~set_cmyk color%set_cmyk proc~set->proc~set_cmyk proc~set_decimal color%set_decimal proc~set->proc~set_decimal proc~set_hex color%set_hex proc~set->proc~set_hex proc~set_hsl color%set_hsl proc~set->proc~set_hsl proc~set_hsv color%set_hsv proc~set->proc~set_hsv proc~set_name color%set_name proc~set->proc~set_name proc~set_rgb color%set_rgb proc~set->proc~set_rgb proc~set_xyz color%set_xyz proc~set->proc~set_xyz proc~initialize_colors->proc~convert proc~initialize_colors->proc~set proc~set_by_name->proc~initialize_colors

Variables

Type Attributes Name Initial
integer(kind=ik) :: b
integer(kind=ik) :: c
type(color) :: custom_color
integer(kind=ik) :: decimal
integer(kind=ik) :: g
real(kind=rk) :: h
character(len=7) :: hex
real(kind=rk) :: hl
integer(kind=ik) :: k
integer(kind=ik) :: m
type(color) :: nearest_color
integer(kind=ik) :: r
real(kind=rk) :: s
real(kind=rk) :: sl
real(kind=rk) :: v
real(kind=rk) :: vl
real(kind=rk) :: xyz_x
real(kind=rk) :: xyz_y
real(kind=rk) :: xyz_z
integer(kind=ik) :: y

Source Code

program demo_color

   use forimage, only: rk, ik, color
   implicit none

   type(color)      :: custom_color, nearest_color
   integer(ik)      :: r, g, b
   character(len=7) :: hex
   integer(ik)      :: decimal
   integer(ik)      :: c, m, y, k
   real(rk)         :: h, s, v
   real(rk)         :: hl, sl, vl
   real(rk)         :: xyz_x, xyz_y, xyz_z


   ! Set the color using RGB values
   call custom_color%set(name='custom_color', r=245_ik, g=127_ik, b=64_ik)

   ! Convert the color to other color spaces
   call custom_color%convert('rgb2all')

   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a hex value
   call custom_color%set(name='custom_color', hex='#F57F40')

   ! Convert the color to other color spaces
   call custom_color%convert('hex2all')


   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a decimal value
   call custom_color%set(name='custom_color', decimal=16088896_ik)

   ! Convert the color to other color spaces
   call custom_color%convert('decimal2all')


   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a decimal value
   call custom_color%set(name='custom_color', c=0_ik, m=48_ik, y=74_ik, k=4_ik)

   ! Convert the color to other color spaces
   call custom_color%convert('cmyk2all')


   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a hsv value
   call custom_color%set(name='custom_color', h=20.8840_rk, s=73.8776_rk, v=96.0784_rk)

   ! Convert the color to other color spaces
   call custom_color%convert('hsv2all')


   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a hsv value
   call custom_color%set(name='custom_color', hl=20.8840_rk, sl=90.0498_rk, vl=60.5882_rk)

   ! Convert the color to other color spaces
   call custom_color%convert('hsl2all')


   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Set the color using a hsv value
   call custom_color%set(name='custom_color', xyz_x=46.1753_rk, xyz_y=34.9669_rk, xyz_z=9.1672_rk)

   ! Convert the color to other color spaces
   call custom_color%convert('xyz2all')

   ! Get the values of the color in other color spaces
   call custom_color%get(r=r, g=g, b=b)
   call custom_color%get(hex=hex)
   call custom_color%get(decimal=decimal)
   call custom_color%get(c=c, m=m, y=y, k=k)
   call custom_color%get(h=h, s=s, v=v)
   call custom_color%get(hl=hl, sl=sl, vl=vl)
   call custom_color%get(xyz_x=xyz_x, xyz_y=xyz_y, xyz_z=xyz_z)

   ! Print the name and color values
   call custom_color%print()



   ! Print and save the available colors
   call custom_color%print_available_colors()
   call custom_color%save_available_colors()



   ! Set a color using the name of a color from the available colors
   call custom_color%set('red', use_library=.true.)
   call custom_color%print()



   ! Set the color using specific RGB values
   call custom_color%set(name='custom_color', r=100_ik, g=30_ik, b=30_ik)

   print'(a)', 'Find the nearest color to the custom color'
   call custom_color%find_nearest(nearest_color)

   ! Print the name and values of the nearest color
   call nearest_color%print()

end program demo_color