Creating a color gradient

David McCord shared this question 1 year ago

I would like to color a rectangle with a changing grey scale from left to right, so the grey gets darker steadily as you go from the left edge to the right edge. Is there a way to make the color of a vertical strip a function of x?

Comments (4)


GG is not usefull for aestetic creations

you can create a lot of rectangles, then a color for each rectangle

the spreadsheet can do easier the job


I agree with mathmagic about making this in GeoGebra is complicated but it can be done somehow using some tricks. Check the following applets:

The main idea is to create a bunch of objects of the same kind and then color them using the command SetDynamicColor()

I hope this helps.


A solution with trace of a segment and Properties/Advanced/DynamicColor

Disadvantage: if the triangle is changed, the filling has to be slow rebuilt. Advantage: high resolution.

Note the predefined function f(x)=betaRegularized(a, b, x) to adjust the distribution of black/white.


You can use an SVG (or PNG) to fill a shape eg

© 2021 International GeoGebra Institute