Background Color Gradient

Have jReality programming problems or questions? Post them here.
Post Reply
goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Background Color Gradient

Post by goose12 » Fri 5. Aug 2011, 05:40

Hi,

I was wondering if I can get an example of how to set the background to a gradient of colors. I have tried the following unsuccessfully. Thanks in advance.

Code: Select all

ap.setAttribute(CommonAttributes.BACKGROUND_COLOR, new ColorGradient( new Color[] { Color.blue, Color.cyan, Color.green} ));

ap.setAttribute(CommonAttributes.BACKGROUND_COLOR,  new Color[] { Color.blue, Color.cyan, Color.green});

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Background Color Gradient

Post by gunn » Fri 5. Aug 2011, 12:10

jReality does not have a built-in support for this kind of color gradient for the background. It does however offer a gradient based on specifying 4 colors, one for each corner, which it then bilinearly interpolates. I believe you can simulate the gradient you wish by constraining the 4 colors to be 2 equal pairs.

Since this option is not so well-documented in the tutorials, I've extended the tutorial example de.jreality.tutorial.app.BackgroundExample to include all three basic variations for backgrounds which jReality supports. Use the '1' key to cycle among these three options.

Note that the existing version of this tutorial online at http://www3.math.tu-berlin.de/jreality/ ... Background will not be updated to reflect this new content until the next release cycle of the jReality distribution.

If you can't check it out of the repository for some reason please post and I will post the source code here.
jReality core developer

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Background Color Gradient

Post by Andre » Fri 5. Aug 2011, 13:19

gunn wrote: Note that the existing version of this tutorial online at http://www3.math.tu-berlin.de/jreality/ ... Background will not be updated to reflect this new content until the next release cycle of the jReality distribution.
I just ran the scripts ;)

goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Re: Background Color Gradient

Post by goose12 » Sun 7. Aug 2011, 00:11

Thanks, thanks exactly what I was looking for.

Post Reply