Is it OK to call g.strokePath() on a path that is not closed?

Suppose I update path (a class variable) outside the paint() function. You can assume that the actual path is much more complex than this. I don’t want to update that in each paint() function.

    auto bound = getLocalBounds().toFloat();
    const auto temp_bound = bound.reduced(5.f);
    path.clear();
    path.startNewSubPath(temp_bound.getBottomLeft());
    path.lineTo(temp_bound.getTopRight());
    path.lineTo(temp_bound.getBottomRight());

Now, suppose the path has N points:

  • I want to stroke the path from point 1 to point N (but not point N to point 1)
  • I want to fill the closed area of path

Instead of creating another path & close that path, can I reuse the path like this:

    g.setColour(juce::Colours::orange);
    g.fillPath(path);
    g.setColour(juce::Colours::white);
    g.strokePath(path, juce::PathStrokeType{2.5f});

I have tested on macOS & Windows and the result is the same as expected. But I am not sure whether it is safe to assume that it will always work.