How to dynamicly color objects.

Nicholasfox shared this question 5 months ago
Answered

I want to dynamicly color different objects like the picture as below.

I realized that sequence command can't do this.

Need help, thanks.

https://www.geogebra.org/cl...94185c0dec4c8c012da1eb58588aaa43

Comments (5)

photo
3

Objects can have dynamic colors (see [url=https://wiki.geogebra.org/e...) but you must provide the colors in RGB form. That said, afaik you can't colour elements of a list differently, so it's not enough to create a sequence of areas, but each area needs to be a different object. If you want to have some flexibility regarding the number of areas shown, some scripting is in order.

Attaches is a very flexible solution:

  • Slider to set the number 'n' of areas. Feel free to change the maximum of the slider to anything you want.
  • 'LCubicAreas' is the list of the 'n' areas needed. It has an "On Update" script which constructs a separate object for each element, sets it's dynamic color, and sets the line thickness to 0. (It does that by dynamically creating list a of commands and executes them. It's just a single line but very ugly.) If yo want to change the name of the list, you also need to change it in the script.
  • The matrix 'ColorSet' provides the colors. Each line (3 values between 0 and 1 for R, G, B) represents one color. It's NOT necessary to provide as many colors as you have areas, the colours are simply cycled through. As long as you have at least one color, everything works.
  • There is a variable 'opacity' where you can dynamically change the opacity of the areas (value between 0 and 1).
  • There is a text variable 'AreaNameBase' that simply sets the base name for the areas the script constructs. Change that if you don't like the generated names form the script.

photo
1

Amazing, Thanks for your help.

photo
1

Amazing, Thanks for your help.

photo
1

By using your way, I made another version. Thanks.

https://www.geogebra.org/ca...

photo
2

I recomend you this tutorial

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

I make my constructions using this method:

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

Cheers!

photo
© 2021 International GeoGebra Institute