Making Path::perpendicularOffset public?


#1

I’m using juce 1.46, and would like to write my own routine for drawing arrows on lines.

Doing so would be facilitated if perpendicularOffset were made a public function. It could continue to remain static, but as it stands now, that function isn’t declared in the header, and is inaccessible by any drawing routine I might write.

If this change has already been made for a more current version of juce, that would be added incentive to update!


#2

I thought there was already code in the Line class to calculate that?


#3

Sorry, I should have given more detail.

You’re right, there’s code in the Line class to draw an arrowhead. The line class calls Path::addArrow(), and addArrow() in turn calls perpendicularOffset() to calculate the path to draw.

I’d like to draw an arrowhead that’s just two lines, not filled. To do so, I have to write my own arrowhead drawing routine, which is easy to do by simply copying and changing the one in the Line class. The code in the Line class relies on perpendicularOffset(), which is declared outside of any class as static void, and thus, I’m unable to use it directly, without copying it into my class.

It’s great that that code is there, I’d love to use it rather than copying it. It seems like a useful routine to have for other purposes as well, hence I thought it might be a candidate for public access.


#4

I meant Line::getPointAlongLine, which takes a perpendicular offset - that’ll do what you need.


#5

Ah, much thanks. That’s perfect.


#6