home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
- ADOBE SYSTEMS INCORPORATED
- Copyright 2001 Adobe Systems Incorporated
- All Rights Reserved
-
- NOTICE: Adobe permits you to use, modify, and distribute this
- file in accordance with the terms of the Adobe license agreement
- accompanying it. If you have received this file from a source
- other than Adobe, then your use, modification, or distribution
- of it requires the prior written permission of Adobe.
- ***************************************************************/
- /***************************************************************
- Author: Mary Obelnicki
- ***************************************************************/
-
- /***************************************************************
- This file breaks the selected object into 'pieces' of a given size.
- The pieces actually consist of an alias of the original object in a
- group with a mask to create something that looks like a piece of the
- original without making the file large.
-
- ***************************************************************/
-
- /***************************************************************
- To change the behavior of this script,
- make your changes below
- ***************************************************************/
- var target = application.currentComposition.selection[0];
- baoMaskSquare( target, // the object to break apart
- 50); // the size of the piece
-
- /***************************************************************
- DO NOT EDIT BELOW THIS LINE
- ***************************************************************/
- function moveAnchorPointTo(object, x, y)
- {
- object.anchorPoint.x += x - object.position.x;
- object.anchorPoint.y += y - object.position.y;
- object.position.x = x;
- object.position.y = y;
- }
-
-
- function baoMaskSquare(object, sqSize)
- {
- var mask = application.currentComposition.createObject(LMObjectType.geometric, 50, 50);
- mask.size.x = sqSize;
- mask.size.y = sqSize;
-
- var xmid = object.position.x + object.scale.x/100 * ((.5 * object.size.x) - object.anchorPoint.x);
- var ymid = object.position.y + object.scale.y/100 * ((.5 * object.size.y) - object.anchorPoint.y);
-
- var halfXSquares = Math.ceil(.5 * object.scale.x/100 * object.size.x / sqSize);
- var halfYSquares = Math.ceil(.5 * object.scale.y/100 * object.size.y / sqSize);
-
- var xpos;
- var ypos;
- var tempArray = new Array;
-
- for (xpos = (xmid - (halfXSquares - .5) * sqSize); xpos < (xmid + halfXSquares*sqSize); xpos+=sqSize)
- {
- for (ypos = (ymid - (halfYSquares - .5) * sqSize); ypos < (ymid + halfYSquares*sqSize); ypos+=sqSize)
- {
- var newObject = object.makeAlias();
-
- var newMask = mask.makeAlias();
- newMask.position.x = xpos;
- newMask.position.y = ypos;
-
- tempArray[0] = newMask;
- tempArray[1] = newObject;
- var newGroup = application.currentComposition.group(tempArray);
- newGroup.topObjectIsMask = true;
- moveAnchorPointTo(newGroup, xpos, ypos);
- newGroup.name = "PieceAt(" + xpos + "," + ypos + ")" ;
- }
- }
-
- mask.name = "OriginalMask" ;
- object.name = "OriginalObject" ;
- object.setDepth(0);
- mask.setDepth(1);
- object.position.x = 50;
- object.position.y = application.currentComposition.size.y - 50;
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-