How has the JUCELogo-Path been created?


#1

The JUCE logo on the IntroScreen of the JuceDemo is a Path ( MainAppWindow::getJUCELogoPath() ).

I assume the original Path wasn't painfully created by hand. It's more likely that the logo was created with a vector graphic software like Adobe Illustrator or Inkscape and saved as SVG. If so, how has it been converted to a JUCE::Path?

 

There is Drawable::createFromSVG (const XmlElement &svgDocument) which returns a Drawable*. Internally this creates a DrawableComposite. But is there a way to get some pathes out of this Drawable?

There are also some functions in juce_SVGParser.cpp, but I couldn't figure out how to use them to go from a SVG XML to a Path.

 

What I did:

    Path logo;

    String xmlString = String::fromUTF8 (BinaryData::logo_svg, BinaryData::logo_svgSize);
    ScopedPointer<XmlElement> xml = XmlDocument::parse (xmlString);
    
    // This is ugly and only works with this specific SVG (it doesn't dive into nested groups)
    if (xml != nullptr && xml->hasTagName("svg"))
    {
        XmlElement* svgGroup = xml->getFirstChildElement();
        
        while (svgGroup != nullptr)
        {
            if (svgGroup->hasTagName ("g"))
            {
                XmlElement* path = svgGroup->getFirstChildElement();
                
                while (path != nullptr)
                {
                    if (path->hasTagName ("path"))
                    {
                        logo.addPath (Drawable::parseSVGPath (path->getStringAttribute ("d")));
                    }
                    
                    path = path->getNextElement();
                }
            }
            
            svgGroup = svgGroup->getNextElement();
        }
    }

Is there a better/easier way to extract the pathes from an SVG?

 


#2

The introjucer has a tool to do this on its tools menu.


#3

Oh, how comfortable. Thanks for this nice tool!