SVG: A More Complex Logo

August 17, 2014Category: WebTags: ,

My logo is extreme simple. It has two shapes and is all straight lines. Because of this simplicity, I had no trouble converting it to SVG, and the entire file ended up being four lines of code. My next challenge, then, is to convert a more complex logo, one which involves more shapes, and shapes which involve curves. My partner at Catstache has a logo which fits the bill. It’s complex, has many layers, and is more than one color. So can it be done well in SVG? Lets take a look at the logo in PNG first:

svgcomplexlogo1

As you can see there is a pen (which also is two letters), plus an ink drop, and a curved line. And this is all on a double circle. We’ll need 6 different shapes to create the entire thing. Lets get started!


We first need to create the SVG wrapper code. I’m going to give it dimensions of 250 by 250. These will scale when it’s displayed, but it’s large enough that we won’t have to use partial numbers much:

<svg version="1.1" baseProfile="full" width="250" height="250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

</svg>

Inside that code, we’ll add all of our shapes. SVG does z layering in order of code. The first element that you type will be on the bottom, and the last one will be on the top. So we’ll start with a gray circle. To create this, I’m going to use the circle element. I’ll center it by giving it an x and y coordinates of 125, as well as a radius of 125:

<circle cx="125" cy="125" r="125" fill="rgb(24,24,24)" />

This gives us: (Open Live Example)

svgcomplexlogo2

Next up is the white border. Since this isn’t on the outside, we need another circle, slightly smaller. It needs a white border, and transparent fill.

Adding this gives us: (Open Live Example)

svgcomplexlogo3

Now that we have the background done, we need to start on the shapes. I’m going to do the pen first. I’m going to create a line using, and it will have two segments, all straight. The way this is created is really odd. You basically use letters as commands, inside the d attribute. M with coordinates is where the line starts, then L with coordinates means it moves to those new coordinates. A line with 2 segments has 3 points. So we’ll use an M and two Ls.

<path d="M192 50 L170 111 L186 117" stroke-width="4" stroke="white" fill="transparent" />

Adding this gives us: (Open Live Example)

svgcomplexlogo4

The bottom portion of the pen shape consists of 4 segments, which means five coordinates. We’ll use another , this time with an “M” and four “L”s.

<path d="M183 125 L167 170 L163 161 L146 175 L166 117" stroke-width="4" stroke="white" fill="transparent" />

Adding this gives us: (Open Live Example)

svgcomplexlogo5

Next up, we need the ink drop. When I researched the shape, I found out that it is possible to make an ink drop. It’s extremely complex though, so we are going to simply slightly and use an ellipsis. At most resolutions, it will be a negligible difference anyway. I’m also going to rotate it, to get the long radius angled towards the pen tip. This shape is similar to the circle, in that we declare the coordinates of the center. The difference is that there is an x radius and a y radius. Also, we are rotating 15 degrees, which is another attribute.

<ellipse transform="rotate(15)" cx="183" cy="150" rx="3" ry="5" fill="white" />

Adding this gives us: (Open Live Example)

svgcomplexlogo6

Finally, we need to create the curving trail that the pen has already left. This is the most complex part. SVG has several ways to do curves, and to be honest I don’t really fully understand them all. But the easiest is a method in which you define 4 points to make a single arc. We still use the , and still use the “d” attribute. Instead of an “L” command, we use a “Q” to create the curve. For this specific shape, we’ll need to combine several arcs. After playing around for about a half hour, I got a long that looks very similar to the goal.

<path d="M130,193 C81,208 132,153 71,170 Q32,181 49,158" stroke-width="2" stroke="white" fill="transparent" />

Adding this gives us: (Open Live Example)

svgcomplexlogo7

Success! The final code ends up being:

<svg version="1.1" baseProfile="full" width="250" height="250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <circle cx="125" cy="125" r="125" fill="rgb(24,24,24)" />
    <circle cx="125" cy="125" r="115" fill="transparent" stroke="white" stroke-width="4" />
    <path d="M192 50 L170 111 L186 117" stroke-width="4" stroke="white" fill="transparent" />
    <path d="M183 125 L167 170 L163 161 L146 175 L166 117" stroke-width="4" stroke="white" fill="transparent" />
    <ellipse transform="rotate(15)" cx="183" cy="150" rx="3" ry="5" fill="white" />
    <path d="M130,193 C81,208 132,153 71,170 Q32,181 49,158" stroke-width="2" stroke="white" fill="transparent" />
</svg>