Condition upon colour

Paul Smith shared this question 7 months ago
Answered

Hi all,

In "On Click" under "Scripting" for a segment, what is the syntax please for saying "if the colour is black, setcolor to red?

Many thanks

Comments (5)

photo
1

You have to set the condition when to color it black or red, not to contol if it's black. E.g. for a segment AB you can control its color black or red wit a scripting command on update: SetColor(f, Als(x(B)<0, "black", "red")). You can't control the color as such, only the conditions under which a color is set.

chris

photo
1

Thanks Chris.

In "On Click", "SetColour(f,"red")" works.

When I click on the segment it goes red.

But if it's red, I want it to go black.

Is there no syntax for "if(color=black, setcolour...

There must be a boolean statement for if an object is a certain colour?

photo
photo
1

There must be a boolean statement for if an object is a certain colour?

Nope. You need to keep track with your own boolean

photo
2

try with attached

photo
1

You are a genius. Thanks so much.

photo
© 2020 International GeoGebra Institute