summaryrefslogtreecommitdiffstats
path: root/lib/public/Color.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Color.php')
-rw-r--r--lib/public/Color.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/public/Color.php b/lib/public/Color.php
index e2cabd9c2fc..d5b2a92a6ac 100644
--- a/lib/public/Color.php
+++ b/lib/public/Color.php
@@ -126,6 +126,20 @@ class Color {
}
/**
+ * Alpha blend another color with a given opacity to this color
+ *
+ * @return Color The new color
+ * @since 25.0.0
+ */
+ public function alphaBlending(float $opacity, Color $source): Color {
+ return new Color(
+ (int)((1 - $opacity) * $source->red() + $opacity * $this->red()),
+ (int)((1 - $opacity) * $source->green() + $opacity * $this->green()),
+ (int)((1 - $opacity) * $source->blue() + $opacity * $this->blue())
+ );
+ }
+
+ /**
* Calculate steps between two Colors
* @param int $steps start color
* @param Color[] $ends end color