[SOLVED] SVG positioning and color


#1

Hi guys,
I’m building a resizable GUI and I’m using an SVG for my logo. I’ve been able to draw it as a DrawableComposite, but I’m struggling with its positioning and, more importantly, its colour. Since users will be able to change the color palette of this product, I do really need that the logo colour should change according to the user selection. I tried with “replaceColour”, but it’s not working.

Thanks!

Edit:
Solved this way

MemoryInputStream svgLogoStream(BinaryData::logo_svg, BinaryData::logo_svgSize, false);

svgLogo = dynamic_cast <DrawableComposite*> (Drawable::createFromImageDataStream (svgLogoStream));

if (svgLogo != nullptr)
{
    svgLogo->replaceColour(Colours::black, textColourLight);
    AffineTransform transform = AffineTransform::scale(0.15f, 0.15f).followedBy(AffineTransform::translation(10.f, 10.f));
    svgLogo->draw (g, 1.0f, transform);
}

#2

I would also love to know how to adjust an SVG colour!


#3

as far as i remember you can set fill of DrawableShape that can be extracted from DrawableComposite’s tree. In case of an SVG, its DrawableComposite is a tree of shapes and groups that are equivalent to the SVG structure itself.