Linear Gradient colour binding

Hi

I’d like to be able to dynamically alter the two colours in a Linear Gradient for a rectangle but I can’t find a property to bind too, can this be done?

Chris

Currently this can not be done. We do have a ticket in the system to have this feature added.

As a work around, you could use the paintable canvas component and change the gradient through scripting. If you look at this component there is script on it, through this you should be able to break it apart and make it work the way you want.

Greg

OK, using paintable canvas I have the basic features of what I want working but is there any way to use transparency and a greater range of colours? I seem to be stuck with just the 13 standard colours in Java.

Chris

Chris,

You should be able to use any of these colors also
docs.oracle.com/javase/1.4.2/doc … Color.html

Greg

Yep, those are the 13 colours.

I shall have to work out how to use “brighter”, “darker” and “Transparency”, if they are applicable to Gradients

Chris

You can create any color you want through scripting, i.e.:

myNewColor= (Color(255,0,0,255))
# Paint output pipe and nozzle
g.setPaint(GradientPaint(0,12,myNewColor, 0,30, Color.DARK_GRAY,1))

The last byte in the tuple is the transparancy. You could also map dynamic values into your color tuple if you wanted to make it dynamic: Color(r,g,b,t)

Step7

Thats what I was after, two sets of brackets are required, its still early days with this for me. I’ll try that on Monday

Many Thanks

Chris

After 8+ years, has that ticket you mentioned been fulfilled? This would still be a super-handy feature, but this is the only result I find.

1 Like

Bump

No. What you could do is use the runScript expression to invoke a project script that manually creates a gradient, e.g. an instance of LinearGradientPaint.