Buzz Kettles <[EMAIL PROTECTED]> wrote:
> Do you know if copypixels supports [#ink : #reverse]?

Hi Buzz,

According to Werner Sharp, the formula for reverse ink is:
destination = destination XOR source.

Truth table for XOR:

   |  0  1
---|-------
 0 |  1  0
   |
 1 |  0  1

(Though I imagine that you know this already :-)

This operation is applied to each of the bits in each 8-bit color component:

rgb(127,   0,   5) = 01111111 00000000 000000101
rgb(128, 127,   5) = 10000000 10000000 000000101
           XOR       00000000 01111111 111111111

You should only be getting white pixels is if both destination and source
are the same color, as in the blue component above.

So it sounds as if you are using the same image as source and destination.
To reverse an image, you should use black as the destination.  Using other
colors gives different effects, as shown in the demonstration below.

Cheers,

James


-- In a Movie Script:

on reverseInk(aTextColor, aDestinationColor)
  -- Create a text member with the text "Buzz" in the chosen color
  tTextMember           = new(#text)
  tTextMember.text      = "Buzz"
  tTextMember.fontSize  = 18
  tTextMember.font      = "Arial"
  tTextMember.alignment = #center
  tTextMember.width     = 64
  
  if ilk(aTextColor) = #color then
    tTextMember.color = aTextColor
  end if
  
  -- Convert the text to an image with an alpha channel
  tSource = tTextMember.image
  
  -- Prepare a destination image with the chosen background color
  tRect  = tSource.rect
  tImage = image(tRect.width, tRect.height, 32)
  if ilk(aDestinationColor) <> #color then
    aDestinationColor = rgb(0, 0, 0) -- use black as default
  end if
  tImage.fill(tRect, aDestinationColor)
  
  -- Use reverse ink to copy the text image across
  tImage.copyPixels(tSource, tRect, tRect, [#ink: #reverse])
  
  -- Create a new bitmap member from the resulting image
  new(#bitmap).image = tImage
end


-- In the Message window:
-- To create white letters on a black background
reverseInk()
-- Using red text to create green letters on a blue background
reverseInk(rgb(255, 0, 0), rgb(0, 0, 255))


-- rgb(255, 0,   0) = 11111111 00000000 00000000 -- red
-- rgb  (0, 0, 255) = 00000000 00000000 11111111 -- blue
--              XOR   00000000 11111111 00000000 -- green

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to