elemental pure subroutine convert(this, to)
class(color), intent(inout) :: this
character(len=*), intent(in) :: to
integer(ik) :: r, g, b
select case (to)
case ('rgb2hex')
call rgb_to_hex(this%r, this%g, this%b, this%hex)
case ('rgb2decimal')
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
case ('rgb2cmyk')
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
case ('rgb2hsv')
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
case ('rgb2hsl')
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
case ('rgb2xyz')
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('rgb2all')
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hex2rgb')
call hex_to_rgb(this%hex, this%r, this%g, this%b)
case ('hex2decimal')
call hex_to_rgb(this%hex, r, g, b)
call rgb_to_decimal(r, g, b, this%decimal)
case ('hex2cmyk')
call hex_to_rgb(this%hex, r, g, b)
call rgb_to_cmyk(r, g, b, this%c, this%m, this%y, this%k)
case ('hex2hsv')
call hex_to_rgb(this%hex, r, g, b)
call rgb_to_hsv(r, g, b, this%h, this%s, this%v)
case ('hex2hsl')
call hex_to_rgb(this%hex, r, g, b)
call rgb_to_hsl(r, g, b, this%hl, this%sl, this%vl)
case ('hex2xyz')
call hex_to_rgb(this%hex, r, g, b)
call rgb_to_xyz(r, g, b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hex2all')
call hex_to_rgb(this%hex, this%r, this%g, this%b)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('decimal2rgb')
call decimal_to_rgb(this%decimal, this%r, this%g, this%b)
case ('decimal2hex')
call decimal_to_rgb(this%decimal, r, g, b)
call rgb_to_hex(r, g, b, this%hex)
case ('decimal2cmyk')
call decimal_to_rgb(this%decimal, r, g, b)
call rgb_to_cmyk(r, g, b, this%c, this%m, this%y, this%k)
case ('decimal2hsv')
call decimal_to_rgb(this%decimal, r, g, b)
call rgb_to_hsv(r, g, b, this%h, this%s, this%v)
case ('decimal2hsl')
call decimal_to_rgb(this%decimal, r, g, b)
call rgb_to_hsl(r, g, b, this%hl, this%sl, this%vl)
case ('decimal2xyz')
call decimal_to_rgb(this%decimal, r, g, b)
call rgb_to_xyz(r, g, b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('decimal2all')
call decimal_to_rgb(this%decimal, this%r, this%g, this%b)
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('cmyk2rgb')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, this%r, this%g, this%b)
case ('cmyk2hex')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, r, g, b)
call rgb_to_hex(r, g, b, this%hex)
case ('cmyk2decimal')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, r, g, b)
call rgb_to_decimal(r, g, b, this%decimal)
case ('cmyk2hsv')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, r, g, b)
call rgb_to_hsv(r, g, b, this%h, this%s, this%v)
case ('cmyk2hsl')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, r, g, b)
call rgb_to_hsl(r, g, b, this%hl, this%sl, this%vl)
case ('cmyk2xyz')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, r, g, b)
call rgb_to_xyz(r, g, b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('cmyk2all')
call cmyk_to_rgb(this%c, this%m, this%y, this%k, this%r, this%g, this%b)
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hsv2rgb')
call hsv_to_rgb(this%h, this%s, this%v, this%r, this%g, this%b)
case ('hsv2hex')
call hsv_to_rgb(this%h, this%s, this%v, r, g, b)
call rgb_to_hex(r, g, b, this%hex)
case ('hsv2decimal')
call hsv_to_rgb(this%h, this%s, this%v, r, g, b)
call rgb_to_decimal(r, g, b, this%decimal)
case ('hsv2cmyk')
call hsv_to_rgb(this%h, this%s, this%v, r, g, b)
call rgb_to_cmyk(r, g, b, this%c, this%m, this%y, this%k)
case ('hsv2hsl')
call hsv_to_rgb(this%h, this%s, this%v, r, g, b)
call rgb_to_hsl(r, g, b, this%hl, this%sl, this%vl)
case ('hsv2xyz')
call hsv_to_rgb(this%h, this%s, this%v, r, g, b)
call rgb_to_xyz(r, g, b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hsv2all')
call hsv_to_rgb(this%h, this%s, this%v, this%r, this%g, this%b)
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hsl2hsv')
call hsl_to_rgb(this%hl, this%sl, this%vl, r, g, b)
call rgb_to_hsv(r, g, b, this%h, this%s, this%v)
case ('hsl2rgb')
call hsl_to_rgb(this%hl, this%sl, this%vl, this%r, this%g, this%b)
case ('hsl2hex')
call hsl_to_rgb(this%hl, this%sl, this%vl, r, g, b)
call rgb_to_hex(r, g, b, this%hex)
case ('hsl2decimal')
call hsl_to_rgb(this%hl, this%sl, this%vl, r, g, b)
call rgb_to_decimal(r, g, b, this%decimal)
case ('hsl2cmyk')
call hsl_to_rgb(this%hl, this%sl, this%vl, r, g, b)
call rgb_to_cmyk(r, g, b, this%c, this%m, this%y, this%k)
case ('hsl2xyz')
call hsl_to_rgb(this%hl, this%sl, this%vl, r, g, b)
call rgb_to_xyz(r, g, b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('hsl2all')
call hsl_to_rgb(this%hl, this%sl, this%vl, this%r, this%g, this%b)
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_xyz(this%r, this%g, this%b, this%xyz_x, this%xyz_y, this%xyz_z)
case ('xyz2rgb')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, this%r, this%g, this%b)
case ('xyz2hex')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, r, g, b)
call rgb_to_hex(r, g, b, this%hex)
case ('xyz2decimal')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, r, g, b)
call rgb_to_decimal(r, g, b, this%decimal)
case ('xyz2cmyk')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, r, g, b)
call rgb_to_cmyk(r, g, b, this%c, this%m, this%y, this%k)
case ('xyz2hsv')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, r, g, b)
call rgb_to_hsv(r, g, b, this%h, this%s, this%v)
case ('xyz2hsl')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, r, g, b)
call rgb_to_hsl(r, g, b, this%hl, this%sl, this%vl)
case ('xyz2all')
call xyz_to_rgb(this%xyz_x, this%xyz_y, this%xyz_z, this%r, this%g, this%b)
call rgb_to_hex(this%r, this%g, this%b, this%hex)
call rgb_to_decimal(this%r, this%g, this%b, this%decimal)
call rgb_to_cmyk(this%r, this%g, this%b, this%c, this%m, this%y, this%k)
call rgb_to_hsv(this%r, this%g, this%b, this%h, this%s, this%v)
call rgb_to_hsl(this%r, this%g, this%b, this%hl, this%sl, this%vl)
end select
end subroutine convert