Graphics::drawArrow - new param/feature request


#1

Hey Jules,
I hope this is the best place for this post.
Would it be too difficult to add quadratic shaping to the line for this function?
A sloped drawArrow essentially.
A simple hack would be to draw a sloped(arc) line (dashed or not) from v1 to v2. Then apply a shorter line call to drawArrow() at v2 figuring the ending direction into the equation.
That would be cool. 8)
Cheers,
CD


#2

Yeah, not a bad idea. Maybe the best way would be to give the Path class the ability to create a stroke that has arrowheads on the ends. Then it could be any shape at all. Hmm, that’d actually be quite a cool feature for me to add to the new jucer vector graphics editor…


#3

Good call on the Path integration. Yeah, that would be a neat feature - indeed :wink:
CD


#4

Hey,
I have another idea - not related to drawArrow but perhaps just as useful. I don’t see anything under Graphics:: which fits the bill.
A way to draw symmetrical multi-sided objects, such as triangles, pentagons, hexagons, septagons, octagons, etc.

enum {
triangle,
// square,
pentagon,
hexagon,
septagon,
octagon
// perhaps more… after a certain point - it’ll just turn into a circle… esp with antialiasing.
}Sides;

Graphics::drawMultigon(float x, float y, float diam /* or radius */, float lineThickness=1.0f, const Sides mType);

Cheers,
CD


#5

Good suggestion! I’m tinkering with some geometry code at the moment so may have a go at this stuff.


#6

Very nice. I see in the HEAD you’ve added the new arrow end cap for Paths (plus a bunch of other stuff too). Let me check it out. :wink:
CD


#7

Yep, I’ve been doing a lot of geometry stuff this week.


#8

Ok, fun. lol check it out. I did the following to the basic hello world app. Gotta silly result.

[code]
void MainComponent::resized()
{

// inserted
PathStrokeType mystroke(2.0f);
mystroke.createStrokeWithArrowheads(internalPath1,internalPath1,15.0f,15.0f,25.0f,25.0f);

// end insert

internalPath1.closeSubPath();

}[/code]

It shows two arrows pointin back at each other! Too funny.
hmm. will have to play with it some more…
Also, would I have to create a new sub path to tweak the fill color of the arrows?

CD


#9

That might look odd because it’ll be rendering another stroke around the outline of the already-stroked path…

Well yes, a Path contains no colour information, so any differently coloured sections need to be created and drawn separately.


#10

Yeah, its what I was looking for. I appreciate you following up so quickly with a solution for this.
Thanks for that. Good job on everything. I’m satisfied.
Cheers,
CD


#11

Hey Jules,

Question: Is it possible to apply dashes to createStrokeWithArrowheads ?
Not sure how…
Also, a small issue with artifacts popping up (little spurious triangles), if I apply quadraticTo() before the above call to give a cool slope. Only occurs if the arrow head points back or near the origin (back to the source). Looks like a sub pixel rounding issue internally or something like that.

Thanks!
CD


#12

No, dashes would require a whole extra bunch of code to generate.

My algorithm isn’t going to be bulletproof - you could easily get it to go wrong if the curve bends too much along the section where it’s trying to draw the arrowhead.


#13

Ok. On the first issue, would it be possible to achieve adequate results using multiple paths?
Is it possible to do dashing on normal paths? I’m just exploring that now.

With the 2nd issue, its no biggie. I could either not worry about or enforce some kind of angular bounds.

Regardless, its still pretty cool as it is now. But more would be nice! :wink:
CD


#14

You can probably just break your path up and draw dashes for part of it, and an arrowhead for another bit.

Ideally, you’d need a stroke creator that can dynamically change the width along the entire length of the path to some user-defined pattern - that’d be able to create any kind of arrow/dashes/snake shapes. Too busy to write it at the moment though!


#15

cool deal. Get to it whenever you feel like it. I’m patient.
CD