Remove Alpha Channel

Description

Remove alpha channel from the color object, if defined (see hasalpha). Works for all colorobjects.

Usage

CIEXYZ.dropalpha()

Examples

from colorspace.colorlib import HCL, sRGB, HSV
# Example using HCL colors
cols = HCL([0, 40, 80],
           [30, 60, 80],
           [85, 60, 35],
           alpha = [1.0, 0.5, 0.1])
cols # with alpha channel
polarLUV color object (3 colors)
            H       C       L   alpha
  1:     0.00   30.00   85.00    1.00
        40.00   60.00   60.00    0.50
        80.00   80.00   35.00    0.10
cols.dropalpha()
cols # alpha channel removed
polarLUV color object (3 colors)
            H       C       L
  1:     0.00   30.00   85.00
        40.00   60.00   60.00
        80.00   80.00   35.00
# No effect if there is no alpha channel
cols.dropalpha()
cols
polarLUV color object (3 colors)
            H       C       L
  1:     0.00   30.00   85.00
        40.00   60.00   60.00
        80.00   80.00   35.00
# Example using sRGB colors
cols = sRGB([0.01, 0.89, 0.56],
            [0.25, 0.89, 0.02],
            [0.65, 0.89, 0.23],
            alpha = [1.0, 0.5, 0.1])
cols # with alpha channel
sRGB color object (3 colors)
            R       G       B   alpha
  1:     0.01    0.25    0.65    1.00
         0.89    0.89    0.89    0.50
         0.56    0.02    0.23    0.10
cols.dropalpha()
cols # alpha channel removed
sRGB color object (3 colors)
            R       G       B
  1:     0.01    0.25    0.65
         0.89    0.89    0.89
         0.56    0.02    0.23
# Example using HSV colors
cols = HSV([218, 0, 336],
           [1, 0, 1],
           [0.65, 0.89, 0.56],
           alpha = [1.0, 0.5, 0.1])
cols # with alpha channel
HSV color object (3 colors)
            H       S       V   alpha
  1:   218.00    1.00    0.65    1.00
         0.00    0.00    0.89    0.50
       336.00    1.00    0.56    0.10
cols.dropalpha()
cols # alpha channel removed
HSV color object (3 colors)
            H       S       V
  1:   218.00    1.00    0.65
         0.00    0.00    0.89
       336.00    1.00    0.56