# Gradient expression for FillPaint property

**URL:** <https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814>\
**Category:** General Discussion\
**Created:** [November 23, 2015, 10:26am UTC](https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814 "2015-11-23T10:26:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgmo](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pgmo](https://forum.inductiveautomation.com/u/pgmo)\
**Post date:** [November 23, 2015, 10:26am UTC](https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814/1 "2015-11-23T10:26:10Z")

</div>

Hi,  
is it possible to set a rectangle FillPaint property to a gradient color by using an expression based on some variable values? (I’m using Ignition 7.8.0)

Thank you in advance

---

<div class="post-metadata">

**Author:** ![sngeru](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@sngeru](https://forum.inductiveautomation.com/u/sngeru)\
**Post date:** [November 26, 2015, 12:31am UTC](https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814/2 "2015-11-26T00:31:10Z")

</div>

Hello,

You wouldn’t be able to use a binding directly but you could do something like this through scripting and then work this into an expression binding using the runScript() expression function.

```auto
from com.inductiveautomation.ignition.client.util.gui.paints import RelativeLinearGradientPaint
from java.awt import Color
from java.awt.geom import Point2D

#RelativeLinearGradientPaint(java.awt.geom.Point2D start, java.awt.geom.Point2D end, float[] fractions, java.awt.Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
rlgp = RelativeLinearGradientPaint(Point2D.Double(0.0,0.5), Point2D.Double(1.0,0.5), [0.0, 0.4111675024032593, 1.0],[Color(255,0,0), Color(0,255,200), Color(0,0,255)], RelativeLinearGradientPaint.CycleMethod.NO_CYCLE)
event.source.parent.getComponent('Rectangle').fillPaint = rlgp
```

If you placed this script on a button it would change the gradient of a rectangle on screen to the specified colors and locations.

Let me know if this helps.

Best,

---

<div class="post-metadata">

**Author:** ![pgmo](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pgmo](https://forum.inductiveautomation.com/u/pgmo)\
**Post date:** [November 26, 2015, 9:12am UTC](https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814/3 "2015-11-26T09:12:29Z")

</div>

Hallo sngeru,  
thank you very much, I will give it a try.

Regards

---

<div class="post-metadata">

**Author:** ![batterydev](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@batterydev](https://forum.inductiveautomation.com/u/batterydev)\
**Post date:** [October 26, 2017, 8:03am UTC](https://forum.inductiveautomation.com/t/gradient-expression-for-fillpaint-property/10814/4 "2017-10-26T08:03:33Z")

</div>

For Some reason it does not work to me.Could you please insert here the entire script included runScript() expression.
