G.strokePath Question


It is is possible to get coordinate on the Y axis?
like Y = f (B)?
Is it possible to apply the color to the interval A?


For the first question I think you might want to use 


I haven't tried but I assume that since you have a function, the nearest point to (x; 0) would be (xB ; yB) .

For the color I don't really know... Can't you draw the curve until a first control point at the beginning of segment A, then draw another  quadratic curve (with different color) to another control point at the end of segment A, then draw the end ?

I assume it depends on the QuadraticTo algorithm, the curve in the end might be less smooth (?)..


Nearest point returns something like this


I not think about what I can split curve, now I do not need this feature. Thank you :)


Point<float> Path::getPointAlongPath might also be of some use:


I think Adrien is problably correct in that you will need to use different path segments if you wish to colour on section of it differently to the rest. The Path::Iterator class might also be worth looking into, although I've never used it myself. 


You can colour the line differently by using a ColourGradient with several points e.g. in your above example you would have yellow at 0.0, 0.55 & 0.7 then purple at about 0.6 and 0.699. Something along those lines anyway.

Alternatively if you want block colour you could stroke the path several times, reducing or excluding the Graphics clipping region by a rectangle each time.


Made with a gradient, thanks for the tip.

One more question, I can update only the selected area? For example, only where the gradient.

I tried to reduceClipRegion but it clears all before drawing.


For question a)

It is is possible to get coordinate on the Y axis?get y axis

you can borrow the code from Path::intersectsLine http://www.juce.com/doc/classPath#a58919b7e0a5d57558c75d8814c31ef0e

The method returns a bool, but internally the intersection is known:

bool Path::intersectsLine (const Line<float>& line, const float tolerance)
    PathFlatteningIterator i (*this, AffineTransform(), tolerance);
    Point<float> intersection;

    while (i.next())
        if (line.intersects (Line<float> (i.x1, i.y1, i.x2, i.y2), intersection))
            return true;

    return false;

Give it a vertical line to intersect and return the point named intersection in the method. However, it is your responsibility to check

a) a path can intersect multiple times...

b) a path can intersect at no point at all

but I think this should get you on the track...