function ToolkitGdTest::colorsAreEqual
Function to compare two colors by RGBa.
1 call to ToolkitGdTest::colorsAreEqual()
- ToolkitGdTest::testManipulations in core/
tests/ Drupal/ KernelTests/ Core/ Image/ ToolkitGdTest.php - Since PHP can't visually check that our images have been manipulated properly, build a list of expected color values for each of the corners and the expected height and widths for the final images.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Image/ ToolkitGdTest.php, line 71
Class
- ToolkitGdTest
- Tests that core image manipulations work properly: scale, resize, rotate, crop, scale and crop, and desaturate.
Namespace
Drupal\KernelTests\Core\ImageCode
public function colorsAreEqual($color_a, $color_b) {
// Fully transparent pixels are equal, regardless of RGB.
if ($color_a[3] == 127 && $color_b[3] == 127) {
return TRUE;
}
foreach ($color_a as $key => $value) {
if ($color_b[$key] != $value) {
return FALSE;
}
}
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.