Illustrate a metallic padlock in Inkscape

Involved Inkscape Tutorial


Creating non-linear or non-concentric gradients can be a tricky proposition when you're using Inkscape. But fear not, because for 'regular' shapes we can use some simple techniques to simulate rounded shapes with light and shadow using some of the filters and path operations easily available to us.

In this tutorial I'll show you how, with some straightforward planning and consideration for path shapes, overlaps and creation, we can understand how light and shadow can be incorporated into our Inkscape vector work without tying yourself in knots about the lack of Gradient Meshes.

Let's take a look at the image we'll be assembling in this tutorial.

A shiny metallic padlock created in Inkscape

Skills you'll develop in this tutorial

Ready for it? Let's begin.

Step 1 - Create a new document and the base lock shape

Open up Inkscape with a new, blank canvas, and go to the Document Properties via File --> Document Properties or by pressing Ctrl, Shift and D. Set the canvas size to 300 pixels square. Close the dialog box and switch on Inkscape's default grid with the # key.

Create a new canvas for the padlock illustration

Activate the Rectangle Tool with the R key and draw a shape which is 175 pixels wide by 130 tall, using the grid as a guide. Allow the edges to snap to the grid, and round the shape's corners slightly using the handles; hold the Ctrl key down to round both corners equally at the same time.

Draw the padlock's base rectangle

Open the Fill and Stroke dialog box and select a fill colour of #faefbd. Click the Linear Gradient fill button and go into the Gradient Editor by clicking the Edit button.

Set the box's initial fill and swap to a linear gradient

Click the Add Stop button once so that we have 3 gradient stops in all. Select the second and third stops and change their colours to #d2be74 and #796d47 respectively, at full opacity (A = 255 in the bottom box and slider).

Create an initial gradient fill for the padlock

To give the padlock a feel of being slightly 'shaped', we can adjust the positioning of these gradient stops in a clever fashion.

Swap to the Gradient Tool (accessed via Ctrl and F1) and drag the gradient's start point - the lightest colour - into the centre of the rectangle. Slide the middle gradient stop much nearer to the outside edge, then find the Repeat drop-down box on the Fill and Stroke panel and select the Reflected option.

Give the padlock a gold-plated and shaped appearance with a reflected gradient

Change to the Pen Tool (keyboard B) and, using the grid as your snap-to guide, Click on a point on either edge of the shape, then press Enter to draw in the line. This will give us a horizontal bar which is exactly the same width as the lock shape. Give this line a Stroke width of 1 pixel and a Stroke colour of black.

Draw the first horizontal line across the padlock

Do this again for a second line, but make this one white instead. Swap to the Select Tool (F1), and use the keyboard arrow keys to position this line directly above the black one - one pixel higher. A bullet-proof way of doing this is to use the toolbar to set the X and Y positions manually. What it lacks in style it makes up for in efficacy. It's up to you.

Position the white line immediately above the black one

I've switched my grid off there to show that more clearly. Drag a selection area around these two lines with the Select Tool and put them together into a group by pressing Ctrl and G or by going to menus and selecting Object --> Group objects. Then jump back to the Fill and Stroke dialog and lower the opacity of this group to around 20%.

Group the lines and lower their opacities as one

Select the group and Duplicate it with Ctrl and D or Edit --> Duplicate. Move this duplicate downwards by 20 pixels, either with the arrow keys or using the mouse. Repeat the process a few times, moving each duplicated group by the same amount so that they're evenly-spaced. When you're done, your padlock base should have a nice ridged-look to it.

Duplicate the line group and distribute them across the base to create a ridged look

Complete the construction of this shape by adding an outline stroke to it. Give it a colour of #796d47 to match with the end-point of our gradient from before.

Duplicate the line group and distribute them across the base to create a ridged look

Step 2 - Create the padlock's metallic shackle

On to the business end of things - creating the shackle. Initially, we'll work on a new layer above the base, although eventually this will sit beneath the base. So, open up the Layers panel with Ctrl, Shift and L and click the + button, or hit Layer --> Add Layer in the menus. Name the layer "Shackle" and accept the Above current setting.

Add a new layer to create the shackle on

I'll switch my grid back on at this point. Select the Ellipse Tool and draw a circle which has a diameter of 140 pixels. Hold down the Ctrl key as you click and drag, to constrain the shape to a circle. You can either watch the measurements in the information bar at the bottom of Inkscape's window to get the correct size, or draw it first and then resize afterwards.

Draw a circle for the first step of creating the shackle

Duplicate this shape, and shrink the duplicate to be 100 pixels in diameter (20 pixels less in radius). The way I like to do it is by using the Transform dialog box - Ctrl, Shift and M to bring it up, or Object --> Transform. Click the Scale tab and set the Width and Height to 100 pixels. Tick the Scale proportionally box to make life a bit easier.

Re-scale the duplicate circle to 100 pixels wide

Keep this circle selected and Shift-Click the original so they're both highlighted. Then press Ctrl and - on the keyboard, or select Path --> Difference in the menu, to leave a ring-shape on the canvas.

Remove the centre of the circle with a Difference operation

Draw a large, wide rectangle which covers the lower half of your ring-shape, and repeat the Difference step from above, so that you've got just a U-shape left behind. The grid will help you to hit the exact mid-point of the circle on each side so it's a perfect 'U'.

Use a rectangle shape to take away the un-needed lower half of the ring

Keeping the Rectangle Tool at hand, draw a tall rectangle 20 pixels wide and 60 pixels tall, which touches the edge of that shape we've just created. Then Duplicate it and move it to the same point on the other side of the ring. Join all three elements together by holding Shift and clicking them, then pressing Ctrl and +. The menu option of Path --> Union will do the same thing.

Join all the shackle components together with the Union operator

Good work. This shape is going to be very important to us, and we'll need to be able to easily pick it up again later, so at this point I'm going to recommend assigning it an ID so we can retrieve it quickly at any time. Hit Ctrl, Shift and O, or use Object --> Object Properties and type something memorable for this shape into the ID field. As there are no other IDs on the page, I'm going to simply choose "U".

Give your shackle shape an ID to make it easy to find later

Trust me: you'll be glad we did that, later. For now though, give this U-shape a fill colour of #dcdcdc - a light grey - and quickly make a Duplicate of it. Press Ctrl and ( twice, or select Path --> Inset from the menu twice, to make an inset U-shape. Give this copy a fill of #e7e7e7.

Create an inset shape and fill it with a lighter grey than before

Do this again, creating an inset from the original shape, but use four steps to the inset instead of two. Give this second inset a fill of fafafa.

Create a second inset shape and fill it with white

Select both the two inset shapes at the same time, then head over to our Fill and Stroke panel. Find the Blur option box and set a value of 4 for the blur.

Blur the inset shapes to create the illusion of a rounded edge

Aaa-ha! That's a really nice trick, isn't it? By blurring those two shapes, we can give the illusion of a 3-dimensional, rounded edge to this shackle. This is great, but we can it even better with some light and shadow.

Step 3 - Add light and shadow

To do this, we need to select the base 'U' again. The two blurred shapes are on top of everything in the drawing, so how can we do that? Remember that ID we assigned the original a few moments ago? Let's make use of that, and you'll see how easy it can be when you use Inkscape's features.

Press Ctrl and F or go to the Edit --> Find menu option, and enter your original object's ID into the appropriate box. When you click the Find button, Inkscape will pick it up and select it for you. Ultra-useful.

Use the Find function to locate objects with known properties or names

Duplicate the shape twice - these will appear at the top of your drawing. Select the topmost copy, and press the left arrow key four times, then the down arrow key four times to offset it slightly from the other duplicate. Feel free to go with mouse click-and-drags, or even use the Transform dialog box if you like, but I think this is the quickest way to do the job.

Add the first duplicate to the selection, then press Ctrl and - again to split the two Us into two resultant shapes from the non-overlapping areas.

Create the shackle shadow areas

Give this shape a black fill and Blur it by 4 pixels. Then reduce the opacity to about 20%.

Add a blur to the shackle shadow

Repeat this process, reversing the direction of the offsets, to create a white highlight on the other side of the shackle. Use an opacity of around 60% for this object, as they need to amplify the lighting of the padlock's chrome shackle.

Create the shape for the shackle's highlight

Add the highlight to the other side of the shackle

Lastly, draw two ellipses - one on either side of the shackle piece - that overlap the bottom of the straight parts. Make them black, reduce their opacity to around 10%, and Blur them by 15 pixels.

Add two small ellipses for extra shadows

Wonderful. There's only one problem here, though. All those blurred objects are extending past the edges of of the shackle shape, which will look strange unless we do something about it. Find your original U-shape, and Duplicate it one last time. Select ALL the objects on this layer with Ctrl and A, or drag a rubberband selection area around all the shackle objects, then select Object --> Clip --> Set in the menus.

Clip all the objects to the original U shape to deal with any leaking blurs

Outstanding work. We've used a single shape many times to generate that effect, but it's a process you can repeat on most curved shapes where you want to add form, depth, light and shadow; it's an extremely powerful technique in vector graphics.

Move this layer below the padlock base to see how it all comes together. Use the arrow buttons on the Layers panel to do this.

Move the padlock's shackle beneath the base to see the effect of the depth work

Step 3 - Add the finishing touches

Switch back to the top layer by clicking on it in the Layers panel. Activate the Rectangle Tool and draw a shape with a black fill which lies just inside the sides of the main padlock shape, and aligned with the bottom. Round the corners slightly, lower the opacity to 15% and apply a Blur of 4.

Move the padlock's shackle beneath the base to see the effect of the depth work

Change the fill-type to be a Linear Gradient, and use the Gradient Tool to set a vertical gradient from the bottom of the shape to a point about half way up it.

Apply a linear gradient on the bottom shadow

On the subject of shadows, let's quickly add one at the bottom of the drawing. With the Ellipse Tool, draw a very short, wide, black ellipse across the padlock which extends past both edges of it, with an Opacity of 20% and a Blur of 12. Send this object to the very back of the drawing with the End key, or by selecting Object --> Lower to Bottom in the menus. It's a subtle addition, but one that just helps to define the drawing and set it off against any background you add later.

Create a drop shadow for the padlock base as well

And there you have it - your very own shiny padlock in vector format, ready to use in your work. Go ahead and make an interesting background for it, if you like. I've just created a dark-coloured rectangle at the back of the drawing here and overlaid a subtle grainy texture.

Add a background to the drawing to show it off to full effect

Has this tutorial left you feeling all secure in your new-found knowledge? Have I got it all locked up, and have you got any Inkscape or GIMP tutorial requests you'd like me to try and create? Let me know in the comments section below.

Mark is the Editor and owner of Designmark Graphics Ltd. Publishing tutorial articles and guides for Inkscape and the GIMP, this blog aims to boost the profile of these Open Source graphics applications and showcase what they are capable of.

comments powered by Disqus

Connect with me

I'm on a range of social channels and, to get alerts as soon as new tutorials are published, subscribe to the RSS feed using the link below.

Search the site

Search the site for a topic or tutorial subject using the search box below:

What's this blog about?

The Designmark blog is the best online resource for Open Source Graphics software tutorials, showing you how to produce quality graphics in Inkscape and the GIMP. You can find out more about how this blog came to be and what's going on behind the scenes in this article.

Who's in charge here?

That would be me, Mark. You can learn more about me, my background and the design work I do on .

Things that built this blog