Gradient with more than 2 colors

Right now, according to the docs, only this is possible 

{ type=“gradient”, color1={ r, g, b, a }, color2={ r, g, b, a }, direction= }

Is it possible to create and apply a gradient with more than 2 colors? 

This is just partially what it means to be a “gradient” (in this context).  E.g. in a green-to-blue gradient, the color is 100% green at one edge and 0% green at the other edge (with blue going 0% to 100%).

Just to check:  are you thinking of a mathematical gradient over 3 colors (like a surface/flow map)?  or do you just want green-to-blue-to-purple colors in a row?

The obvious idea for the latter is just to create 2 (or more) gradients that are adjacent to each other, one for each pair of colors.  E.g. you’d go from green-to-blue, then blue-to-purple.  It’s a dumb, brute-force kind of approach, but that’s not always a bad thing.

Just to check:  are you thinking of a mathematical gradient over 3 colors (like a surface/flow map)?  or do you just want green-to-blue-to-purple colors in a row?

I just want a basic 3-color gradient.  (my requirement is a green-to-blue-to-green gradient).

The obvious idea for the latter is just to create 2 (or more) gradients that are adjacent to each other, one for each pair of colors.

But how do I apply it to a single display object, in my instance a text object? 

 

Ahh … I haven’t played with these but maybe look at the “generators” for object-fills:

Particularly the generator.radialGradient … you might be able to set the radii to something that gets it close to a green-to-blue-to-green (but would have a slightly circular edge).

The closest I could get was something like two bands of color, but maybe some more tweaking would get it closer to what you want.

myRectangle.fill.effect = "generator.radialGradient" myRectangle.fill.effect.color1 = {0,1,0} myRectangle.fill.effect.color2 = {0,0,1} myRectangle.fill.effect.center\_and\_radiuses = {0.5,0.5,0.6,0.99} myRectangle.fill.effect.aspectRatio = 10

Otherwise, you’d have to see if there’s a way to write your own filter or generator function – I can’t see anything in the docs about that.

Interesting idea, but unfortunately I am unable to make it suit my needs. 
A circle for a gradient is too rigid.  An ellipse would have served better.

For now, I cooked up a really ugly way. 
I created 2 instances of the display object, placed one above the other,   gave a gradient to each(color1->color2 to the first, and color2->color1 to the other) and hid a half of one object using a container. 

It’s sort of OK, but I doubt I will be using this   -_-.

I probably will scratch the whole 3-color gradient idea.

The other idea (I haven’t tried this either) is that you can include an image as a background-fill … maybe make the gradient image in another program and import it.  Obviously, there could be pixelation issues at higher resolutions, but it might be worth a try.

Good Luck!

I was looking for a more generic solution… 
One which won’t involve creating images for every effect. 

But, I did end up using a background image… 
Nothing else works. 

Thanks a lot anyway! 

This is just partially what it means to be a “gradient” (in this context).  E.g. in a green-to-blue gradient, the color is 100% green at one edge and 0% green at the other edge (with blue going 0% to 100%).

Just to check:  are you thinking of a mathematical gradient over 3 colors (like a surface/flow map)?  or do you just want green-to-blue-to-purple colors in a row?

The obvious idea for the latter is just to create 2 (or more) gradients that are adjacent to each other, one for each pair of colors.  E.g. you’d go from green-to-blue, then blue-to-purple.  It’s a dumb, brute-force kind of approach, but that’s not always a bad thing.

Just to check:  are you thinking of a mathematical gradient over 3 colors (like a surface/flow map)?  or do you just want green-to-blue-to-purple colors in a row?

I just want a basic 3-color gradient.  (my requirement is a green-to-blue-to-green gradient).

The obvious idea for the latter is just to create 2 (or more) gradients that are adjacent to each other, one for each pair of colors.

But how do I apply it to a single display object, in my instance a text object? 

 

Ahh … I haven’t played with these but maybe look at the “generators” for object-fills:

Particularly the generator.radialGradient … you might be able to set the radii to something that gets it close to a green-to-blue-to-green (but would have a slightly circular edge).

The closest I could get was something like two bands of color, but maybe some more tweaking would get it closer to what you want.

myRectangle.fill.effect = "generator.radialGradient" myRectangle.fill.effect.color1 = {0,1,0} myRectangle.fill.effect.color2 = {0,0,1} myRectangle.fill.effect.center\_and\_radiuses = {0.5,0.5,0.6,0.99} myRectangle.fill.effect.aspectRatio = 10

Otherwise, you’d have to see if there’s a way to write your own filter or generator function – I can’t see anything in the docs about that.

Interesting idea, but unfortunately I am unable to make it suit my needs. 
A circle for a gradient is too rigid.  An ellipse would have served better.

For now, I cooked up a really ugly way. 
I created 2 instances of the display object, placed one above the other,   gave a gradient to each(color1->color2 to the first, and color2->color1 to the other) and hid a half of one object using a container. 

It’s sort of OK, but I doubt I will be using this   -_-.

I probably will scratch the whole 3-color gradient idea.

The other idea (I haven’t tried this either) is that you can include an image as a background-fill … maybe make the gradient image in another program and import it.  Obviously, there could be pixelation issues at higher resolutions, but it might be worth a try.

Good Luck!

I was looking for a more generic solution… 
One which won’t involve creating images for every effect. 

But, I did end up using a background image… 
Nothing else works. 

Thanks a lot anyway!