Browse Source

Added a couple of methods to Graphics.

tags/2021-05-28
jules 13 years ago
parent
commit
b416ab6651
3 changed files with 28 additions and 7 deletions
  1. +0
    -1
      modules/juce_audio_basics/sources/juce_BufferingAudioSource.h
  2. +15
    -4
      modules/juce_graphics/contexts/juce_GraphicsContext.cpp
  3. +13
    -2
      modules/juce_graphics/contexts/juce_GraphicsContext.h

+ 0
- 1
modules/juce_audio_basics/sources/juce_BufferingAudioSource.h View File

@@ -103,7 +103,6 @@ private:
double volatile sampleRate;
bool wasSourceLooping, isPrepared;
friend class SharedBufferingAudioSourceThread;
bool readNextBufferChunk();
void readBufferSection (int64 start, int length, int bufferOffset);
int useTimeSlice();


+ 15
- 4
modules/juce_graphics/contexts/juce_GraphicsContext.cpp View File

@@ -343,14 +343,19 @@ void Graphics::fillRect (const Rectangle<int>& r) const
context.fillRect (r, false);
}
void Graphics::fillRect (const Rectangle<float>& rectangle) const
{
Path p;
p.addRectangle (rectangle);
fillPath (p);
}
void Graphics::fillRect (const float x, const float y, const float width, const float height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addRectangle (x, y, width, height);
fillPath (p);
fillRect (Rectangle<float> (x, y, width, height));
}
void Graphics::setPixel (int x, int y) const
@@ -406,7 +411,8 @@ void Graphics::drawRect (const int x, const int y, const int width, const int he
context.fillRect (Rectangle<int> (x, y + height - lineThickness, width, lineThickness), false);
}
void Graphics::drawRect (const float x, const float y, const float width, const float height, const float lineThickness) const
void Graphics::drawRect (const float x, const float y, const float width, const float height,
const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -424,6 +430,11 @@ void Graphics::drawRect (const Rectangle<int>& r, const int lineThickness) const
drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness);
}
void Graphics::drawRect (const Rectangle<float>& r, const float lineThickness) const
{
drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness);
}
//==============================================================================
void Graphics::fillEllipse (const Rectangle<float>& area) const
{


+ 13
- 2
modules/juce_graphics/contexts/juce_GraphicsContext.h View File

@@ -273,6 +273,9 @@ public:
/** Fills a rectangle with the current colour or brush. */
void fillRect (const Rectangle<int>& rectangle) const;
/** Fills a rectangle with the current colour or brush. */
void fillRect (const Rectangle<float>& rectangle) const;
/** Fills a rectangle with the current colour or brush.
This uses sub-pixel positioning so is slower than the fillRect method which
@@ -327,8 +330,16 @@ public:
@see fillRect
*/
void drawRect (const Rectangle<int>& rectangle,
int lineThickness = 1) const;
void drawRect (const Rectangle<int>& rectangle, int lineThickness = 1) const;
/** Draws four lines to form a rectangular outline, using the current colour or brush.
The lines are drawn inside the given rectangle, and greater line thicknesses
extend inwards.
@see fillRect
*/
void drawRect (const Rectangle<float>& rectangle, float lineThickness = 1.0f) const;
/** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.


Loading…
Cancel
Save