Skip to main content
Known Participant
July 25, 2019
Question

Can I have a path stroke chopped into random colours at random intervals?

  • July 25, 2019
  • 2 replies
  • 1052 views

Hi,

I would like to know if this is possible. And if it is possible:

Is it also possible to have the random colours be picked from a certain colour group? Or a certain reference image? So I can have control over the look and feel of the stroke?

Is it also possible to have control over the frequency of the chopping intervals?

Is it also possible to have a 'randomness fit scaler'? So you can make the segments more random or more even?

If it is also possible for straight lines and not for strokes on paths, I would like to know it as well.

Thank you very much.

    This topic has been closed for replies.

    2 replies

    Community Expert
    July 25, 2019

    Try this.

    1. Draw a path creating a new shape layer
    2. Press uu to reveal the modified properties of the shape layer
    3. Add Trim Paths to the newly created Shape 1
    4. Select Shape 1, not path 1, but shape 1 and press Ctrl + D to duplicate Shape 1 multiple times until you get a new Shape element for each color you want
    5. Type stroke, color in the Timeline search field to reveal the color of each Shape
    6. Edit the color of each Stroke that is revealed
    7. Type trim, start, end in the Timeline search field to reveal all trim paths with their start and end properties
    8. Adjust the end value for each path to arrange the colors you will end up with something like this:
    9. Add two Expression Control Sliders to the shape layer and name one Frequency and one Randomness

    I don't have time to write the expressions for you right now but I'll tell you the concept. Each Shape's start and end values would be tied to both sliders. The Frequency would divide the number of Shapes by the value of the slider to adjust the start and end value of all shapes. If the slider was set to 1 then all of the shapes would have the end value adjusted to 100 so only the top shape was visible, if the value was 2 then the end value of the top layer would be 50% and the remaining shapes would remain at 100 showing just the first two colors. Set the value to 3 and the value for the first shape would be 33% the second would be 66% and all others would still be at 100. The expression for randomness would modify the end value for each shape to adjust the difference between the end position. If you wanted to be able to move the position of the colors in the line then you would add expressions to the start value also so the color of shape 1 could be moved to position 2. This could also be controlled by the Randomness slider or you could add a checkbox or even a rotation slider to control the order of the colors. It all depends on what you want to do with the colors. It would probably take me about 20 minutes to come up with a working expression that could be applied to any copy of any shape in a shape layer. Dan Ebberts could probably write one in about 5 minutes.

    That should get you started. The key to making this workflow simple is to set up Shape 1 with Trim Paths first, use the Timeline search to isolate various properties like "shape, color" so your timeline is uncluttered and it's easy to edit. Make sure you use the commas.

    Mylenium
    Legend
    July 25, 2019

    All of what you want is possible, but it will require a ton of expressions. You'd simply create an x amount of strokes on top of each other and then e.g. control the behavior of Trim Paths operators for the individual ends. Conversely, colors could be applied using sampleImage(), from a predefined color list or color expression controls linked to the stroke/ fill colors.

    Mylenium