Using expressions to define x and y positions inside an object
Hello!
I am fairly new to writing expressions in Adobe After Effects and need some help. I am trying to write an expression that will generate 300 unique positions for 300 copies of the same image inside an object without having to manually move each image to a new location.
To do that, I created an expression for the first image's position as follows:
seedRandom(3,true);
random([thisComp.width,thisComp.height])
I then copied and pasted it 300 times.
The problem with this is that it sets the random position to the entire composition's width and height, whereas I want it to set only to x and y coordinates that are inside the confines of a not-perfectly-shaped map (map of USA) inside the composition. I have tried to mask my object and then write something like this:
seedRandom(9,true);
x = thisComp.layer("USAMAP").mask("Mask 1").maskPath.width;
y = thisComp.layer("USAMAP").mask("Mask 1").maskPath.height;
random([x,y])
But I know this won't exactly work since the object is not a perfect shape. Do I have to define more parameters?
Side question (not as important as my first): When dealing with tons of small images on a very large scale like 300+, is there an easier way to replicate the image without physically copying and pasting? Is there some sort of code that tells After Effects to copy an image and run it `x' amount of times in the background without physically creating the copies? As of now, I've been copying and pasting the image, using sequence layers, and stretching the right tail-end of my timeline for all 300 images. I'm just curious.
Thanks for all the help!
