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

**URL:** <https://forum.juce.com/t/is-it-ok-to-call-g-strokepath-on-a-path-that-is-not-closed/67337>\
**Category:** Audio Plugins\
**Created:** [October 10, 2025, 7:28pm UTC](https://forum.juce.com/t/is-it-ok-to-call-g-strokepath-on-a-path-that-is-not-closed/67337 "2025-10-10T19:28:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [October 10, 2025, 7:28pm UTC](https://forum.juce.com/t/is-it-ok-to-call-g-strokepath-on-a-path-that-is-not-closed/67337/1 "2025-10-10T19:28:19Z")

</div>

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.

```cpp
    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:

```cpp
    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.

 ![Screenshot 2025-10-10 at 15.25.10](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/9/b/9b191375d6bb765264cacc9d084183007aeabf8f.png)
