From 78bfab2d1782141cf33d5a2b986cbd30d95759d8 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 12 Nov 2014 10:52:44 +0000 Subject: [PATCH] Added a Path::addTriangle method that takes Point parameters --- modules/juce_graphics/geometry/juce_Path.cpp | 19 +++++++++++++------ modules/juce_graphics/geometry/juce_Path.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index 5a6b2f8662..65c211fe3a 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -501,13 +501,20 @@ void Path::addRoundedRectangle (float x, float y, float w, float h, float cs) addRoundedRectangle (x, y, w, h, cs, cs); } -void Path::addTriangle (const float x1, const float y1, - const float x2, const float y2, - const float x3, const float y3) +void Path::addTriangle (float x1, float y1, + float x2, float y2, + float x3, float y3) { - startNewSubPath (x1, y1); - lineTo (x2, y2); - lineTo (x3, y3); + addTriangle (Point (x1, y1), + Point (x2, y2), + Point (x3, y3)); +} + +void Path::addTriangle (Point p1, Point p2, Point p3) +{ + startNewSubPath (p1); + lineTo (p2); + lineTo (p3); closeSubPath(); } diff --git a/modules/juce_graphics/geometry/juce_Path.h b/modules/juce_graphics/geometry/juce_Path.h index ac319f96f3..c680089f2d 100644 --- a/modules/juce_graphics/geometry/juce_Path.h +++ b/modules/juce_graphics/geometry/juce_Path.h @@ -377,6 +377,18 @@ public: float x2, float y2, float x3, float y3); + /** Adds a triangle to the path. + + The triangle is added as a new closed sub-path. (Any currently open paths will be left open). + + Note that whether the vertices are specified in clockwise or anticlockwise + order will affect how the triangle is filled when it overlaps other + shapes (the winding order setting will affect this of course). + */ + void addTriangle (Point point1, + Point point2, + Point point3); + /** Adds a quadrilateral to the path. The quad is added as a new closed sub-path. (Any currently open paths will be left open).