Lingo Dictionary > A-C > crop() (image object command)

 

crop() (image object command)

Syntax

imageObject.crop(rectToCropTo)

Description

When used with an image object, returns a new image object that contains a copy of the given image object, cropped to the given rect. The original image object is unchanged. The new image object does not belong to any cast member and has no association with the Stage. If you wish to assign it to a cast member you can do so by setting the image property of that cast member.

This is different from using crop with a cast member, which crops the cast member itself, altering the original.

Example

This Lingo takes a snapshot of the Stage and crops it to the rect of sprite 10, capturing the current appearance of that sprite on the Stage:

set stageImage = (the stage).image
set spriteImage = stageImage.crop(sprite(10).rect)
member("sprite snapshot").image = spriteImage

Example

This statement uses the rectangle of cast member Happy to crop the image of cast member Flower, then sets the image of cast member Happy to the result.

member("Happy").image = member("Flower").image.crop(member("Happy").rect)