Skip to content

Instantly share code, notes, and snippets.

View thegroovetrain's full-sized avatar

Eric Seibt thegroovetrain

View GitHub Profile
@thegroovetrain
thegroovetrain / mix_tint_tone_shade.php
Last active February 20, 2021 18:57 — forked from andrewrcollins/mix_tint_tone_shade.php
Color Mixing, Tint, Tone, and Shade in PHP
<?php
function mix($color_1 = array(0, 0, 0), $color_2 = array(0, 0, 0), $weight = 0.5)
{
$f = function($x) use ($weight) { return (1 - $weight) * $x; };
$g = function($x) use ($weight) { return $weight * $x; };
$h = function($x, $y) { return round($x + $y); };
return array_map($h, array_map($f, $color_1), array_map($g, $color_2));
}