dynamic colors

Introduction
Following applet illustrates two ways to use dynamic colors. [br][list][*]The colors of the sign of a function f and the color of a Point P depent on a [b]given condition[/b].[br][/*][*]The colors of a slider s and a point C are calculated out of a[b] variable value[/b].[br][br][/*][*][b]sign of a function[/b]: The sign of a function [code]f(x)= ax + b[/code] depends from the values of a and b.[/*][*][b]color of a point P[/b]: Point P colors green when it's on the graph of f and red if it's not.[/*][*][b]color of a slider[/b]: The color of slider s changes while moving the slider.[/*][*][b]color of a point C[/b]: The color of point P changes if you drag it along the segment l.[/*][/list]
How do you do this?
[list][*][b]Sign of the function f[/b]: Create:[br]- a slider a from -4 to 4 with increment 0.5[br]- a slider b from-4 to 4 with increment 0.5[br]- a function [code]f(x) = a x + b[/code][br]- a number zero = -b/a[br]- a number [code]c = Integral(f, -50, zero)[/code][br]- a number [code]d = Integral(f, zero, 50)[br][/code]Open the Properties of c and d, select the tab Advanced and define their dynamic colors so that a[br][b]negative value will color red and a positive value will color green[/b].[br][table][tr][td][/td][td]colors of c[/td][td]colors of d[/td][/tr][tr][td]Red:[/td][td][code]If(c < 0, 1, 0)[/code][/td][td][code]If(c > 0, 0.7, 0)[/code][/td][/tr][tr][td]Green:[/td][td][code]If(d < 0, 1, 0)[/code][/td][td][code]If(d > 0, 0.7, 0)[/code][/td][/tr][tr][td]Blue:[/td][td][code]0[/code][/td][td][code]0[/code][/td][/tr][/table][br][/*][*][b]Color of the point P[/b]: Create a point P, open its Properties and select the tab Advanced.[br]Define its colors so that[b] P colors green when it's on the graph and green when it's not[/b].[br][table][tr][td]Red:[/td][td][code]If(Distance(P, f) > 0, 1, 0)[/code][/td][/tr][tr][td]Green:[/td][td][code]If(Distance(P, f) ≟ 0, 0.7, 0)[/code][/td][/tr][tr][td]Blue:[/td][td][code]0[/code][/td][/tr][/table][/*][*][b]Color of the slider s[/b]: Create a slider from [code]0[/code] to 1 with increment 0.1. [br]Define its color in the tab advanced of its Properties: [br][table][tr][td]Red:[/td][td][code]s[/code][/td][/tr][tr][td]Green[/td][td][code]0[/code][/td][/tr][tr][td]Blue[/td][td][code]1-s[/code][/td][/tr][/table]Moving the slider from 0 to 1 its color [b]will change from blue to red[/b].[br][br][/*][*][b]Color of the point C[/b]: Create:[br]- the Segment l between the points A and B: [code]l = Segment(A,B)[/code].[br]- the Point C on the segment.[br]- the Segment g between the points A and C: [code]g = Segment(A,C)[/code].[br]Define its colors so that C [b]will color from black to green[/b] while dragging it on the segment.[br][table][tr][td]Red:[/td][td][code]0[/code][/td][/tr][tr][td]Green:[/td][td][code]g/l[/code][/td][/tr][tr][td]Blue:[/td][td][code]0[/code][/td][/tr][/table][/*][/list]

Information: dynamic colors