Reflect

From Director Online Wiki
Jump to: navigation, search
--if b = 255 then
--  result := 255
--else begin
--  c := a*a DIV (255-b);
--  if c > 255 then result := 255 else result := c;
--end;
-- ******* reflect mode *************
on reflectBlendMode (image1, image2)
 
  theWidth = image1.width - 1
  theHeight = image1.height - 1
  theImage = image(theWidth + 1, theHeight + 1, 32)
 
  repeat with x = 0 to theWidth
    repeat with y = 0 to theHeight
      theColour1 = image1.getPixel(point(x,y))
      theColour2 = image2.getPixel(point(x,y))
      theNewColour = color(0,0,0)
 
      if theColour2.red = 255 then
        theColour2.red = 255
      else
        theNewColour.red = min(theColour1.red * theColour1.red / float(255 - theColour2.red), 255)
      end if
      if theColour2.green = 255 then
        theColour2.green = 255
      else
        theNewColour.green = min(theColour1.green * theColour1.green / float(255 - theColour2.green), 255)
      end if
      if theColour2.blue = 255 then
        theColour2.blue = 255
      else
        theNewColour.blue = min(theColour1.blue * theColour1.blue / float(255 - theColour2.blue), 255)
      end if
      theImage.setPixel(point(x, y), theNewColour)
    end repeat
  end repeat
  return theImage
end