All pastes #448623 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-19 19:40 UTC
rendered paste body
here's a neat little alias i just made, uses a bit of match to replicate mspaint's custom color definition grid:

[code]
alias blend {
  var %i = 0
  while (%i < 16385) {
    var %x = %i % 128, %y = $int($calc(%i / 128)), %quad = $int($calc(%x * 3 / 64)), %inv = 255 - %y, $&
      %mid = $int($calc((3 * %x / 64 - %quad) * (255 - 2 * %y))), %+ = %y + %mid, %- = %inv - %mid, %rgb
    if (%quad == 0) %rgb = %inv , %+ , %y 
    elseif (%quad == 1) %rgb = %- , %inv , %y 
    elseif (%quad == 2) %rgb = %y , %inv , %+ 
    elseif (%quad == 3) %rgb = %y , %- , %inv 
    elseif (%quad == 4) %rgb =  %+ , %y , %inv 
    else %rgb = %inv , %y , %-
    drawdot -r $1 $rgb( [ %rgb ] ) 1 $calc($2 + %x) $calc($3 + %y)
    inc %i
  }
}
[/code]

[b]/blend @window X Y[/b] to draw the grid at (X, Y) on @window

then you can let people mouse over a color, use $getdot(@window,$mouse.x,$mouse.y) to find its RGB value (maybe preview it in a larger square as in mspaint)

basically it's a grid 128 x 128 pixels which obviously can't represent all the possible RGB combinations (since theres 256 x 256 x 256 of them) but it displays enough such that you can get a nice looking blend effect