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)); fillRect (Rectangle<float> (x, y, width, height)); }
void Graphics::drawImageWithin (const Image& imageToDraw, const int destX, const int destY, const int destW, const int destH, const RectanglePlacement& placementWithinTarget, const bool fillAlphaChannelWithCurrentBrush) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (destX, destY, destW, destH)); if (imageToDraw.isValid()) { const int imageW = imageToDraw.getWidth(); const int imageH = imageToDraw.getHeight(); if (imageW > 0 && imageH > 0) { double newX = 0.0, newY = 0.0; double newW = imageW; double newH = imageH; placementWithinTarget.applyTo (newX, newY, newW, newH, destX, destY, destW, destH); if (newW > 0 && newH > 0) { drawImage (imageToDraw, roundToInt (newX), roundToInt (newY), roundToInt (newW), roundToInt (newH), 0, 0, imageW, imageH, fillAlphaChannelWithCurrentBrush); } } } }
//============================================================================== void Graphics::fillRect (int x, int y, int width, int height) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); context.fillRect (Rectangle<int> (x, y, width, height), false); }
void Graphics::drawBevel (const int x, const int y, const int width, const int height, const int bevelThickness, const Colour& topLeftColour, const Colour& bottomRightColour, const bool useGradient, const bool sharpEdgeOnOutside) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); if (clipRegionIntersects (Rectangle<int> (x, y, width, height))) { context->saveState(); const float oldOpacity = 1.0f;//xxx state->colour.getFloatAlpha(); const float ramp = oldOpacity / bevelThickness; for (int i = bevelThickness; --i >= 0;) { const float op = useGradient ? ramp * (sharpEdgeOnOutside ? bevelThickness - i : i) : oldOpacity; context->setFill (topLeftColour.withMultipliedAlpha (op)); context->fillRect (Rectangle<int> (x + i, y + i, width - i * 2, 1), false); context->setFill (topLeftColour.withMultipliedAlpha (op * 0.75f)); context->fillRect (Rectangle<int> (x + i, y + i + 1, 1, height - i * 2 - 2), false); context->setFill (bottomRightColour.withMultipliedAlpha (op)); context->fillRect (Rectangle<int> (x + i, y + height - i - 1, width - i * 2, 1), false); context->setFill (bottomRightColour.withMultipliedAlpha (op * 0.75f)); context->fillRect (Rectangle<int> (x + width - i - 1, y + i + 1, 1, height - i * 2 - 2), false); } context->restoreState(); } }
void Graphics::drawImage (const Image& imageToDraw, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, const bool fillAlphaChannelWithCurrentBrush) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (dx, dy, dw, dh)); jassert (areCoordsSensibleNumbers (sx, sy, sw, sh)); if (imageToDraw.isValid() && context.clipRegionIntersects (Rectangle<int> (dx, dy, dw, dh))) { drawImageTransformed (imageToDraw.getClippedImage (Rectangle<int> (sx, sy, sw, sh)), AffineTransform::scale (dw / (float) sw, dh / (float) sh) .translated ((float) dx, (float) dy), fillAlphaChannelWithCurrentBrush); } }
void Graphics::fillRoundedRectangle (const float x, const float y, const float width, const float height, const float cornerSize) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); Path p; p.addRoundedRectangle (x, y, width, height, cornerSize); fillPath (p); }
void Graphics::fillEllipse (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.addEllipse (x, y, width, height); fillPath (p); }
void Graphics::drawRoundedRectangle (const float x, const float y, const float width, const float height, const float cornerSize, const float lineThickness) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); Path p; p.addRoundedRectangle (x, y, width, height, cornerSize); strokePath (p, PathStrokeType (lineThickness)); }
//============================================================================== void Graphics::drawRect (const int x, const int y, const int width, const int height, const int lineThickness) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); context.fillRect (Rectangle<int> (x, y, width, lineThickness), false); context.fillRect (Rectangle<int> (x, y + lineThickness, lineThickness, height - lineThickness * 2), false); context.fillRect (Rectangle<int> (x + width - lineThickness, y + lineThickness, lineThickness, height - lineThickness * 2), false); 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 { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); Path p; p.addRectangle (x, y, width, lineThickness); p.addRectangle (x, y + lineThickness, lineThickness, height - lineThickness * 2.0f); p.addRectangle (x + width - lineThickness, y + lineThickness, lineThickness, height - lineThickness * 2.0f); p.addRectangle (x, y + height - lineThickness, width, lineThickness); fillPath (p); }