# Du bleu foncé au bleu clair

Rousseau-Wallon shared this question 2 weeks ago

Bonjour,

J'ai construit une courbe implicite qui dépend du paramètre petit O. Comment faire pour que sa couleur passe du bleu foncé au bleu clair, sachant qu'elle doit s'éclaircir lorsqu'elle s'éloigne du triangle ?

J'ai fait une tentative de réglage dynamique de sa couleur, mais sans réussir.

Merci

Files: tonm.ggb

1

Not a wonderful solution... but it can be an idea.

I've picked up 11 RGB shades of blue, created their ordered lists of values for Red (rList), Blue (bList) and Green (gList) and put the list in the dynamic colors of the curve.

Values are divided by 255 because dynamic colors are meant of values in [0,1]

Please have a look, maybe it can inspire you a better solution than mine.

1

Comment faire pour obtenir ça :

1

What about activating the trace for the curve, then dragging the slider?

Or do you want something permanent? In that case you'll need to fill areas 😨

1

Oui, quelque chose de permanent, et en plus de dynamique (en fonction des sommets du triangle).

Mais c'est très très lent. Comment obtenir l'image sans trop de calculs, de façon à ce que ce soit fluide ?

1

Might be difficult to get "fast" computations of those 3-ellipses. Afaik there there is no general parametric form for them. Maybe the computation becomes faster if you don't use a representation with so many square-roots but instead a polynomial (in x and y) of degree 8. (If it helps: That polynomial can be derived as a determinant of a matrix (see http://math.ucsd.edu/~njw/P... page 3 bottom and page 4).

1

Avec SoitEpaisseurTracé(eqk, 100) ?

1

Defining the dynamic colors based on o is in priniple the right approach, but your problem is that you are changing only the blue colour and not the others. This way the colour changes from something with low blue component to something with a high blue component (in the RGB sense which is rather un-intuitive anyway).

I'll show a few simple approaches and a more sophisticated approach and discuss how well they resemble what you probably want. (Also see the attachment for how those approaches work.)

• Your idea was to let Red and Blue constant and only change Blue. This will not work too well. First of all, whenever Blue is not significantly higher than Red or Green, you will end up with a color that is not blue at all. Which means you basically need very low Red and Green values. That way the color will range from a very dark blue (even black if you start at 0) to a very bright blue but it will never become a light blue.
• To get a light blue (or light colors in general), all three RGB components must be high. A simple way to guarantee a blue shade would be to simply let Blue stay constant (and very high) and gradually change Red and Green from 0 to the Blue-value (or maybe better to something lower than the blue value not not end up with light grey or white). Now you have kind of the opposite problem than before: the color will range from a very bright blue to a very light blue, but never be a dark blue.
• An obvious way to deal with the shortcomings of these two approaches is to combine them. For example use the first approach for o from 0 to 5 and the second for o from 5 to 10. Or maybe just have different rate of change for Red/Green and Blue (e.g. quadratic vs. inverse quadratic). This simple approach works well enough as long as you want to do this only with Blue or Red or Green, but not well suited for "mixed" colors and also lacks a bit of smoothness.
• A more sophisticated approach (which is much smoother and easily adaptable to any color) is to simply not work with RGB directly but instead use a different color model that better fits our perception of colors (and have it automatically converted into RGB). Since you basically want a fixed color and only adjust the 'lightness', the HSL model is likely the best choice. You can chose a fixed Hue (the "color"), a fixed Saturation (how bright it should be), and only change the Lightness based on the value of o. It makes for a smooth change without changing the perceived color.
• And you can easily switch to any other Hue or Saturation and adjust the Lightness range without worrying what that means in RGB terms.