# Blending two overlapping images (script by Sanke, May 2009). # This script assumes that the two images are of the same height. on mouseUp put the imagedata of img 1 into tid1 put the height of img 1 into h1 put the width of img 1 into w1 put the imagedata of img 2 into tid2 put the height of img 2 into h2 put the width of img 2 into w2 put min(w1,w2) into tmin ask "blending range? (max "&tmin-1&")" with trunc(tmin/2) wait 3 milliseconds put it into tblendrange if it is empty then exit to top if tblendrange > tmin - 1 then answer "Chosen blending range exceeds possible maximum!"&CR&"Choose again." exit to top end if if tblendrange = 0 then put 1 into tblendrange put (100/tblendrange) into tblendstep lock screen set the height of img 3 to h2 put w1 + w2 into w3 set the width of img 3 to w3 - tblendrange put the width of img 3 into w3 put the imagedata of img 3 into tid3 put w1*4 into trow1 put w2*4 into trow2 put w3*4 into trow3 put (w1 - 1)-tblendrange into tj1End put (tj1End + tblendrange) into tj1End2 repeat with i = 0 to h2-1 put i*trow1 into ti1 put i*trow2 into ti2 put i*trow3 into ti3 repeat with j = 0 to tj1End put char ti1 + j*4 +2 of tid1 into char ti3 + j*4 +2 of tid3 put char ti1 + j*4 +3 of tid1 into char ti3 + j*4 +3 of tid3 put char ti1 + j*4 +4 of tid1 into char ti3 + j*4 +4 of tid3 end repeat put 0 into tRel2 put 100 into tRel1 repeat with j = tj1End to tj1End2 subtract tblendstep from tRel1 add tblendstep to tRel2 put chartonum(char ti1 + j*4 +2 of tid1) into tc1 put chartonum(char ti2 + (j-tj1End)*4 +2 of tid2) into tc2 put numtochar(tC1/100*tRel1 + tc2/100*tRel2) into char (ti3 + (j*4+2)) of tid3 put chartonum(char ti1 + j*4 +3 of tid1) into tc1 put chartonum(char ti2 + (j-tj1End)*4 +3 of tid2) into tc2 put numtochar(tC1/100*tRel1 + tc2/100*tRel2) into char (ti3 + (j*4+3)) of tid3 put chartonum(char ti1 + j*4 +4 of tid1) into tc1 put chartonum(char ti2 + (j-tj1End)*4 +4 of tid2) into tc2 put numtochar(tC1/100*tRel1 + tc2/100*tRel2) into char (ti3 + (j*4+4)) of tid3 end repeat repeat with j = tblendrange-1 to w2 -1 put char ti1 + j*4 +2 of tid2 into char ti3 + (j+w1-tblendrange)*4 +2 of tid3 put char ti1 + j*4 +3 of tid2 into char ti3 + (j+w1-tblendrange)*4 +3 of tid3 put char ti1 + j*4 +4 of tid2 into char ti3 + (j+w1-tblendrange)*4 +4 of tid3 end repeat end repeat set the imageData of img 3 to tid3 end mouseup