Color gradient on object?

16 views
Skip to first unread message

Andrew Morrison

unread,
Nov 20, 2017, 9:41:52 PM11/20/17
to Glowscript Users

Is it possible to change the color of an object from one color to another on opposite sides of the object?  I'm trying to get a gradient of color going around a ring object as a function of the angle around the ring, but I am not sure if that is possible.  Thoughts?

Thanks!

Andrew

Bruce Sherwood

unread,
Nov 20, 2017, 10:00:27 PM11/20/17
to Glowscript Users
No, there isn't an easy way to do this. There is a missing feature in the extrusion object, a feature that was available in VPython 6, which is to specify an array of colors to be used for the segments of the extrusion.

However, you can use vertex and triangle or quad objects to make any arbitrary object, with any colors, though it's somewhat effortful.

Bruce

Andrew Morrison

unread,
Nov 20, 2017, 11:31:41 PM11/20/17
to Glowscript Users

Ah, bummer.  I whipped up a Doppler effect demo and one of the suggestions I got was to shade one side of the wavefronts blue and the other side red.  I thought it was an interesting suggestion, but then realized it wouldn't be easy to implement.  Just thought I would ask.

Bruce Sherwood

unread,
Nov 21, 2017, 9:13:15 AM11/21/17
to Glowscript Users
Now that I've seen your program I realize that being able to color the segments of an extrusion wouldn't help. A ring object is quite unusual. It requires its own special GPU processing because when you change its radius the thickness doesn't change. When you change a dimension of an extrusion object this affects all of the elements of the object.

Bruce

Bruce Sherwood

unread,
Nov 21, 2017, 4:11:40 PM11/21/17
to Glowscript Users
On second thought, use curve objects. You can specify colors along a curve. 

Bruce
Reply all
Reply to author
Forward
0 new messages