forcolor Module


Uses

  • module~~forcolor~~UsesGraph module~forcolor forcolor module~forimage_parameters forimage_parameters module~forcolor->module~forimage_parameters module~pnm pnm module~forcolor->module~pnm iso_fortran_env iso_fortran_env module~forimage_parameters->iso_fortran_env module~pnm->module~forimage_parameters

Used by

  • module~~forcolor~~UsedByGraph module~forcolor forcolor module~forimage forimage module~forimage->module~forcolor program~demo_color demo_color program~demo_color->module~forimage program~demo_ppm demo_ppm program~demo_ppm->module~forimage program~example26 example26 program~example26->module~forimage program~example27 example27 program~example27->module~forimage program~example28 example28 program~example28->module~forimage program~example29 example29 program~example29->module~forimage program~test test program~test->module~forimage program~test1 test1 program~test1->module~forimage program~test10 test10 program~test10->module~forimage program~test11 test11 program~test11->module~forimage program~test12 test12 program~test12->module~forimage program~test13 test13 program~test13->module~forimage program~test14 test14 program~test14->module~forimage program~test15 test15 program~test15->module~forimage program~test16 test16 program~test16->module~forimage program~test17 test17 program~test17->module~forimage program~test18 test18 program~test18->module~forimage program~test19 test19 program~test19->module~forimage program~test2 test2 program~test2->module~forimage program~test20 test20 program~test20->module~forimage program~test21 test21 program~test21->module~forimage program~test22 test22 program~test22->module~forimage program~test23 test23 program~test23->module~forimage program~test24 test24 program~test24->module~forimage program~test25 test25 program~test25->module~forimage program~test3 test3 program~test3->module~forimage program~test4 test4 program~test4->module~forimage program~test6 test6 program~test6->module~forimage program~test7 test7 program~test7->module~forimage program~test8 test8 program~test8->module~forimage program~test9 test9 program~test9->module~forimage

Derived Types

type, public ::  color

Components

Type Visibility Attributes Name Initial
integer(kind=ik), private :: b = 0_ik

rgb

integer(kind=ik), private :: c = 0_ik

cmyk

character(len=256), private :: color_name

color name

integer(kind=ik), private :: decimal = 0_ik

decimal

integer(kind=ik), private :: g = 0_ik

rgb

real(kind=rk), private :: h = 0.0_rk

hsv

character(len=7), private :: hex = '#000000'

hex

real(kind=rk), private :: hl = 0.0_rk

hsl

integer(kind=ik), private :: k = 0_ik

cmyk

integer(kind=ik), private :: m = 0_ik

cmyk

integer(kind=ik), private :: r = 0_ik

rgb

real(kind=rk), private :: s = 0.0_rk

hsv

real(kind=rk), private :: sl = 0.0_rk

hsl

real(kind=rk), private :: v = 0.0_rk

hsv

real(kind=rk), private :: vl = 0.0_rk

hsl

real(kind=rk), private :: xyz_x = 0.0_rk

xyz

real(kind=rk), private :: xyz_y = 0.0_rk

xyz

real(kind=rk), private :: xyz_z = 0.0_rk

xyz

integer(kind=ik), private :: y = 0_ik

cmyk

Type-Bound Procedures

generic, public :: assignment(=) => copy_color
procedure, public :: convert
procedure, public :: find_nearest
procedure, public :: get
procedure, public :: get_b
procedure, public :: get_g
procedure, public :: get_r
procedure, public :: print
procedure, public :: print_available_colors
procedure, public :: save
procedure, public :: save_available_colors
procedure, public :: set
procedure, private :: copy_color
procedure, private :: get_cmyk
procedure, private :: get_decimal
procedure, private :: get_hex
procedure, private :: get_hsl
procedure, private :: get_hsv
procedure, private :: get_name
procedure, private :: get_rgb
procedure, private :: get_xyz
procedure, private :: print_cmyk
procedure, private :: print_decimal
procedure, private :: print_hex
procedure, private :: print_hsl
procedure, private :: print_hsv
procedure, private :: print_name
procedure, private :: print_rgb
procedure, private :: print_xyz
procedure, private :: set_by_name
procedure, private :: set_cmyk
procedure, private :: set_decimal
procedure, private :: set_hex
procedure, private :: set_hsl
procedure, private :: set_hsv
procedure, private :: set_name
procedure, private :: set_rgb
procedure, private :: set_xyz

Functions

private pure elemental function get_b(this) result(b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

Return Value integer(kind=ik)

private pure elemental function get_g(this) result(g)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

Return Value integer(kind=ik)

private pure elemental function get_r(this) result(r)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

Return Value integer(kind=ik)


Subroutines

private pure elemental subroutine cmyk_to_rgb(c, m, y, k, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: c
integer(kind=ik), intent(in) :: m
integer(kind=ik), intent(in) :: y
integer(kind=ik), intent(in) :: k
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure elemental subroutine convert(this, to)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in) :: to

private pure elemental subroutine copy_color(this, from)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
class(color), intent(in) :: from

private pure elemental subroutine decimal_to_rgb(decimal, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: decimal
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure elemental subroutine find_nearest(this, nearest_color)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
type(color), intent(out) :: nearest_color

private pure elemental subroutine get(this, name, r, g, b, c, m, y, k, decimal, hex, h, s, v, hl, sl, vl, xyz_x, xyz_y, xyz_z)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(out), optional :: name
integer(kind=ik), intent(out), optional :: r
integer(kind=ik), intent(out), optional :: g
integer(kind=ik), intent(out), optional :: b
integer(kind=ik), intent(out), optional :: c
integer(kind=ik), intent(out), optional :: m
integer(kind=ik), intent(out), optional :: y
integer(kind=ik), intent(out), optional :: k
integer(kind=ik), intent(out), optional :: decimal
character(len=7), intent(out), optional :: hex
real(kind=rk), intent(out), optional :: h
real(kind=rk), intent(out), optional :: s
real(kind=rk), intent(out), optional :: v
real(kind=rk), intent(out), optional :: hl
real(kind=rk), intent(out), optional :: sl
real(kind=rk), intent(out), optional :: vl
real(kind=rk), intent(out), optional :: xyz_x
real(kind=rk), intent(out), optional :: xyz_y
real(kind=rk), intent(out), optional :: xyz_z

private pure elemental subroutine get_cmyk(this, c, m, y, k)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
integer(kind=ik), intent(out) :: c
integer(kind=ik), intent(out) :: m
integer(kind=ik), intent(out) :: y
integer(kind=ik), intent(out) :: k

private pure elemental subroutine get_decimal(this, decimal)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
integer(kind=ik), intent(out) :: decimal

private pure elemental subroutine get_hex(this, hex)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
character(len=*), intent(out) :: hex

private pure elemental subroutine get_hsl(this, h, s, l)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
real(kind=rk), intent(out) :: h
real(kind=rk), intent(out) :: s
real(kind=rk), intent(out) :: l

private pure elemental subroutine get_hsv(this, h, s, v)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
real(kind=rk), intent(out) :: h
real(kind=rk), intent(out) :: s
real(kind=rk), intent(out) :: v

private pure elemental subroutine get_name(this, name)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
character(len=*), intent(out) :: name

private pure elemental subroutine get_rgb(this, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure elemental subroutine get_xyz(this, x, y, z)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this
real(kind=rk), intent(out) :: x
real(kind=rk), intent(out) :: y
real(kind=rk), intent(out) :: z

private pure elemental subroutine hex_to_rgb(hex, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: hex
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure elemental subroutine hsl_to_rgb(h, s, l, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: h
real(kind=rk), intent(in) :: s
real(kind=rk), intent(in) :: l
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure elemental subroutine hsv_to_rgb(h, s, v, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: h
real(kind=rk), intent(in) :: s
real(kind=rk), intent(in) :: v
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b

private pure subroutine initialize_colors(colors)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
type(color), intent(out), dimension(:), allocatable :: colors

private impure elemental subroutine print(this, option)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in), optional :: option

private impure elemental subroutine print_available_colors(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this

private impure elemental subroutine print_cmyk(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_decimal(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_hex(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_hsl(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_hsv(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_name(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_rgb(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private impure elemental subroutine print_xyz(this)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(in) :: this

private pure elemental subroutine rgb_to_cmyk(r, g, b, c, m, y, k)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
integer(kind=ik), intent(out) :: c
integer(kind=ik), intent(out) :: m
integer(kind=ik), intent(out) :: y
integer(kind=ik), intent(out) :: k

private pure elemental subroutine rgb_to_decimal(r, g, b, decimal)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
integer(kind=ik), intent(out) :: decimal

private pure elemental subroutine rgb_to_hex(r, g, b, hex)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
character(len=7), intent(out) :: hex

private pure elemental subroutine rgb_to_hsl(r, g, b, h, s, l)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
real(kind=rk), intent(out) :: h
real(kind=rk), intent(out) :: s
real(kind=rk), intent(out) :: l

private pure elemental subroutine rgb_to_hsv(r, g, b, h, s, v)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
real(kind=rk), intent(out) :: h
real(kind=rk), intent(out) :: s
real(kind=rk), intent(out) :: v

private pure elemental subroutine rgb_to_xyz(r, g, b, x, y, z)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b
real(kind=rk), intent(out) :: x
real(kind=rk), intent(out) :: y
real(kind=rk), intent(out) :: z

private impure elemental subroutine save(this, file_name, height, width)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in), optional :: file_name
integer, intent(in), optional :: height
integer, intent(in), optional :: width

private impure elemental subroutine save_available_colors(this, file_name, height, width)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in), optional :: file_name
integer, intent(in), optional :: height
integer, intent(in), optional :: width

private pure elemental subroutine set(this, name, r, g, b, c, m, y, k, decimal, hex, h, s, v, hl, sl, vl, xyz_x, xyz_y, xyz_z, use_library)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in) :: name
integer(kind=ik), intent(in), optional :: r
integer(kind=ik), intent(in), optional :: g
integer(kind=ik), intent(in), optional :: b
integer(kind=ik), intent(in), optional :: c
integer(kind=ik), intent(in), optional :: m
integer(kind=ik), intent(in), optional :: y
integer(kind=ik), intent(in), optional :: k
integer(kind=ik), intent(in), optional :: decimal
character(len=*), intent(in), optional :: hex
real(kind=rk), intent(in), optional :: h
real(kind=rk), intent(in), optional :: s
real(kind=rk), intent(in), optional :: v
real(kind=rk), intent(in), optional :: hl
real(kind=rk), intent(in), optional :: sl
real(kind=rk), intent(in), optional :: vl
real(kind=rk), intent(in), optional :: xyz_x
real(kind=rk), intent(in), optional :: xyz_y
real(kind=rk), intent(in), optional :: xyz_z
logical, intent(in), optional :: use_library

private pure elemental subroutine set_by_name(this, name)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in) :: name

private pure elemental subroutine set_cmyk(this, c, m, y, k)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
integer(kind=ik), intent(in) :: c
integer(kind=ik), intent(in) :: m
integer(kind=ik), intent(in) :: y
integer(kind=ik), intent(in) :: k

private pure elemental subroutine set_decimal(this, decimal)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
integer(kind=ik), intent(in) :: decimal

private pure elemental subroutine set_hex(this, hex)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in) :: hex

private pure elemental subroutine set_hsl(this, h, s, l)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
real(kind=rk), intent(in) :: h
real(kind=rk), intent(in) :: s
real(kind=rk), intent(in) :: l

private pure elemental subroutine set_hsv(this, h, s, v)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
real(kind=rk), intent(in) :: h
real(kind=rk), intent(in) :: s
real(kind=rk), intent(in) :: v

private pure elemental subroutine set_name(this, name)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
character(len=*), intent(in) :: name

private pure elemental subroutine set_rgb(this, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
integer(kind=ik), intent(in) :: r
integer(kind=ik), intent(in) :: g
integer(kind=ik), intent(in) :: b

private pure elemental subroutine set_xyz(this, x, y, z)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
class(color), intent(inout) :: this
real(kind=rk), intent(in) :: x
real(kind=rk), intent(in) :: y
real(kind=rk), intent(in) :: z

private pure elemental subroutine xyz_to_rgb(x, y, z, r, g, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: x
real(kind=rk), intent(in) :: y
real(kind=rk), intent(in) :: z
integer(kind=ik), intent(out) :: r
integer(kind=ik), intent(out) :: g
integer(kind=ik), intent(out) :: b