/**
  * {@inheritdoc}
  */
 protected function viewValue(FieldItemInterface $item)
 {
     $opacity = $this->getFieldSetting('opacity');
     $settings = $this->getSettings();
     $color_hex = new ColorHex($item->color, $item->opacity);
     if ($opacity && $settings['opacity']) {
         $rgbtext = $color_hex->toRGB()->toString(TRUE);
     } else {
         $rgbtext = $color_hex->toRGB()->toString(FALSE);
     }
     return $rgbtext;
 }
 /**
  * {@inheritdoc}
  */
 protected function viewValue(FieldItemInterface $item)
 {
     $opacity = $this->getFieldSetting('opacity');
     $settings = $this->getSettings();
     $color_hex = new ColorHex($item->color, $item->opacity);
     switch ($settings['format']) {
         case 'hex':
             if ($opacity && $settings['opacity']) {
                 $output = $color_hex->toString(TRUE);
             } else {
                 $output = $color_hex->toString(FALSE);
             }
             break;
         case 'rgb':
             if ($opacity && $settings['opacity']) {
                 $output = $color_hex->toRGB()->toString(TRUE);
             } else {
                 $output = $color_hex->toRGB()->toString(FALSE);
             }
             break;
     }
     return $output;
 }