+/*
+ * Multiply two colors together.
+ */
+INLINE_MAYBE
+color_t color_mult(color_t c1, color_t c2)
+{
+ c1.r *= c2.r;
+ c1.g *= c2.g;
+ c1.b *= c2.b;
+ return c1;
+}
+
+/*
+ * Scale a color by some scalar coefficient.
+ */
+INLINE_MAYBE
+color_t color_scale(color_t c, scal_t k)
+{
+ c.r *= k;
+ c.g *= k;
+ c.b *= k;
+ return c;
+}
+
+/*
+ * Scale a color by another color and some scalar coefficient.
+ */
+INLINE_MAYBE
+color_t color_scale2(color_t c1, color_t c2, scal_t k)
+{
+ return color_scale(color_mult(c1, c2), k);
+}
+
+INLINE_MAYBE
+color_t color_blend(color_t d, color_t s)
+{
+ d.r = (S(1.0) - s.a) * d.r + s.a * s.r;
+ d.g = (S(1.0) - s.a) * d.g + s.a * s.g;
+ d.b = (S(1.0) - s.a) * d.b + s.a * s.b;
+ return d;
+}
+