29DrawableImage::DrawableImage() : bounds ({ 0.0f, 0.0f, 1.0f, 1.0f })
33DrawableImage::DrawableImage (
const DrawableImage& other)
36 opacity (other.opacity),
37 overlayColour (other.overlayColour),
40 setBounds (other.getBounds());
43DrawableImage::DrawableImage (
const Image& imageToUse)
45 setImageInternal (imageToUse);
48DrawableImage::~DrawableImage()
54 return std::make_unique<DrawableImage> (*
this);
58void DrawableImage::setImage (
const Image& imageToUse)
60 if (setImageInternal (imageToUse))
64void DrawableImage::setOpacity (
const float newOpacity)
69void DrawableImage::setOverlayColour (
Colour newOverlayColour)
71 overlayColour = newOverlayColour;
81 if (bounds != newBounds)
87 auto tr = bounds.topLeft + (bounds.topRight - bounds.topLeft) / (
float) image.getWidth();
88 auto bl = bounds.topLeft + (bounds.bottomLeft - bounds.topLeft) / (
float) image.getHeight();
90 auto t = AffineTransform::fromTargetPoints (bounds.topLeft.x, bounds.topLeft.y,
94 if (t.isSingularity())
107 if (opacity > 0.0f && ! overlayColour.isOpaque())
113 if (! overlayColour.isTransparent())
115 g.
setColour (overlayColour.withMultipliedAlpha (opacity));
123 return image.getBounds().toFloat();
126bool DrawableImage::hitTest (
int x,
int y)
128 return Drawable::hitTest (x, y) && image.isValid() && image.getPixelAt (x, y).getAlpha() >= 127;
131Path DrawableImage::getOutlineAsPath()
const
137bool DrawableImage::setImageInternal (
const Image& imageToUse)
139 if (image != imageToUse)
142 setBounds (image.getBounds());
143 setBoundingBox (image.getBounds().toFloat());
153 return std::make_unique<AccessibilityHandler> (*
this, AccessibilityRole::image);
Represents a colour, also including a transparency value.
A graphics context, used for drawing a component or image.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void drawImageAt(const Image &imageToDraw, int topLeftX, int topLeftY, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image.
void setColour(Colour newColour)
Changes the current drawing colour.
Holds a fixed-size bitmap.
Represents a parallelogram that is defined by 3 points.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
Manages a rectangle and allows geometric operations to be performed on it.