Skip to main content
Rowby
Inspiring
April 14, 2017
Answered

Turning a single star image into a star field with an expression

  • April 14, 2017
  • 4 replies
  • 1771 views

Hi

I have a single cartoon version of a star.  I would like to populate the background layer of the comp with a star field.  And I don't want to have to place those stars all in by hand.

So I am looking for an expression (which I will control with a slider(s) ) that will give me the most flexibility.

1)  Be able to "randomly" populate the background with the star image.

2)  Adjust the size of the individual stars in some way (perhaps random -- but still have permaters in some way -- perhaps I will need to use different layers to do that.

3)  The stars will be still, but I would like their rotation to be random, so that they are not all in the exact same position.

4)  An additional feature would be the ability (if I upload a version that has a white color (instead of yellow) would be able to set colors for the various stars in some way.  (Possibly I would need to do different colors on different layers, if this is not easily possible -- even with a random expression re color???)

Any thoughts on this. I am a newbie to expressions, but I think I get the concept.

Best

Rowby

    This topic has been closed for replies.
    Correct answer Szalam

    You can draw a cartoon star like that very easily with the shape tools and then use repeaters and other shape tool functions to randomly position them around the scene. You can even have randomly jiggled strokes on each one so that they are all different.

    You know what? It won't take very long. Gimme a second.

    4 replies

    Szalam
    Community Expert
    Community Expert
    April 14, 2017

    Update: now with random scale.

    Project file

    Rowby
    RowbyAuthor
    Inspiring
    April 19, 2017

    Hi everyone.

    I've been away and just returned to this question.  For whatever reason I couldn't get Horshack's expressions to work.  I'm sure it's my inexperience in expressions.  I'm going to try Szalam's project file   

    In any case, here's my attempt at Horshack's solution.  For my own education perhaps Horshack can show me where I went wrong with the clone stamp.  It did not affect my single star.


    I'll report back soon!

    Rowby

    Horshack
    Legend
    April 19, 2017

    Hi Rowby,

    The expressions I provided were meant to be applied on each clone stamp's Transform property group. You've applied them to the layer's transform property group. You can get to the first clone stamp's group by going to Effects -> Paint -> Clone 1 -> Transform: Clone 1

    Szalam
    Community Expert
    Community Expert
    April 14, 2017

    This is done with one shape and a repeater Here's the project file

    If you want to mess with the positions, rotations, etc., just mess with the relevant options under the "Wiggle Transform" property. There are all kinds of things you can do with this.

    Now, you could also do something like this with expression and have a whole bunch of layers with their properties tied to expression control effects on a controller layer, but this way is much faster.

    Szalam
    Community Expert
    SzalamCommunity ExpertCorrect answer
    Community Expert
    April 14, 2017

    You can draw a cartoon star like that very easily with the shape tools and then use repeaters and other shape tool functions to randomly position them around the scene. You can even have randomly jiggled strokes on each one so that they are all different.

    You know what? It won't take very long. Gimme a second.

    Horshack
    Legend
    April 14, 2017

    The clone stamp tool is perfect for this. Each clone gets its own Transformation parameter that can you keyframe in the timeline for your layer, for example: Effects -> Paint -> Clone 1 -> Transform: Clone 1. For the properties you want to be random you can include a random expression. Here are three for position, scale, and rotation. If you don't like the random value they select for any given property then change the first parameter to seedRandom from "1" to a different value.

    For position:

    seedRandom(1,true);

    var randomX = random(0,1000);

    var randomY = random(0,800);

    [randomX, randomY];

    For scale:

    seedRandom(1,true);

    var s = random(20,200);

    [s,s];

    For rotation:

    seedRandom(1,true);

    var r = random(0,360);

    ;

    If you want to make these expressions configurable you can drop some Expression control sliders onto your layer (or a new null layer) and link the parameters to random() or seedRandom() to those sliders.