Outils pour utilisateurs

Outils du site


issue90:inkscape

Ceci est une ancienne révision du document !


Table des matières

1

Using clones makes it easy to create identical copies of objects or groups in your image. As we saw last time, breaking your groups down into smaller chunks to clone lets you add a little variety, and you can always draw extra objects on top of your clones to further distinguish them. But you can't make significant changes to a clone – altering the shape of a path, for example – without first converting it to a normal copy. Although you can't make significant changes to clones, they're not entirely inert either. I've already shown how they can be rotated, flipped, scaled and skewed independently of their parent objects. But there's one other little trick in the clones' arsenal which requires a bit of effort to set up, but can be well worth it for some situations: clones can change their fill and stroke separately from their parents. You can't just take any old clone and give it a new fill and stroke, though. Instead, the parent object has to have its fill and/or stroke “unset”. The quickest way to unset the fill or stroke is to right-click on the relevant swatch in the status bar at the bottom of the Inkscape window. Towards the bottom of the context menu will be an option for “Unset fill” or “Unset stroke”. Select this item and the corresponding color swatch will be replaced with the word “Unset”. You can also unset the fill or stroke using the “?” button in the relevant tab of the Fill and Stroke dialog.

L'utilisation de clones rend facile la création de copies d'objets ou de groupes dans votre image. Comme nous l'avons vu le mois dernier, nous obtenons un peu de variété en dissociant les groupes en petits morceaux à cloner et vous pouvez toujours dessiner des objets supplémentaires sur vos clones pour les distinguer. Mais vous ne pouvez pas faire de grosses modifications de votre clone - modifier le tracé de la forme, par exemple - sans le convertir d'abord en copie normale.

Bien que vous puissiez faire des modifications significatives aux clones, ce n'est cependant pas sans conséquence. J'ai déjà montré comment les tourner, les inverser, les changer d'échelle et les incliner indépendamment de leurs objets parents. Mais il y a une autre petite astuce dans l'arsenal des clones, qui demande un peu d'effort pour le paramétrer, mais qui vaut le coup dans certaines situations : les clones peuvent changer de tracé et de remplissage indépendamment de leurs parents.

Vous ne pouvez pas prendre juste un vieux clone pour lui donner un nouveau trait et/ou remplissage. A la place, le tracé ou le remplissage de l'objet parent doit avoir été “défait”. La façon la plus rapide de défaire le remplissage ou le trait est faire un clic droit sur le nuancier des couleurs dans la barre d'état en bas de la fenêtre d'Inkscape. Vers le bas du menu contextuel, vous trouvez une option « Défaire le trait » ou « Défaire le remplissage ». Sélectionnez la ligne et la couleur va être remplacée avec la mention « défait ». Vous pouvez aussi défaire le trait ou le remplissage avec le bouton « ? » dans l'onglet approprié de la boîte de dialogue Trait et remplissage.

2

Unfortunately, unsetting the fill or stroke on your object has side effects. An unset fill is rendered in black which is often bad enough, but an unset stroke doesn't render at all which can be disastrous if the object you want to clone is all stroke and no fill – making it effectively disappear from the screen! Because strokes are trickier to illustrate (an invisible object doesn't make for a great screenshot), we'll start by just considering unset fills, and come back to strokes later in the article. As a demonstration I've drawn two identical circles, then unset the fill in the bottom one. You can easily spot it because the fill has been drawn as solid black. It's important to note that “black” and “unset” are not the same thing, though, even if they appear that way on screen. Next, I've cloned each circle, then set the fill color for each clone to yellow. As you can see, the top clone ignores the fill that's been set, just like all the clones we looked at previously. The bottom clone, on the other hand, has replaced the black “unset” fill with the color that's been set on the clone itself. The yellow clone has inherited its shape, size and stroke from the parent object, but carries its own fill color. We can extend this further by creating additional clones from that one parent and giving each of them their own color.

Malheureusement, il ya des effets de bord à modifier le tracé ou le remplissage de votre objet. Un trait modifié est rendu en noir ce qui est souvent assez vilain, mais un remplissage modifié n'a aucun rendu ce qui est désastreux quand l'objet que vous voulez retoucher n'est fait que de remplissage, sans ligne - ce qui le fait disparaître de l'écran ! Parce que les remplissages sont difficiles à illustrer (un objet invisible ne donne pas une superbe copie d'écran !), nous allons commencer par le cas de tracés, nous reviendrons aux remplissages plus loin dans l'article.

A titre de démonstration, j'ai dessiné deux cercles identiques, puis j'ai modifié le tracé de l'un d'eux. Vous pouvez le voir facilement puisque le trait défait a été dessiné en noir. C'est important de noter que « noir » et « défait » ne sont pas synonymes, bien que l'affichage à l'écran puis le faire croire. Ensuite, j'ai cloné chaque cercle, puis modifié la couleur du remplissage de chaque clone en jaune. Comme vous pouvez le voir, le clone du haut ignore le remplissage modifié, comme tous les autres clones vus précédemment. A l'inverse, le clone du bas a remplacé le remplissage noir « défait“ par par la couleur que j'ai mise sur le clone.

Le clone jaune a hérité sa forme, son trait et son remplissage de l'objet parent, mais, affiche sa propre couleur. Nous pouvons étendre ceci plus avant en créant des clones supplémentaires à partir de chaque parent puis en donnant à chacun sa propre couleur.

When dealing with something as simple as a circle, there's probably no real benefit in creating clones like this compared with simply duplicating the parent and changing the fill. But the parent object is rarely as simple as a circle, and these clones can still also be rotated, flipped, scaled and skewed independently. Furthermore, the fills don't have to be simple colors: you can use patterns and linear or radial gradients, too. Admittedly the Inkscape UI struggles a little with anything other than simple colors as the gradient editing handles tend to appear out of place, and the pattern scaling handles don't appear at all – but SVG itself allows for all these possibilities. Taking our previous example, let's mix it up a little to demonstrate some of these capabilities. First I've converted the parent circle to a path, then tweaked its nodes to give a more interesting shape. Then I've squashed, skewed and rotated some of the clones, and given others different fills or transparency. They're all still clones – a change to the parent path will affect them all – but combining transformations with an unset fill lets them each take on a distinctly different appearance. In the previous article, I was extolling the virtues of cloning groups rather than single objects, so you'll be pleased to hear that you can use unset fills in cloned groups as well. Any objects within your group that have their fill unset will be given the clone's color, whereas other objects will be cloned as normal, inheriting their fill from the parent. This ability to mix normal and unset fills within the parent can be very useful if you require a few similar copies with just part of the design changing color with each clone – consider creating some characters for a crowd scene, each of which has a different colored T-shirt.

Quand on travaille avec une chose aussi simple qu'un cercle, il n'y a probablement pas d'intérêt à créer des clones comme ça plutôt que de copier le parent et de changer le remplissage. Mais un objet parent est rarement aussi simple qu'un cercle et ces clones peuvent toujours être tournés, inversés, mis à l'échelle et penchés indépendamment. De plus, les remplissages ne sont pas que des couleurs simples : vous pouvez aussi utiliser des motifs, insérer des gradients linéaires ou radiaux. Admettons que l'interface utilisateur d'Inkscape sature un peu avec autre chose que des couleurs simples, de sorte que les poignées d'édition des gradients ne sont pas à leur place ou que les poignées de mise à l'échelle du motif n'apparaît pas du tout - mais le moteur de dessin vectoriel permet toutes ces possibilités.

En reprenant notre exemple précédent, mélangeons un peu tout pour montrer quelques possibilités de l'outil. D'abord je vais convertir le cercle parent en chemin, puis tordre ses noeuds pour obtenir une forme plus intéressante. Ensuite, je vais écraser, pencher et tourner certains clones, et donner à d'autres des traits ou des remplissages transparents. CE sont encore tous des clones - un modification du chemin parent les affecte tous - mais la combinaison des transformations avec un remplissage défait donne à chacun une apparence différente.

3

In this example, I've cloned a group of five objects – four shapes inside a larger rounded square. The circle and triangle have their fills unset, whereas the star and square have them set to specific colors. You can see that in each clone the shapes with the fixed colors appear the same as the parent, but those with the fill unset use the color that's set on the clone itself. You'll notice that both the circle and the triangle take on the same color in each clone. One major limitation of this approach is that SVG considers all unset fills in a clone to be identical. There's no way to apply two colors to your clone and have one affect the circle whilst the other affects the triangle. Or is there…? If you really want to get extra colors into your clones, there are ways to do it by being underhanded and devious. One approach is to stack identical clones on top of each other, each set to a different fill color, then use clipping paths to only show the relevant parts of each clone. Another technique I've used in the past is to create a filter in the parent that “rotates” the color of one of the unset objects – more on that when we get onto filters later in this series. For this example, however, I kept it simple: I managed to use two colors in the unset objects by using a linear gradient as the fill. By creating a couple of extra stops in the gradient and setting them to the same colors as the start and end points, I created gradients like this, to allow me to fake the appearance of having two separate fill colors.

4

At the start of the article I did promise to come back to unset strokes. Whereas an unset fill is rendered in black, making it easy to see and work with, an unset fill is also rendered in black, but with a width of zero! If your object has a fill – even an unset one – it will still be visible on screen. But, if you unset the stroke of an object with no fill, it will disappear from view entirely. For this reason my first rule of working with unset strokes is to unset them as the last step. Work with a colored stroke while you're creating your parent object or group, and unset it only at the last minute. The second rule is not to panic if you do lose track of your object. Just use the View > Display Mode > Outline menu to switch to a mode where even the most invisible of Inkscape objects appears as a skeletal outline. Even in this mode you can still select and manipulate your objects, and they will remain selected when you switch back to another display mode. With an unset stroke in your parent object or group, you can now set not only the stroke color (or pattern, or gradient) on each clone, but also its width, join style, end caps and dashes. In fact, at a minimum you have to set the color and width if you want the stroke to be visible. Unfortunately, you can't set markers on a per-clone basis – if you want arrows or chevrons marking the nodes of your path, they have to be set on the parent object.

5

With unset strokes, you now have another method of getting an extra color into your clones. With a little lateral thinking, you can even usurp the stroke to provide a second fill color, if that suits your needs better. In this final example, I've used an unset fill on the left hand shape, that's clear enough. But where is the right hand shape coming from? You've probably already guessed that there's an unset stroke involved, but how does that turn into a shaped fill in the clones? The trick was to draw a single vertical line in the parent and give it a really large width value – 40px in this case – effectively creating a 40px wide rectangle. Then I used a path to clip that “rectangle” to the shape I wanted, before finally unsetting the stroke. On each clone I have to only set the stroke to the color I want, with a 40px width, and my second “filled shape” appears. You can also perform a similar trick using masks, which can be particularly useful for faking a gradient in your clones. The ability to use different fills and strokes on clones can make them extremely versatile, at the expense of leaving you with black areas or invisible lines in your parent object. Being able to set only two “parameters” on each clone can be limiting, but hopefully you've seen how, with a little lateral thinking, the use of masks, gradients, clipping and filters can let you break that restriction to some degree.

issue90/inkscape.1424108620.txt.gz · Dernière modification : 2015/02/16 18:43 de d52fr