View Single Post
Old 12-15-2018, 08:27 PM   #15
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Here's a preset:
Code:
//RGB decompose
//@param 1:r.x "red x offset" 0 -100 100 0 1
//@param 2:r.y "red y offset" 0 -100 100 0 1
//@param 3:g.x "green x offset" 0 -100 100 0 1
//@param 4:g.y "green y offset" 0 -100 100 0 1
//@param 5:b.x "blue x offset" 0 -100 100 0 1
//@param 6:b.y "blue y offset" 0 -100 100 0 1

gdf=g.x != r.x || g.y != r.y;
bdf=b.x != r.x || b.y != r.y ? b.x != g.x || b.y != g.y ? 2 : 1;

function f(cp,r,g,b,x,y,w,h) local(tmp) global() (
  cp ? gfx_set(0,0,0,1,0, tmp = gfx_img_resize(tmp,w,h))
     : x||y?gfx_fillrect(0,0,w,h);

  gfx_blit(0, 0, cp?:x, cp?:y, w,h, 0,0,w,h);
  gfx_set(r,g,b,-1,1);
  r+g+b ? gfx_fillrect(0,0,w,h);
  gfx_set(0,0,0,1,1,-1);
  cp ? gfx_blit(tmp,0, x,y, w,h,0,0,w,h);
);

colorspace='RGBA';
input_info(0,project_w,project_h); 

        f(0, 0,gdf,bdf!=0,r.x,r.y,project_w,project_h);
gdf   ? f(1, 1,0,  bdf!=1,g.x,g.y,project_w,project_h);
bdf>1 ? f(1, 1,1,  0,     b.x,b.y,project_w,project_h);
It's perhaps a little more complicated than it needs to be, for the optimization of the cases where some of the three channels are aligned...
Justin is offline   Reply With Quote