1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a couple of methods to Graphics.

This commit is contained in:
jules 2012-10-13 11:17:21 +01:00
parent 310c063195
commit b416ab6651
3 changed files with 28 additions and 7 deletions

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();

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
{

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.