color Derived Type

type, public :: color

Describes an RGB color.


Contents


Components

Type Visibility Attributes Name Initial
integer(kind=int32), public :: blue = 255

The blue component of the color (must be between 0 and 255).

integer(kind=int32), public :: green = 0

The green component of the color (must be between 0 and 255).

integer(kind=int32), public :: red = 0

The red component of the color (must be between 0 and 255).


Type-Bound Procedures

procedure, public, pass :: copy_from => clr_copy_from

  • private subroutine clr_copy_from(this, clr)

    Copies another color to this color.

    Arguments

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

    The color object.

    class(color), intent(in) :: clr

    The color to copy.

procedure, public, pass :: to_hex_string => clr_to_hex_string

  • private pure function clr_to_hex_string(this) result(txt)

    Returns the color in hexadecimal format.

    Arguments

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

    The color object.

    Return Value character(len=6)

    A string containing the hexadecimal equivalent.