Disabling randomisation for gradients #549
|
Hi, thanks for the package first of all. My question is about enforcing colours on a gradient instead of randomising them. For example let's say I want to set the body colours to the colours of the French flag 🇫🇷. I would supply to the bodyColors property the hexidecimals of blue, white and red . The bodyColorFill is set to linear. Now because of the randomisation the avatar is not necessarily in the order of blue, white and red but their colours could be reordered. But how can I enforce the colours to follow exactly the order I supplied, e.g. disable the randomisation of colours? |
Replies: 1 comment 3 replies
|
Hi @rbozan, thanks for asking. You were right that there was no way to do it, the shuffle always ran. It seemed like such an obvious gap once you pointed at it that it went straight into 10.5.0, which I just published. The new option is const avatar = new Avatar(style, {
seed: 'Felix',
baseColor: ['0055a4', 'ffffff', 'ef4135'],
baseColorFill: 'linear',
baseColorAngle: 0,
baseColorOrder: 'fixed',
});
Every color group in a style gets the option, so It is in all six libraries (JavaScript, PHP, Python, Rust, Go, and Dart) and in the HTTP API. The rules are written up in the core options guide. Thanks again for the nudge, this one was fun to build. |
Hi @rbozan, thanks for asking. You were right that there was no way to do it, the shuffle always ran. It seemed like such an obvious gap once you pointed at it that it went straight into 10.5.0, which I just published.
The new option is
*ColorOrder. Set it tofixedand your colors stay exactly as you passed them. Your flag example, onbottts(its color group is calledbase, so the option isbaseColor):