Copying parts of pictures to the front

Shao Sean shaosean at unitz.ca
Tue Feb 5 02:14:00 EST 2002


okay, i finally got it working irregardless of where the base image is
located.. this script assumes that the two images (base and swap) are the
same sizes and that the areas to be swapped are in the same areas in each
picture (which, based on the emails, i assume is what you're doing)..

what you'll need to make this script work is the following:
- the base image (lowest layer)
- the swap image to be grouped (at least one layer higher then the base
image)
- the buttons (at least one layer higher then the swap image group)

also, this script assumes that the base image is called "base", and the
group is called "swap".. please feel free to change as needed

so without further ado, here are the scripts:

-- Group Script
on showPiece pButtonLoc, pButtonRect
  # Declare the variables
  local hVariance, vVariance
  -- hVariance is the pixel difference between the left edge of the button
and the left edge of the base image plus the extra pixels for the group
margins
  -- vVariance is the pixel difference between the top edge of the button
and the top edge of the base image plus the extra pixels for the group
margins

  # Store values into variables
  put item 1 of pButtonRect - item 1 of the rect of image "base" + the
margins of me into hVariance
  put item 2 of pButtonRect - item 2 of the rect of image "base" + the
margins of me into vVariance

  # Resize and reposition this group
  set the rect of me to pButtonRect
  set the loc of me to pButtonLoc

  # Scroll this group
  set the hScroll of me to hVariance
  set the vScroll of me to vVariance

  # Show the piece
  set the visible of me to TRUE
end showPiece

on hidePiece
  set the visible of me to FALSE
end hidePiece


-- Button script
on mouseEnter
  send "showPiece the loc of me,the rect of me" to group "swap"
end mouseEnter

on mouseLeave
  send "hidePiece" to group "swap"
end mouseLeave


-- Not part of the scripts, just more of my email ;-)

if you have any questions about this script, please feel free to email me..
i also have an example stack (compressed: 90K in size due to the images)




More information about the use-livecode mailing list