RGBMixer - An alias to equally blend two rgb values

By SReject on Apr 18, 2014

This alias takes two color sets and equally blends them. The alias accepts either r,g,b or their respective values.

To use:
$RGBMixer(r1, g1, b1, r2, g2, b2)
mixes rgb color sets into a single rgb value

$RGBMixer(color1, color2)
Blends the two rgb color values into a single rgb value

alias RGBMixer {
  if ($0 != 2 && $0 != 6) || (!$regex($replace($1-,$chr(32),),/^\d+$/)) {
    return -1
  }
  if ($0 == 2) {
    tokenize 44 $rgb($1) $+ , $+ $rgb($2)
  }

  var %r = $iif($round($calc(($1 + $4) / 2), 0) > 255, 255, $iif($v1 < 0, 0, $v1))
  var %g = $iif($round($calc(($2 + $5) / 2), 0) > 255, 255, $iif($v1 < 0, 0, $v1))
  var %b = $iif($round($calc(($3 + $6) / 2), 0) > 255, 255, $iif($v1 < 0, 0, $v1))
  return $rgb(%r, %g, %b)
}

Comments

Sign in to comment.
Meta   -  Apr 19, 2014

Shouldn't you be adding the two like values together and dividing by two..?

SReject  -  Apr 19, 2014

Oops, yea. thanx. the subtraction was from another alias I was working on that allowed ratio blending >.>

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.