Jump to content

Recommended Posts

Posted

I have a slew of gradients that I want to create, but creating them all manually could take me well into retirement age.🤪 Is there a way to do it programmatically?

  • Are gradients stored as a text string somewhere?
  • Or if I created them as images could they be captured via the same approach that is used to create single color palettes?
  • Are macros something that would work for a task like this?
  • Anything that I haven't mentioned would be awesome as well.
  • Ideally, being able to convert CSS into gradients would be preferable, but I can work with anything that's faster than doing them all manually.

Thanks in advance,

Paul

Posted
7 hours ago, Realto said:

Is there a way to do it programmatically?

How's your Python?

https://pypi.org/project/drawsvg/

you can find a handy Drawsvg Quick Reference here
https://github.com/cduck/drawsvg

then the svgs can be opened in Affinity. Here's one I made after a few minutes, a mere 8 lines of code
Good luck

GradRect.svg

Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe
Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10

Posted

SVG files are plain text and can be edited with any text editor or created from Excel.

you just need to learn the syntax, which is really simple.

 

Mac mini M1 A2348 | MBP M3 

Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.

 

Posted
On 11/9/2024 at 9:09 AM, David in Яuislip said:

How's your Python?

https://pypi.org/project/drawsvg/

you can find a handy Drawsvg Quick Reference here
https://github.com/cduck/drawsvg

then the svgs can be opened in Affinity. Here's one I made after a few minutes, a mere 8 lines of code
Good luck

GradRect.svg 507 B · 0 downloads

Perfect! Exactly what I was looking for. I can mass-generate all that I need with a simple JS function and now I won't have to deal with the manual way of creating them which is worse than watching paint dry as well as painful after only a few with the constant trackball input required to make one. If you're interested, I'll post the results after I make some progress so I can share the wealth. Quality gradients seem to be a bit scarce in Designer.

Posted
On 11/9/2024 at 9:55 AM, NotMyFault said:

SVG files are plain text and can be edited with any text editor or created from Excel.

you just need to learn the syntax, which is really simple.

 

I wasn't aware that they could be copied so easily and imported into a palette that way, so this should be a perfect solution. I already have a JS app I created that generates CSS gradient code that will just need a few slight modifications. I'll post the palette that I create in here in a few days if you're interested.

Thanks!

Posted

Ok, here's my first automated palette. It took several hours to set it all up and get it working right. I wound up using PHP to generate the gradients and save them as files. Once the files were all created, I think it took all of 10 minutes to get them added to a new palette in Designer. Doing it manually would have taken several entire work-weeks and an advanced case of carpal tunnel.

These are all two stop gradients. I'm also going to add a few stops and test them out to see how those look.

Now, the only real challenge is combining the colors effectively, which is exactly how it should be!

Thanks again!

If anyone is interested in additional gradient palettes that I create, reply in here or send me a DM (if that's possible in here) and I'll post anything new.

GeneratedGradients.jpg

Gradients2024.afpalette

Posted

@Realto Great work, thank you. What I didn't get entirely: How did you create the .afpalette file with the gradients? Were you able to automate that process, too, or did you sample the gradients manually by selecting each object from the SVG file in Affinity and using the Swatches panel to add the fills to the palette?

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.