Outils pour utilisateurs

Outils du site


issue66:tutoriel_-_inkscape

Ceci est une ancienne révision du document !


Intro Paths

This instalment is going to introduce the most powerful of Inkscape's drawing primitives: Paths. I say 'introduce' because paths can be created, used and manipulated in many different ways, so we'll come back to them time and time again as these tutorials progress. But, this month, we'll keep it simple and start with the Line tool (SHIFT+F6, or “b”). Select the tool, click once on the canvas, then move the cursor to another part of the canvas before double-clicking to finish your path. You've just created the simplest type of path there is: a straight line. Try giving the stroke a color and thickness using the Fill and Stroke dialog or the tools on the status bar that we've covered previously. Now, switch to the Selection tool (remember you can just hit SPACE as a fast shortcut), and confirm that you can resize, rotate and shear it just as you would expect. Double-click on the line to switch to the editing mode and you'll notice something a little out of the ordinary: whereas a double-click on a rectangle, ellipse or star will switch to the appropriate tool, double-clicking on a path switches instead to the Node tool (shown left) .

Dans ce numéro, je vais vous présenter la plus puissante des primitives de dessin d'Inkscape : les chemins. Je dis bien vous les « présenter » car les chemins peuvent être créés, utilisés et manipulés de multiples façons et nous y retournerons maintes et maintes fois au fil du temps.

Mais, ce mois-ci, nous resterons dans la simplicité et commencerons avec l'outil Ligne (MAJ+F6 ou « b »).

Sélectionnez l'outil, cliquez une fois sur le canevas, puis bouger le curseur vers une autre partie du canevas avant de double-cliquez pour terminer votre chemin.

Vous venez de créer le type de chemin le plus simple qui existe : une ligne droite. Essayez d'ajouter une couleur et une épaisseur à votre ligne avec le dialogue Remplissage et contour ou les outils dans la barre d'état dont nous avons parlé précédemment. Maintenant, choisissez l'outil Sélection (rappelez-vous qu'il suffit d'appuyer sur la barre d'espace comme raccourci) et assurez-vous de pouvoir le redimensionner, faire pivoter et le rogner comme vous vous y attendriez. Double-cliquez sur la ligne pour aller en mode édition et vous remarquerez quelque chose d'un peu inhabituel : alors qu'un double-clic sur un rectangle une ellipse ou une étoile vous présentera l'outil approprié, un double-clic sur un chemin vous présente à la place l'outil des Nœuds (à droite).

Utilisation Line Tool

You'll become familiar with the Node tool soon enough, but, for now, just select the Line tool again. This time, click in several places on the canvas before finishing off with a double-click. You've just created a path with multiple line segments. The chances are that you've got an 'open' path – one in which the two ends are separate. If you draw another multi-segment path, but double-click back at your starting point, you'll create a 'closed' path. The difference between them becomes apparent when you add a fill – and it should remind you of the effect we got when creating arcs back at the start of this series. As you can see, if you apply a fill to an open path it will be drawn as though there's a straight line that closes the path. That can sometimes be a handy feature, however it works only when there's a single break in the path – as soon as you introduce another (we'll see how to do that next month), the fill disappears entirely.

Node Tool

Let's return to the Node tool by double-clicking on one of the paths, or by pressing the F2 or “n” keys. The double-click will switch tools and select your path; if you opted for the keyboard shortcut, you might have to click on your path to ensure it's selected. You should see a small diamond-shaped handle marking each transition between line segments. These are called 'nodes' and, as you might imagine, the Node tool is what we'll use to manipulate them. Try dragging one of the nodes around with the mouse. Now hold down SHIFT as you click on several nodes to select them – they are colored yellow when they're selected – and drag all of them around as one. Do you want to move the nodes at either end of a segment? Simply click on the line that joins them. Hold down SHIFT as you do so to add both nodes to an existing selection. You can also press “!” (SHIFT-1 on my keyboard) to invert the selection, which can be especially useful when dealing with very complex paths. Finally, try dragging a 'rubber band' selection box over some of your nodes by clicking on the canvas and, keeping the mouse button pressed, dragging out a rectangle that covers some of your nodes. Release the mouse button and the nodes within the box will be selected (or added to your selection, if you also held SHIFT). Of course there's more that you can do with nodes than just move them around. Select a few then enable the 'Show Transformation Handles' button (shown left) on the tool control bar. You'll see the familiar move/resize handles around your nodes; clicking on one of the selected nodes will switch to the rotate/skew handles instead. These operate in the same way as the handles you get with the Selection tool, but the transformations are applied to the selected nodes rather than the whole object.

More on node tool

Think back to the previous article when you were editing gradients directly on the canvas. Adding a new gradient stop was as simple as double-clicking on the line where you wanted it to appear. Adding a new node to a path is similar: just double-click on the path. If you want it exactly halfway along a segment, then select the nodes at either end (remember, a click on the segment itself will do that), and press the INSERT key or click on the button on the tool control bar. The new node will automatically be added to your selection, so you can repeatedly press INSERT or click the button, shown left, to add several nodes to a line segment. Let's get a little more curvy. Click and drag the middle of one of your line segments to quickly turn it into a 'Bézier curve'. The nodes at each end of your curve should have circular handles attached to them via thin lines. Rough curves can just be dragged out from straight line segments, but you can fine tune them by moving these circular handles around. If you decide that you want to change your Bézier curve back into a straight line, you first need to select the end nodes, then press SHIFT-L or use the button on the tool control bar (shown left). There's an adjacent button (or SHIFT-U) for converting a straight line to a curve, but most of the time it's more useful to just drag the line segment to get the approximate shape you want, then fine tune it with the Bézier handles.

Node types

The little diamond-shaped nodes that we've played with so far are just one of four types of nodes that can be used in paths. These nodes allow the path segments on either side to extend in any direction, allowing you to create corners in your paths. Sometimes, however, sharp corners are the last thing you want, so, for those occasions, there are three other node types: smooth, symmetric and auto-smooth. You can cycle through the various node types by CTRL-clicking on a node, or you can directly change to the type you want by selecting the node(s) and then using the buttons on the tool control bar: Here's a quick summary of the four node types: Corner – Allows the line segments to meet at an angle Smooth – Ensures that the gradient remains constant from one segment to the next Symmetric – Like Smooth, but also ensures that the two handles are the same length Auto-smooth – Moving this node, or its neighbours, will keep the line smooth. If you adjust the handles on this node, however, it will revert to a simple Smooth node. Of course the best way to understand the differences between these four types is to simply draw a line with a handful of nodes and play around with them.

Manipulating paths

Drawing a series of segments from scratch using the Line tool is just one way to create a path, but Inkscape has several others. One of the most common approaches is to convert another object into a path. This lets you easily transform a rectangle, ellipse or polygon into a path whose nodes can be moved and modified freely. The downside to this freedom is that the object loses its original identity – you won't be able to use the Rectangle tool to change the corner radius once its been converted into a path, or the Star tool to adjust the number of sides to your polygon. You also won't be able to convert your path back to the original object type, even if you haven't made any changes to the nodes: conversion is a strictly one-way affair. With those warnings in mind, let's draw some objects and convert them to paths. To start with, you just need to create a few shapes, following the instructions in the earlier instalments of this series. An ellipse, rectangle, rounded rectangle, and a star, for example. Then select each object and use the Path > Object to Path command at the top of the menu (or CTRL-SHIFT-C if you prefer). Double-click on each path so that you can see where Inkscape has created corner nodes, and where it's created smooth nodes. Try manipulating these paths: move some nodes, change them from corner to smooth and back, drag the line segments, and adjust the Bézier handles. Add some nodes with a double-click or by selecting a segment and pressing INSERT. Of course you can also delete nodes by selecting them and pressing DELETE (or clicking the button, shown left, in the tool control bar), but there's a bit of a catch to that: Inkscape will try to preserve the original shape of the path as best it can, even though there are now fewer nodes. If you want it to just delete the node without trying to preserve the shape then you need to press CTRL-DELETE. The difference becomes clear when you want to just remove one corner from a rectangle:

En cas de problèmes

If you go too far with your node editing (or with anything else in Inkscape), you can always use the Edit > Undo menu (CTRL-Z) to roll back your changes. Inkscape maintains a history of all the edits you make in a session, so you can Undo repeatedly if you want to. Take a look at Edit > Undo History if you really want to travel back in time. On the whole, Inkscape is a fairly stable program, but it will occasionally crash. In my experience, this happens most when you're editing paths, and usually when you try to use the Undo facility. Fortunately, it also does a pretty good job of saving your work to a backup file if it can. If Inkscape presents you with a dialog to tell you that it's crashed then usually that will show the path and name of the backup file. Generally, the file is in the same directory as your drawing – or in your home directory if you haven't saved your drawing yet – and will have a name that's based on your file's name but with a numeric date and time string appended to it. Usually you can just open the backup file, save it with a different name, and carry on working as though nothing had happened. As with all computer files, however, it pays to backup regularly – I usually start each of my Inkscape sessions by using File > Save As… to create a copy of my image with a slightly different name so that I can never lose too much work to an Inkscape crash. Now that you can convert Inkscape's shapes into paths it's time to make your snowman look a little less pristine. Convert his elliptical head and body, then add a few nodes and move them slightly to produce the lumps, bumps and asymmetry of a typical snowman. You can also add a bit more character to his carrot nose by drawing cuts and marks and by making it a little wonky in parts. The horizon benefits from a little waviness to imply drifting snow. Although you could create more twiggy arms and crush his hat, I'm going to leave those alone for now and deal with them next month when I'll cover some methods for creating and manipulating complex paths quickly and easily.

issue66/tutoriel_-_inkscape.1354103041.txt.gz · Dernière modification : 2012/11/28 12:44 de auntiee