2

Can anybody help me with drawing hollow rectangle with svg WITHOUT using any js lib(e.g. Raphael)?
In basic, it should be same idea as "donut shape" but rectangle.
something like this:

enter image description here

Korvin Szanto
  • 4,531
  • 4
  • 19
  • 49
user1634692
  • 25
  • 1
  • 4

2 Answers2

8

Here you go

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 2624 1462" width="1312" height="736" id="svg2">

  <path d="M 80,112 l 528,0 0,528 -528,0 z m -64,-64.000003 656,0 0,656.000023 -656,0 z" fill="gold" stroke="black" fill-rule="evenodd" />

</svg>

The path winds in one direction outside and the other inside and the evenodd fill-rule cuts out the middle.

jedierikb
  • 12,752
  • 22
  • 95
  • 166
Robert Longson
  • 118,664
  • 26
  • 252
  • 242
4

Here's an example:

<svg viewBox="0 0 400 400" shape-rendering="crispEdges">
    <path d="M10,10h100v100h-100zM20,20v80h80v-80z" fill="yellow" stroke="black"/>
</svg>
Erik Dahlström
  • 59,452
  • 12
  • 120
  • 139