Outils pour utilisateurs

Outils du site


issue98:inkscape

One common requirement when creating vector drawings is to align objects relative to one another. You might want a circle that's centered within a square, or a triangle that touches the top of the page. A related requirement is to distribute several objects evenly, with identical gaps between each of them. These types of arrangements are made easy with Inkscape's Align and Distribute dialog. This dialog can be opened via the Object menu, the icon to the right of the main “Commands” toolbar, or by pressing CTRL-SHIFT-A. The screenshot was taken from version 0.91 and has a few minor differences to the 0.48 version that's still in many distributions' repositories: the buttons I've outlined in red are new to 0.91, and a few of the other icons have moved to new positions. For this article, I'll be concentrating on the Align section at the top of the dialog, which hasn't significantly changed between versions. Let's start with an extremely simple alignment task: to center a circle in the middle of a page. Start by drawing a circle anywhere in the workspace – it doesn't even have to be inside the page. Now, with the circle selected, open the Align and Distribute dialog and select “Page” from the “Relative to” pop-up menu. There's no option to center both horizontally and vertically at once, so you have to click the “Center on vertical axis” button first, followed by the “Center on horizontal axis” button afterwards (or vice versa, if you prefer). These buttons can be found, one above the other, in the two rows of icons within the “Align” section of the dialog.

Dans la création de dessins vectoriels, une exigence typique est l'alignement des objets l'un par rapport à l'autre. Vous pouvez vouloir qu'un cercle soit centré dans un carré, ou qu'un triangle touche le haut de la page. Un autre besoin du même genre est de distribuer plusieurs objets régulièrement, avec les mêmes écarts. Ces types d'arrangements se font facilement avec la boîte de dialogue Aligner et distribuer.

Cette boîte de dialogue peut être ouverte par le menu Objet, l'icône sur la droite de la barre de commandes principale ou en appuyant sur Maj-Ctrl-A. La copie d'écran a été prise dans la version 0.91 et elle a des écarts mineurs avec la version 0.48 qui est toujours dans les dépôts de nombreuses distributions : les boutons que j'ai encadrés en rouge sont nouveaux dans la 0.91, et quelques autres icônes ont été déplacées. Pour cet article, je vais me concentrer sur la section Aligner qui n'a pas subi de changements significatifs entre les versions.

Commençons par une tache d'alignement extrêmement simple : centrer un cercle au milieu d'une page. Commencez par dessiner un cercle n'importe où dans l'espace de travail - il peut même se trouver à l'extérieur de la page. Le cercle étant sélectionné, ouvrez la boîte de dialogue Aligner et distribuer et sélectionnez « Page » dans la liste déroulante « Relativement à ». Il n' y a pas d'option pour centrer horizontalement et verticalement d'un seul coup ; aussi, vous devez cliquer d'abord sur « Centrer selon un axe vertical », suivi d'un clic sur « Centrer selon un axe horizontal » (ou l'inverse, si vous préférez). Ces deux boutons, l'un au-dessus de l'autre, se trouvent dans les deux lignes d'icônes de la section « Aligner » du dialogue.

That was pretty straightforward, right? Now create three or four circles of different sizes, each with a stroke but no fill. Select them all and repeat the previous steps. If all went well you should now have a series of concentric circles all centered on the page. This example image shows the “before” and “after” arrangement of some circles that were centered in this way: It's important to understand that you can align more than one object at the same time. Usually this reduces the number of steps you need to perform, but sometimes it can be confusing when an inadvertently selected object disappears behind a larger shape that you're trying to align. When dealing with multiple objects, you sometimes want to center the whole arrangement, whilst keeping the individual elements in the same relative positions. One approach is to group them all first: the buttons in the dialog will align the group, but won't descend into it to affect the individual elements. The same effect can be achieved by enabling the “Treat selection as group” checkbox in the dialog before you click on the alignment buttons, saving you the trouble of grouping and then un-grouping your objects (see illustration on following page, top left). With “Treat selection as group” unchecked, let's take a look at some other possibilities. On either side of the two centering buttons you'll find buttons for aligning the top, bottom, left or right edges of your objects. In practice, this refers to the edge of the bounding box for the objects – either the visual or the geometric bounding box, depending on how your Inkscape preferences are set. Most of the time this distinction isn't important, but it can drastically alter the results when a filter is applied to your objects and the visual bounding box is in use.

C'était plutôt simple, n'est-ce pas ? Maintenant créez trois ou quatre cercles de différentes tailles, chacun avec un contour, mais sans remplissage. Sélectionnez-les tous et répétez les étapes précédentes. Si tout s'est bien passé, vous devriez avoir une série de cercles concentriques au centre de la page. Cette image exemple montre les arrangements « avant » et « après » de quelques cercles qui ont été centrés de cette façon :

Il est important de comprendre que vous pouvez aligner plus d'un objet à la fois. Habituellement, ça réduit les nombre d'étapes que vous devez réaliser, mais, parfois, ça peut être perturbant quand un objet sélectionné disparaît par inadvertance derrière une forme plus grande que vous essayez d'aligner. Quand vous traitez plusieurs objets, vous voulez parfois centrer un arrangement entier, tout en gardant les éléments individuels dans leurs positions relatives. Une approche est de les grouper d'abord : les boutons de la boîte de dialogue aligneront le groupe, mais n'affecteront pas les éléments individuels. Le même résultat peut être obtenu en cochant « Manipuler la sélection comme un groupe » dans la boîte de dialogue avant d'appuyer sur les boutons d'alignement, évitant ainsi la nécessité de grouper puis dégrouper vos objets (voir l'illustration sur la page suivante, en haut à gauche).

Avec « Manipuler la sélection comme un groupe : » décoché, regardons d'autres possibilités. Sur chaque côté des deux boutons de centrage, vous trouverez les boutons pour un alignement sur le haut, le bas, la gauche ou la droite de vos objets. En pratique, la référence est le côté de la boîte englobante des objets, qui peut être soit visuelle, soit géométrique, suivant les préférences d'Inkscape que vous avez choisies. La plupart du temps, cette distinction est sans importance, mais cela peut altérer fortement les résultats quand un filtre est appliqué aux objets alors que la boîte englobante visuelle est active.

So far, we've only aligned things relative to the page. Using the pop-up menu you can select various other options. For now we'll look at “Drawing” and “Selection Area” (just “Selection” in 0.48). “Drawing” refers to an imaginary bounding box that encompasses everything you've drawn in your image, whether it's inside or outside the page boundary. It stretches from the left edge of the leftmost object in your drawing to the right edge of the rightmost object, and the equivalent in height. “Selection”, on the other hand, just refers to the bounding box that encompasses all of the currently selected objects. In this example, I've created a few objects and selected all of them except for the purple star. Notice the difference as I use the “Align left edges” button, first with the page, then the drawing and finally the selection. As well as aligning to the page, drawing or selection bounding boxes, objects can also be aligned relative to one another. To do this you need to select at least two objects: one of them will remain anchored in its original position, and all the other objects will be aligned to it. Inkscape offers four options for choosing which of the objects will be anchored: the first object you selected, the last one, the biggest object or the smallest.

Jusqu'à présent, nous n'avons aligné les objets que par rapport à la page. En utilisant la liste déroulante, vous pouvez sélectionner d'autres options. Maintenant, nous allons regarder « Dessin » et « Zone de sélection » (nommé juste « Sélection » dans la 0.48). « Dessin » fait référence à la boîte englobante imaginaire qui embrasse tout ce que vous avez mis dans votre image, que ce soit dans ou en dehors des limites de la page. Elle s'étend du bord gauche de l'objet le plus à gauche de votre dessin au bord droit de l'objet le plus à droite, et l'équivalent en hauteur. « Sélection », à contrario, se réfère uniquement à la boîte englobante qui contient tous les objets déjà sélectionnés.

Dans cet exemple, j'ai créé quelques objets et je les ai tous sélectionnés à l'exception de l'étoile violette. Notez la différence quand j'utilise le bouton Aligner les bords gauches, d'abord avec la page, ensuite le dessin et enfin la sélection.

De même qu'on peut aligner les boîtes englobantes sur la page, le dessin ou la sélection, il est possible d'aligner les objets les uns par rapport aux autres. Pour réaliser ceci, nous devons sélectionner au moins deux objets : l'un d'eux restera ancré dans sa position d'origine, tandis que tous les autres s'aligneront sur lui. Inkscape offre quatre options pour choisir l'objet ancré : le premier objet que vous avez sélectionné, le dernier, le plus gros ou le plus petit.

Of these choices I recommend using only First Selected and Last Selected. They make it easy to determine what's going to move, and what isn't. When trying to align objects, you've usually got a good idea of the outcome you're trying to achieve, so being able to specify exactly which object is used as the anchor for alignment is more useful than some unclear definition of “bigger” or “smaller”. For example, suppose you have a rectangle that you duplicate and rotate through 90°. Which of the two is “bigger” and will be used as the anchor? They're both exactly the same area, but one is wider and the other is taller. The answer depends on what type of alignment you choose: the buttons on the top row, which move the objects horizontally, consider the object with the largest width to be the “biggest”; the buttons on the second row, which move the objects vertically, consider the tallest object to be the “biggest”. In this example the red rectangle is a rotated copy of the yellow one, and the alignment mode was set to “Biggest object” before each of the centering buttons was pressed.

Parmi ces choix, je recommande de n'utiliser que Premier sélectionné et Dernier sélectionné. Ainsi, c'est facile de déterminer ce qui va bouger, ou pas. En essayant d'aligner des objets, vous avez en général déjà une bonne idée de ce que vous voulez obtenir ; aussi, être capable de spécifier exactement l'objet servant d'ancre est plus utile que la définition imprécise « plus grand » ou « plus petit ».

Par exemple, supposez que vous avez un rectangle que vous dupliquez et tournez de 90°. Lequel des deux sera « plus grand » et sera utilisé comme ancre ? Ils ont tous les deux la même aire, mais l'un est plus large et l'autre plus haut. La réponse dépend du type d'alignement que vous choisissez : les boutons de la rangée du haut qui déplacent les objets horizontalement, considèrent que l'objet avec la plus grande largeur est le plus grand ; les boutons de la seconde rangée, qui déplacent les objets verticalement, considèrent l'objet le plus haut comme le plus grand. Dans cet exemple, le rectangle rouge est une copie tournée du jaune et le mode d'alignement se faisait sur « l'objet le plus grand » avant d'appuyer sur chacun des boutons de centrage.

Clearly the use of “Biggest object” and “Smallest object” can cause problems and confusion if multiple objects are the same size, but it can also be misleading when an optical illusion leads you to think that (for example) a dark object is bigger than a similarly sized light object. There's a similar problem when selecting multiple objects at once, then using “First selected” or “Last selected” (Inkscape bases its choice of anchor on the z-index of the items in that case), leading to my rules for aligning objects relative to each other: • Use “First selected”. • De-select everything (click in the work area, away from any objects – or use Edit > Deselect). • Select the object you want to align to (the anchor). • Hold shift and drag a rectangle over the objects you want to align. • Add or remove individual objects from the selection by holding SHIFT as you click on them. • Click on one alignment button from the top row and/or one alignment button from the second row to move the objects into place.

Il est clair que l'utilisation de l'« Objet le plus grand » et de l'« Objet le plus petit » peut induire des problèmes et de la confusion si plusieurs objets ont la même taille, mais il peut aussi être trompeur quand des illusions d'optique vous font penser (par exemple) qu'un objet foncé est plus gros qu'un objet de même taille, mais plus clair. Il y a un problème similaire quand vous sélectionnez plusieurs objets d'un coup, puis utilisez « Le premier sélectionné » ou « Le dernier sélectionné » (dans ce cas Inkscape base son choix d'ancrage sur l'index-z des objets), ce qui nous amène à mes règles pour l'alignement des objets les uns par rapport aux autres : • utilisez « Le premier sélectionné » ; • désélectionnez tout (cliquez dans la zone de travail, loin de tout objet, ou utilisez Éditer > Désélectionner) ; • sélectionnez l'objet sur lequel vous voulez faire l'alignement (l'ancre) ; • maintenez la touche Maj et étirez un rectangle sur les objets que vous voulez aligner ; • ajoutez ou enlevez des objets individuels de la sélection en appuyant sur la touche Maj tout en cliquant sur ces objets ; • cliquez sur le bouton d'alignement de votre choix, sur l'une des deux lignes de boutons, pour mettre en place les objets.

With that approach you'll always be in control of which objects are moved, and where they move to. The only variation that I ever use is when the objects I want to move are already selected – especially if it's a complex selection. In that case it's worth using “Last selected” and just holding SHIFT whilst clicking on the anchor object to add it to the selection. If the anchor is already selected, you can SHIFT-click to de-select it, then do the same again to re-select it, thus making it the last selected object. When using First/Last/ Biggest/Smallest you should note that the behaviour of the “Treat selection as group” checkbox changes somewhat – often in a counter-intuitive way. In these modes, the anchor object has to be part of the group, so you might expect it to move along with everything else in order to maintain the relative positions of objects (as we saw when using the Page/Drawing/Selection modes). What actually happens, however, is that the anchor object remains stationary and all the other selected objects move as though they're grouped. In other words it becomes a “treat selection as group, except for the anchor object” checkbox. Furthermore, the effect of this checkbox changes depending on the layout of your objects. In this example, I've drawn three red stars and one green circle, arranged per the top image. Using “First selected” mode I click on the circle, then hold SHIFT and drag a rectangle over the stars. Ensuring that “Treat selection as group” is checked, a click on the “Center on vertical axis” button should move the stars, keeping the circle in place. Logic might suggest that I'll end up with the second image, but actually what I get is the third one. What's going on?

Avec cette approche, vous gardez en permanence le contrôle sur les objets à déplacer et sur leur déplacement. La seule variante que j'utilise, parfois, est quand les objets à déplacer sont déjà sélectionnés - particulièrement quand c'est une sélection compliquée. Dans ce cas, il vaut mieux utiliser « Le dernier sélectionné » et appuyer sur MAJ tout en cliquant sur l'objet d'ancrage pour l'ajouter à la sélection. Si l'ancre est déjà sélectionnée, vous pouvez, tout en appuyant sur Maj, cliquer une fois pour le désélectionner puis une deuxième fois pour le re-sélectionner ; il devient ainsi le dernier objet sélectionné.

Notez que, quand vous utilisez Le plus grand/le plus petit/le premier/le dernier, le comportement de la case à cocher « Traiter la sélection comme un groupe » change quelque peu, souvent à l'inverse de ce qu'on prévoit. Dans ces modes, l'objet d'ancrage doit faire partie du groupe et vous pourriez vous attendre à ce qu'il bouge avec tous les autres de façon à respecter la disposition relative des objets (comme nous l'avons vu avec les modes Page/Dessin/Sélection). Cependant, ce qui se passe en réalité, c'est que l'objet d'ancrage reste immobile et tous les autres objets bougent comme s'ils étaient groupés. En d'autres termes, la case à cocher devient « Traiter la sélection comme un groupe, sauf pour l'objet d'ancrage ».

De plus, l'effet de cette case à cocher change suivant la disposition de vos objets. Dans cet exemple, j'ai dessiné trois étoiles rouge et un cercle vert, dans la disposition de l'image du haut. En utilisant le mode « Le premier sélectionné », j'ai cliqué sur le cercle, puis, en appuyant sur la touche Maj, j'ai étiré un rectangle sur les étoiles. En m'assurant que la case « Traiter la sélection comme un groupe » soit bien cochée, un clic sur le bouton « Centrer selon un axe vertical » devrait déplacer les étoiles, tout en maintenant le cercle en place. La logique suggérerait que j'obtienne la deuxième image, mais, en fait, c'est la troisième image que j'ai eu. Qu'est-ce qui se passe ?

It's our old friend the bounding box at play once more. Consider the bounding box of the first image – it's the total width of the stars plus the circle. When centering the selection, it's this bounding box that's used for the calculation, even though the circle won't be moved with the other objects. The result is that the stars are moved so that the center of the original bounding box is centered with the circle, even though doing so results in a smaller bounding box afterwards. There are two solutions to this dilemma: the most obvious is to group the stars then align the group to the circle with the “Treat selection as group” checkbox un-ticked. This turns a complex arrangement of four objects into a simpler problem involving just two – the circle and the group. It's the approach I used to produce the second image in the example. The other alternative is to click the “Center on vertical axis” button a second time: after the first press, the new bounding box is only as wide as the stars, so aligning again (with the checkbox enabled) results in the expected behaviour. With everything you've read so far, you should be able to understand the behaviour of most of the alignment buttons in the dialog, but there are two that defy the rules: the last button on each row is purely used to align text objects.

Encore une fois, c'est un tour de notre vielle amie la boîte englobante ! Regardez la boîte englobante dans la première image - c'est la totalité des étoiles plus le cercle. Quand vous centrez la sélection, c'est la boîte englobante qui est utilisée dans les calculs, même si le cercle ne doit pas bouger avec les autres objets. Comme résultat, les étoiles sont déplacées de telle sorte que le centre de la boîte englobante d'origine soit centré sur le cercle, même si, en faisant ça, la boîte englobante finale est plus petite.

Il y a deux solutions à ce dilemme : le plus évident est de grouper les étoiles puis d'aligner le groupe sur le cercle en décochant « Traiter la sélection comme un groupe ». Ceci transforme un arrangement complexe de 4 objets dans un problème plus simple à deux objets - le cercle et le groupe. C'est l'approche que j'ai utilisée pour la deuxième image de l'exemple. L'autre alternative consiste à cliquer sur le bouton « Centrer selon l'axe vertical » une deuxième fois : après le premier appui, la nouvelle boîte englobante a la taille des seules étoiles ; ainsi, le nouvel alignement (avec la case cochée) donnera le résultat escompté.

Avec tout ce que vous avez lu jusqu'ici, vous devriez être capable de comprendre le comportement de la plupart des boutons d'alignement de la boîte de dialogue, mais il y en a deux qui défient les règles : le dernier bouton de chaque ligne n'existe que pour aligner des objets texte.

These buttons align text objects to the vertical or horizontal baseline of other text objects. They ignore any non-text objects in the selection, pay no attention to the state of the “Treat as group” checkbox, and don't even honour the “Relative to” pop-up. If you're using Inkscape for some simple desktop publishing work – perhaps creating a poster or flyer – then they can be used to ensure that different sections of text adhere to the same baseline (the line that runs under the text, ignoring any descenders such as the tail on a “y”). This can give a more professional appearance. An alternative approach is to drag out a guide from the ruler (see part 16), enable snapping, and activate the “Snap text anchors and baselines” option. Regardless of your method, if you use multi-line text, then it's only the baseline of the first line that is snapped or aligned to, preventing completely separate pieces of text from easily sharing the same “baseline grid” as you might in a proper DTP program such as Scribus. Perhaps the most important thing to remember about aligning in Inkscape is that, however you align your objects, if you end up with an alignment you're not happy with, simply press CTRL-Z or use Edit > Undo to reverse the action. There's logic to alignment in Inkscape – even if that logic doesn't always produce the outcome you might initially expect.

Ces deux boutons alignent des objets texte suivant la ligne de référence horizontale ou verticale d'autres objets texte. Ils ignorent tout objet non-texte de la sélection, ignorent la case à cocher « Traiter la sélection comme un groupe » et ne s'intéressent pas à la liste déroulante « Relativement à ». Si vous utilisez Inkscape pour un travail d'édition simple - peut-être pour créer une affiche ou un flyer -, dans ce cas, ils peuvent être utilisés pour s'assurer que les différentes parties de texte sont alignées sur la même référence (la ligne sous le texte, en ignorant les caractères qui dépasseraient dessous, comme le « y »). Ceci peut donner une apparence plus professionnelle. Une approche alternative est de tirer un guide depuis la règle (voir la partie 16), d'autoriser l'aimantation et d'activer l'option « Aimanter les ancres de texte et les lignes de références ». Quelle que soit votre méthode, si votre texte est multi-ligne, alors il n'y a que la ligne de référence de la première ligne qui est aimantée ou qui s'aligne, empêchant des pièces de texte complètement séparées de partager facilement la même « grille de référence » comme vous pourriez le faire dans un programme de PAO (Publication assisté par ordinateur - DTP, desktop publishing, en anglais) tel que Scribus.

La chose peut-être la plus importante à retenir a propos des alignements dans Inkscape : pour ce qui concerne les alignements d'objets, si vous n'êtes pas content du résultat obtenu, vous faites Ctrl-Z ou Éditer > Annuler pour retourner à la situation précédente. Il y a une logique dans les alignements d'Inkscape - même si cette logique ne produit pas toujours le résultat auquel on s'attendait par avance.

issue98/inkscape.txt · Dernière modification : 2015/07/04 14:54 de andre_domenech