There’s a LOT of things that are confusing…
First, trying to follow this with graph paper is error-prone because in Juce graphics (common with Win32 and X-Windows) the TOP is 0, and positive is DOWN.
Second, the calculation for “diagonale” gives a negative X/Y value, not the positive I was mentally expecting.
Third, I was wondering where the “origin” was and thanks to “auto” I didn’t know these types were points, I thought they might be line segments So now I see that if we’re storing a vector in a data type called point, then distance to origin is vector length. Simple enough–but not obvious at first (I’ve only had about 4 hours programming with Juce so I don’t know any of these methods etc.).
Fourth, what you call “perpendicular” is a unit vector, that you then scale to “height”, which is the distance from the top right point to that “diagonale”. (And distance from “diagonale” to the bottom left point.)
And fifth, I had no idea you could get that height simply by dividing the area by the diagonal length. How did you think of that?!
So in short, grad is an infinite sheet with a gradiated band aligned with that diagonal, and the width of this band is just enough to cover the upper-left and lower-right corners.
Now I wanted to have “white” top left, “black” bottom right. But that flipped some signs and not others, flipping to -90, etc. I ended up building the grad with points (0,0) and height * perpendicular * 2. (After about 12 tries!)
Thanks again Daniel. I have to say the Juce documentation is basic at best, but the forum support is excellent.