Retrieve the color from an SVG shape
<rect id="c1" x="510"
y="120" width="20px" height="20px" fill="pink" stroke="blue" onclick="setPenColour(evt)"/>
<![CDATA[
function setPenColour(evt) {
m_pen_colour = evt.target.getAttribute('fill');
}
]]>
Reference:
Tutorials - SVG [kevlindev.com]
Tutorials - SVG - Events [kevlindev.com]