The Designmark Graphics blog
Quality tutorials for Inkscape and GIMP
Today we'll be using Inkscape to create a rippling chequered flag, which means tackling two quite tricky areas of drawing in this application - Envelope Distorts and perspective transformations. Both involve working with some of Inkscape's more temperamental tools, and for that reason I've designated this an 'involved' tutorial. Don't be too intimidated though, I've hopefully given you plenty of pointers on how to avoid the main errors which break people's designs when they try this sort of thing for themselves.
So, let's have a look at our final outcome before we begin:
Skills you'll be developing in this tutorial
- Producing grid patterns from basic starter shapes
- Using Live Path Effects to produce wavy groups of objects
- Basic use of Inkscape's Extensions to generate a Perspective transform of a design
Step 1 - Create the chequered pattern grid
Switch on Inkscape's grid by pressing the # key on the keyboard, and draw a square which is 30 pixels in width and height using the Rectangle Tool (R). Having the rectangle 'snap' to the grid squares will make things easy for us to start with.
If it doesn't already have a fill colour of black, bring up the Fill and Stroke dialog box with Ctrl, Shift and F, and set it to be black now.
Copy and paste this square then, using the Select Tool (F1), move the copy to the right so that it sits flush against the original. Our grid will help again to get the alignment right. Set this square's fill colour to white when it's in position.
With the Select Tool still active, click and drag a rubber band selection around these two squares to select them both. Copy and paste them and move the copies into position alongside the originals.
Repeat this process to build up a black and white chequered pattern for your flag. As the pattern gets bigger you can select more squares at a time to speed things up. Alternate the rows so that black squares always sits next to white ones and vice versa; this will involve re-arranging one of your squares to keep the overall pattern as a rectangle.
When it comes to dealing with perspective in Inkscape, this next step is where a lot of people go wrong. In order to the carry out the process, Inkscape must be looking at objects that are Paths only. The information in Inkscape's status bar at the bottom of the window tells us what sort of shapes we're dealing with. At the moment, everything we've created is a rectangle.
So, let's sort this out. Drag another rubber band selection area around all of your shapes, then go to Path --> Object to Path in the menus, or press Ctrl, Shift and C, to convert all these rectangles to paths.
Keep all your paths selected and pull them together into a single group by selecting Object --> Group in the menus, or by pressing Ctrl and G on the keyboard.
Step 2 - Generate the ripple effect
The plan is to give our flag a rippling effect first, then add the perspective later; it's much harder to do it the other way round. So with your grouped objects all selected, press Ctrl, Shift and 7, or go to Path --> Path Effect Editor in the menus and look at the panel that appears.
From the Apply New Effect dropdown box, select Envelope Deformation, then click Add to bring up the panel for editing. Click the Top Bend Path arrow to show the green path which we will use to create the first ripple. Move the mouse pointer over this green and line, then click and drag a section of it upwards, and another section downwards, to create a bended effect:
Repeat this process on the other edges of the flag by using the options from the Envelope Deformation area of the Path Effects panel, to get your flag looking as though it's fluttering in the breeze.
Do you remember I mentioned about making sure all the elements of our drawing are paths before we do the perspective transform? We need to do the same thing again here, now that we've applied a Path Effect to curve our flag. We can do this without having to ungroup our objects though, so go ahead and use Ctrl, Shift and C or the Path --> Object to Path menu option again.
Step 3 - Generate the perspective
Switch to the Pen Tool (B) and draw the frame that we're going to use to show Inkscape the perspective we want. This step is both easy to do right and easy to do wrong. Click the four corner-points of a quadrilateral which has roughly the same width and height as your original shape, starting at the bottom left-hand corner and going in a clockwise direction. When you've created the four points, click back on the starting point to close the shape and get this result:
Note: the correct order for the points on a perspective frame is bottom-left, top-left, top-right, bottom-right.
Now use the Node Tool (F2) to click and drag the points of this rectangular frame to create the tilted perspective we're after. Try to think about looking at a picture frame with one side being pushed away from you: the furthest edge will become slightly smaller and the corners will appear to be slightly closer to each other.
Now switch back to the Select Tool and click once on the flag pattern to select it. Hold down the Shift key and click on your perspective frame to add that to the selection second. Then go to the menus and choose Extensions --> Modify Path --> Perspective. It might take a moment or two to complete, but Inkscape will work out what you need and apply the transformation.
With Perspective transforms it's important to remember three things: make sure everything is a path, draw the perspective frame the right way round, and select the object to transform before selecting the frame. Do all that and it's easy. Well, kind of.
So, our flag is now waving happily away, but something's missing to convey that rippling feel of it blowing in the breeze. It needs some light and shadow across its surface to bring the effect to life, which we'll get on and create now.
Step 4 - Add light and shadow to enhance the perspective
The gradient you'll need for the job will depend on how many ripples you've put into your flag. Basically, what we're aiming to do is to identify where the flag is curving inwards and outwards, and assign light and shadow to these areas accordingly.
If it's not already selected, click on your flag shape to select it. Press Ctrl and C, then Ctrl, Alt and V to paste a copy of the group in place; that is, directly on top of the original. These options are both available in the Edit menu. Ungroup the flag shapes using Ctrl, Shift and G (or Object --? Ungroup), then combine them into one outline with Ctrl and +, or Path --> Union in the menus. You'll see the fill of the shape change when it's done.
Change the fill on this new shape to be a linear gradient, then click the Edit button to open up the Gradient Editor.
In my example, I identified three main areas that I think need some light and dark applying to them to enhance the feeling of perspective. Each light area will need a dark region to accompany it (and vice versa), so in my Gradient Editor window I'm going to use the Add Stop button until I can see six stops in the list in total.
Start by selecting each gradient stop from the dropdown list, and assigning it a value of either black or white; using the colour wheel is probably the easiest way of picking the colour. Start with black and alternate for each one going down the list. Use the Alpha slider to make these colours fully opaque for now so we can see the stripes on our shape and know we're doing it right.
As this shape overlays our original flag, the trick will be to work with low opacities in order to subtly hint at the flag's curvature and not spoil the colours underneath. Select each gradient stop from the dropdown list and assign it an Alpha value like the ones I've used below - in general, I've made the white stops more visible than the black, and kept each one fairly transparent throughout. You can either enter the values directly into the box or use the slider and your own judgement for what looks best.
Next, we need to position them across the surface of the flag, starting by angling it across the shape correctly. Press Ctrl and F1 to activate the Gradient Tool, then click on the shape to display the gradient stops visually on the overlay shape. Drag the start and end points so that they lie perpendicular to the flag shape.
Good start. Now adjust the gradient stop points so that the shadows are slightly closer to the highlights. Use the Gradient Tool to click on and drag the individual stops on the gradient path so that where you've got what looks like a ripple: assign it a highlight, then a shadow, at a distance that suits the bend in your flag. This is very much a 'by eye' adjustment, but it will enhance the feeling of the flag rippling in a breeze. I'll zoom in slightly to show you a close-up of the changes I've made on mine.
Step 5 - Run it up the flag pole
At the moment, our flag looks like it is just floating in mid-air, which is no use to anyone. We should create a pole to attach our flag to, and tie it on with some simple lines; both straightforward tasks compared to what we've achieved so far.
With the Rectangle tool once again, draw a shape which is about 10 pixels wide by 410 tall. Find one of the circular corner shape nodes at the top of the shape and, holding down the Ctrl key so that both corners are affected, click and drag this control node so that the top and bottom of your pole become fully rounded. Then head over to the Fill and Stroke panel (Ctrl, Shift and F) and start by giving it a solid fill of #d8d8d8ff - a darkish grey tone which is fully opaque.
Change the fill type to a linear gradient and click Edit to go back into the Gradient Editor. Set this gradient up to be a three-stop gradient. The first and third stops should be the afore-mentioned dark grey (#aeaeae), with the middle gradient stop given a colour of #d8d8d8. All should be opaque - an Alpha value of 255. If you've drawn your rectangle vertically, Inkscape should direct your gradient correctly straight away.
Use the Select tool to move this object roughly into position, then click on it once to show the rotation handles. Use the corner handles to turn the shape to the right orientation, then match it up to the corners of the flag. Repeat the process and adjust if necessary until everything sits nicely against each other.
Lovely. Just one more small job to finish the project off. Let's attach our flag to the pole with two very simple cords, drawn with the Pen Tool (B). Click and drag a path on two points on the image - where the flag touches the pole and on the opposite side of the pole - to create a slightly curved line to represent the attaching cord. Press the Enter key when you want Inkscape to draw the line.
In the Fill and Stroke dialog box, Click the Stroke style tab and choose the Round Cap option from the panel, and set a stroke width of 2 pixels using the box above it.
That's a nifty little effect: by making the curve slightly wider than the pole and giving it rounded tips, it gives the illusion of it being wrapped around the pole. It's not perfect, but when we zoom back out to 100%, you'll see it's good enough to carry it off. Copy and paste this line and move the copy to the other point where the flag is attached to see what we've got.
After that, you can go ahead and incorporate it into whatever design you're working on, or maybe just add a nice background and let it speak for itself.
Wow, that's looking great, well done! We've covered a lot of quite advanced techniques and ideas in this tutorial, from the Perspective extension to using Live Path Effects on groups of objects. Have you created your own flag design you'd like the rest of us to salute to? Leave a comment and link to your result.
Be aware that all comments are moderated before being published on site. Please be considerate to others in any comments you post and please don't spam.
1620 comments (newest first)