Browse Source

Added a version of Path::addEllipse that takes a Rectangle

tags/2021-05-28
jules 11 years ago
parent
commit
1a2a50f71d
4 changed files with 24 additions and 21 deletions
  1. +5
    -5
      modules/juce_graphics/contexts/juce_GraphicsContext.cpp
  2. +12
    -12
      modules/juce_graphics/geometry/juce_Path.cpp
  3. +6
    -2
      modules/juce_graphics/geometry/juce_Path.h
  4. +1
    -2
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp

+ 5
- 5
modules/juce_graphics/contexts/juce_GraphicsContext.cpp View File

@@ -438,14 +438,14 @@ void Graphics::drawRect (Rectangle<float> r, const float lineThickness) const
//==============================================================================
void Graphics::fillEllipse (const Rectangle<float>& area) const
{
fillEllipse (area.getX(), area.getY(), area.getWidth(), area.getHeight());
Path p;
p.addEllipse (area);
fillPath (p);
}
void Graphics::fillEllipse (float x, float y, float width, float height) const
void Graphics::fillEllipse (float x, float y, float w, float h) const
{
Path p;
p.addEllipse (x, y, width, height);
fillPath (p);
fillEllipse (Rectangle<float> (x, y, w, h));
}
void Graphics::drawEllipse (float x, float y, float width, float height, float lineThickness) const


+ 12
- 12
modules/juce_graphics/geometry/juce_Path.cpp View File

@@ -436,9 +436,7 @@ void Path::addRectangle (const float x, const float y,
data.elements [numElements++] = closeSubPathMarker;
}
void Path::addRoundedRectangle (const float x, const float y,
const float w, const float h,
float csx, float csy)
void Path::addRoundedRectangle (float x, float y, float w, float h, float csx, float csy)
{
addRoundedRectangle (x, y, w, h, csx, csy, true, true, true, true);
}
@@ -498,9 +496,7 @@ void Path::addRoundedRectangle (const float x, const float y, const float w, con
closeSubPath();
}
void Path::addRoundedRectangle (const float x, const float y,
const float w, const float h,
float cs)
void Path::addRoundedRectangle (float x, float y, float w, float h, float cs)
{
addRoundedRectangle (x, y, w, h, cs, cs);
}
@@ -527,15 +523,19 @@ void Path::addQuadrilateral (const float x1, const float y1,
closeSubPath();
}
void Path::addEllipse (const float x, const float y,
const float w, const float h)
void Path::addEllipse (float x, float y, float w, float h)
{
const float hw = w * 0.5f;
addEllipse (Rectangle<float> (x, y, w, h));
}
void Path::addEllipse (Rectangle<float> area)
{
const float hw = area.getWidth() * 0.5f;
const float hw55 = hw * 0.55f;
const float hh = h * 0.5f;
const float hh = area.getHeight() * 0.5f;
const float hh55 = hh * 0.55f;
const float cx = x + hw;
const float cy = y + hh;
const float cx = area.getX() + hw;
const float cy = area.getY() + hh;
startNewSubPath (cx, cy - hh);
cubicTo (cx + hw55, cy - hh, cx + hw, cy - hh55, cx + hw, cy);


+ 6
- 2
modules/juce_graphics/geometry/juce_Path.h View File

@@ -391,13 +391,17 @@ public:
float x4, float y4);
/** Adds an ellipse to the path.
The shape is added as a new sub-path. (Any currently open paths will be left open).
@see addArc
*/
void addEllipse (float x, float y, float width, float height);
/** Adds an ellipse to the path.
The shape is added as a new sub-path. (Any currently open paths will be left open).
@see addArc
*/
void addEllipse (Rectangle<float> area);
/** Adds an elliptical arc to the current path.
Note that when specifying the start and end angles, the curve will be drawn either clockwise


+ 1
- 2
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -452,8 +452,7 @@ void LookAndFeel_V2::drawAlertBox (Graphics& g, AlertWindow& alert,
colour = alert.getAlertType() == AlertWindow::InfoIcon ? (uint32) 0x605555ff : (uint32) 0x40b69900;
character = alert.getAlertType() == AlertWindow::InfoIcon ? 'i' : '?';
icon.addEllipse ((float) iconRect.getX(), (float) iconRect.getY(),
(float) iconRect.getWidth(), (float) iconRect.getHeight());
icon.addEllipse (iconRect.toFloat());
}
GlyphArrangement ga;


Loading…
Cancel
Save