You are here

public static function ColorUtility::rgbaToOpacity in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Component/ColorUtility.php \Drupal\image_effects\Component\ColorUtility::rgbaToOpacity()
  2. 8.2 src/Component/ColorUtility.php \Drupal\image_effects\Component\ColorUtility::rgbaToOpacity()

Convert RGBA alpha to percent opacity.

Parameters

string $rgba: RGBA hexadecimal.

Return value

int Opacity as percentage (0 = transparent, 100 = fully opaque).

3 calls to ColorUtility::rgbaToOpacity()
GDOperationTrait::hexToRgba in src/Plugin/ImageToolkit/Operation/gd/GDOperationTrait.php
Convert a RGBA hex to its RGBA integer GD components.
ImageEffectsColor::processImageEffectsColor in src/Element/ImageEffectsColor.php
Processes a 'image_effects_color' form element.
image_effects_preprocess_image_effects_color_detail in ./image_effects.module
Prepares variables to get a color info.

File

src/Component/ColorUtility.php, line 45

Class

ColorUtility
Color handling methods for image_effects.

Namespace

Drupal\image_effects\Component

Code

public static function rgbaToOpacity($rgba) {
  $hex = Unicode::substr($rgba, 7, 2);
  return $hex ? floor(hexdec($hex) / 255 * 100) : 100;
}