Illustrate a metallic padlock in Inkscape
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.
Skills you'll develop in this tutorial
- Control and reforming of shapes
- Working with blurs and clipping to simulate gradients around a curved shape
- Creating areas of light and shadow in vector drawings to add depth and form to illustrated objects
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.
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.
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.
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).
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.
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.
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.
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%.
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.
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.
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.
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.
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.
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.
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'.
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.
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".
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.
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.
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.
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.
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.
Give this shape a black fill and Blur it by 4 pixels. Then reduce the opacity to about 20%.
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.
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.
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.
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.
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.
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.
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.
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.
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.
comments powered by Disqus