Jump to content
You must now use your email address to sign in [click for more info] ×

Stripes, Gradient Stops Script (python 3)


VectorVonDoom

Recommended Posts

I needed a quick script to make it easier to create some styles that contained stripes using the fx gradient overlay but it obviously also works with the standard gradient. With just a few stripes and it's easy enough but when you are doing 20 or more with fractional percentages it's too much for my tiny mind to easily keep track of xD

So just enter the odd and even stripe width percentages then where any padding should go and it lists the gradient stops to add. I copied the output to a text file and as I completed steps just deleted them from the list. It saved me a headache. 

Don't look too hard at the messy code, it was a quickie!

Stripes.py

 

Marc

ArtByMarc.me

Link to comment
Share on other sites

Good idea and can be enhanced to show sort of a preview of the expected gradients then too (you can install and use Pillow for Python3 for image handling).

Quote

python3 -m pip install Pillow

Then as an example for how to making a gradient with that then something like this ...

...
# A map of rgb points
# [distance, (r, g, b)]
# distance is percentage from left edge
pointmap = [
    [0.0, (0, 0, 0)],
    [0.20, (0, 0, .5)],
    [0.40, (0, .5, 0)],
    [0.60, (.5, 0, 0)],
    [0.80, (.75, .75, 0)],
    [0.90, (1.0, .75, 0)],
    [1.00, (1.0, 1.0, 1.0)],
]
...

gradient.png.fdf75510ef40ca32b5394dbf11577d8e.png

And some more sophisticated source about color gradients with python here (colors as points in 3D space, linear gradients etc.). Interesting, though probably might be over the top for just quick how it looks like visualization purposes.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

It could be handy so you could fine tune the gradient rather than start entering them and finding they're not quite what you wanted. Anyway it did what I needed it to do  but if someone wants to make a fancy pants version then off you go!  Now if only you didn't have to type it all in to AD, we had extensions... (and/or better fx's)

1.jpg

 

Marc

ArtByMarc.me

Link to comment
Share on other sites

4 hours ago, VectorVonDoom said:

Now if only you didn't have to type it all in to AD, we had extensions... (and/or better fx's)

Maybe that can be addressed in future via app scripting capabilities in some manner.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.