Creating a color gradient

David McCord shared this question 1 year ago
Answered

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)

photo
1

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

photo
3

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

https://www.geogebra.org/m/qgkqjasu

https://www.geogebra.org/m/adchpkga

https://www.geogebra.org/m/f6vfybxz

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.

photo
1

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.

photo
2

You can use an SVG (or PNG) to fill a shape eg https://www.geogebra.org/m/n6pFJQcR

© 2021 International GeoGebra Institute