Outils pour utilisateurs

Outils du site


issue88:inkscape

Ceci est une ancienne révision du document !


In this article, I'm going to start looking at clones in Inkscape. Clones can easily be dismissed as a minor feature, but, with a few tricks, you can use them to perform marvellous feats that make them worthy of several articles just to cover the basics. At the simplest level, a clone is nothing more than a duplicate of an Inkscape object that maintains a link to the original. Changes to the original are automatically propagated to the clone, making them ideal when you need several identical objects in an image. Creating a clone is as simple as selecting the object and using the Edit > Clone > Create Clone menu entry, or just pressing the Alt-D keyboard shortcut. The new clone will be created directly on top of the original object, and will be selected automatically so that you can immediately move it to somewhere else.

Dans cet article, je vais commencer à regarder les clones dans Inkscape. Les clones peuvent être délaissés parce que fonctionnalités mineures, mais, avec quelques astuces, vous pouvez les utiliser pour donner vie à de merveilleuses fonctionnalités qui mériteraient plusieurs articles juste pour couvrir les bases.

Au niveau le plus simple, un clone n'est rien d'autre qu'une copie d'un objet Inkscape, avec lequel un lien est maintenu. les changements sur l'original sont automatiquement propagés au clone, les rendant idéal quand votre image contient plusieurs fois le même objet. Créer un clone est aussi simple que de sélectionner l'objet et d'utiliser l'entrée de menu Éditer > Clone > Créer un clone ou par le raccourci clavier Alt-D. Le nouveau clone sera créé juste au dessus de l'objet original et il sera automatiquement sélectionné, si bien que vous pouvez tout de suite le déplacer ailleurs.

With a clone selected, the Edit > Clone > Select Original menu item (or Shift-D shortcut) will select the original object with which the clone is linked – its “parent” if you like. This now gives us a collection of related keyboard shortcuts that are well worth memorising to speed up your work with Inkscape: Ctrl-X - Cut to clipboard Ctrl-C - Copy to clipboard Ctrl-V - Paste from clipboard (at the mouse position) Ctrl-Alt-V - Paste In Place (at the object's position) Ctrl-D - Duplicate (copy then paste in place) Alt-D - Clone (a linked duplicate) Shift-D - Select Original Initially the Paste In Place option seems a little redundant, given that the Duplicate command appears to achieve the same result. The difference is that Paste In Place also works between layers, and even between Inkscape documents, so you can copy or cut from one drawing's layer, then paste into the same location in a different layer or a different drawing.

Le clone étant sélectionné, l'entrée de menu Editer > Clone > Sélectioner l'original (ou le raccourci Maj-D) sélectionnera l'objet original auquel le clone est relié - son « parent » si vous préférez. Voici maintenant une collection de raccourcis clavier en rapport avec les clones qui vaut la peine d'être mémorisée pour accélérer votre travail dans Inkscape :

Ctrl-X - Cut to clipboard Ctrl-C - Copy to clipboard Ctrl-V - Paste from clipboard (at the mouse position) Ctrl-Alt-V - Paste In Place (at the object's position) Ctrl-D - Duplicate (copy then paste in place) Alt-D - Clone (a linked duplicate) Shift-D - Select Original

A première vue, l'option Coller sur place à vérifier semble un peu redondante, étant donné que la commande Dupliquer semble obtenir le même résultat. La différence, c'est que Coller sur place travaille aussi entre couches et même entre documents Inkscape ; ainsi, vous pouvez copier ou couper depuis une couche d'un dessin et coller à la m^me place sur une autre couche ou sur un autre dessin.

So much for the theory, let's create a duplicate and a clone and see the difference between them. For notational purposes, I'm going to use a solid arrow pointing from the parent object to the duplicate, and a dashed arrow pointing from the parent object to the clone. With this notation the “Select Original” command always follows back from the tip of a dashed arrow to its source. Here's a simple parent object with a single duplicate and a single clone. As you might expect, all three objects look the same. The difference only becomes apparent when the parent object is modified in some way – such as changing it's fill and stroke, or altering the roundedness of the corners.

C'est assez pour les explications, créons une copie et un clone puis voyons les différences entre eux. Pour les distinguer, je prend la convention d'utiliser un flèche entrait plein pour pointer du parent à la copie, et une flèche en pointillé allant du parent au clone. Avec cette convention, la commande “Sélectionner l'original” suit toujours du bout de la flèche pointillée à sa source. Ici, il y a un seul objet parent avec une seule copie et un seul clone.

Comme vous pouvez vous y attendre, c'est trois objets se ressemblent. La différence ne devient apparente que quand le parent est modifié de quelque façon - tel que changer ses traits ou son remplissage ou modifier l'arrondi des angles.

Our duplicated object, which maintains no link to the parent, remains unaffected. The clone, however, is immediately updated to reflect the changes to its parent object. That makes it useful for creating absolutely identical objects – hence the term “clones” – but, as in real life, it's possible for Inkscape's clones to develop slight differences to their parents. A clone, as well as maintaining a link to its parent, is also an object in its own right, and is subject to the same transformations as any other object. Clones can be rotated, scaled and skewed, have their opacity reduced, or have filters applied, independently of the parent. With some rotation, scaling and opacity changes applied to the clone, our previous image looks like this. It's important to note that these changes are applied after the clone has been synchronised with its parent – you can think of them as being added on to the base attributes of the parent. So the clone's fill and stroke colors will still change if the parent's are modified, and any rotation, blur and opacity changes to the parent have a cumulative effect with those that are applied to the clone. For example, this clone has a 45° rotation applied; if I were to rotate the parent by 15° then the clone would also rotate by an additional 15° bringing its total rotation to 60° compared to its original position.

Notre objet dupliqué, qui n'a plus de lien avec le parent, reste inchangé. A l'inverse, le clone est immédiatement modifié pour reproduire les changements de son objet parent. C'est très utile pour créer des objets parfaitement identiques - d'où le terme de clone - mais comme dans la vraie vie, il est possible pour les clones d'Inkscape de développer quelques légères différences par rapport à leurs parents. Un clone, tout en maintenant un lien avec son parent, est aussi un objet de plein droit, sujet aux mêmes transformations que tout autre objet. Les clones peuvent être tournés, changés d'échelle et penchés, être moins opaques ou subir du filtrage, indépendamment du parent. Avec quelques rotation, mise à l'échelle et changement d'opacité appliquée au clone, notre image précédente ressemble à ça.

C'est important de noter que ces changements ont été réalisés après que le clone ait été synchronisé avec son parent - considérez qu'ils ont été ajoutés aux attributs de base du parent. Ainsi, les couleurs de trait et de remplissage du clone continueront à changer si celles du parent changent et tout changement dans la rotation, le flou ou l'opacité du parent auront un effet cumulatif sur les valeurs déjà appliquées au clone. Par exemple, ce clone était tourné de 45° ; si j'appliquais une rotation de de 15° sur le parent alors le clone tournerait de 15° supplémentaire portant sa rotation totale à 60°, à comparer avec sa position d'origine.

One simple but effective use of this feature is to create drop shadows by blurring a clone and reducing its opacity. This is especially beneficial when dealing with text objects as the shadow will automatically adjust to any edits you may make to the text content. If a clone is just another type of object, then surely it must be possible to copy and paste it. If that's possible, then what about duplicating it, or even cloning it? The simple answer is that you can do all these things with clones, but the results might not always be what you expect. You can create long chains of relationships – clones of clones of clones… of clones of objects – but the cumulative nature of any applied transformations can result in a small tweak to one item having a knock-on effect all the way down the chain. To keep things simple, I'll just look at a basic three object chain where a grandparent is duplicated or cloned to form a parent which is, in turn, duplicated or cloned to create a child. I've drawn all the possible combinations, and given each object or clone a number so that it's easier to track what's happening. Starting with the basic arrangement of objects, as with the earlier two-object example, all the elements look the same, whether they've been duplicated or cloned.

Une utilisation simple mais efficace de cette fonctionnalité est la création d'une ombre portée en floutant le clone et en réduisant son opacité. C'est particulièrement bénéfique en traitant des objets textes car l'ombre se met à jour automatiquement à chaque modification du texte.

Si un clone est simplement un autre objet, alors il est sûrement possible de le copier et de le coller. Si c'est possible, alors pourquoi pas le dupliquer ou même le cloner ? Une réponse simple est que vous pouvez faire tout cela avec des clones mais que le résultat ne sera pas toujours ce que vous attendiez. Vous pouvez créer de longues chaines relationnelles - clones de clones de clones … de clones d'objets - mais du fait de la nature cumulative de chaque transformation réalisée, une petite déformation sur un élément peut apparaître, avec des répercutions sur toute la chaine.

Pour rester simple, je vais juste considérer une chaine de 3 objets où un grand-parent est dupliqué ou cloné pour obtenir un parent qui, à son tour, est dupliqué ou cloné pour créer un enfant. J'ai dessiné toutes les combinaisons possibles et affecté un nombre à chaque objet ou clone, ce qui facilitera le suivi des opérations. On commence avec le même arrangement de base des objets que dans l'exemple précédent avec deux objets ; tous les objets se ressemblent qu'ils aient été dupliqués ou clonés.

(1) is the starting point, our grandparent object. This is duplicated to create (2), and cloned to create (3). Each of those objects is duplicated and cloned to produce the remaining items. The provenance of each object is therefore: (1) The original grandparent object. (2) A duplicate of (1). Parent to (4) and (5) (3) A clone of (1). Parent to (6) and (7) (4) A dupe of a dupe of (1) (5) A clone of a dupe of (1) (6) A dupe of a clone of (1) (7) A clone of a clone of (1) What happens when we modify the attributes of (1)? As before, our duplicated object (2) remains unaffected, so (4) and (5) also appear untouched. The first-level clone (3) changes, as does its clone (7). But what about (6)? That was made as a duplicate, so you might expect it not to change, yet you can clearly see that it does. (1) est le point de départ, notre objet grand-parent. Il est dupliqué pour créer (2) et cloner pour obtenir (3). Chacun de ces objets est copié et cloné pour produire les autres éléments. La provenance de chaque objet est donc : (1) l'objet grand-parent original (2) Copie de (1). Parent de (4) et (5) (3) Clone de (1). Parent de (6) et de (7) (4) Copie de copie de (1) (5) Clone de copie de (1) (6) Copie de clone de (1) (7) Clone de clone de (1) Que se passe-t-il quand nous modifions les attributs de (1) ? Comme précédemment, notre objet dupliqué (2) ne change pas, et (4) et (5) aussi paraissent inchangés. Le clone de premier niveau (3) change, ainsi que le clone (7). Mais que se passe-t-il pour (6) ? Il a été créé par copie, donc il ne devrait pas changer, mais vous pouvez voir sans équivoque qu'il a changé. The thing to bear in mind is that (6) is an exact duplicate of (3) – even down to its linkage to the grandparent object (1), represented by the gray line on the image. You can see, therefore, that a second clone of an object can be created either by cloning the object a second time, or by duplicating an existing clone. The difference is that duplicating a clone will also duplicate any other attributes associated with it, so if you've rotated the clone or added a blur, those effects will be present on the new clone, even though it's linkage goes back to the grandparent object. Now let's look at what happens if we modify (2) and (3). For this example I've rotated them through 45°. (4) remains the same, because it has no linkage to any of the other objects. (5) rotates because it's a clone of (2). The linkage between (6) and (1) means that it's not affected by the rotation of (3) – although it would be affected if (1) were to be modified. Finally (7) does rotate because, as a clone of a clone, it's made up of the cumulative effects of all the changes made to both (1) and (3).

If that's not enough to make your head spin, I'll leave it as an exercise for the reader to consider chains of four or more objects! One good reason for using clones is that they tend to be less resource hungry than the equivalent separate objects. In terms of storage space, a clone is little more than a reference to another part of the SVG content, helping to keep the file size down. This can be particularly useful when you're dealing with complex paths, groups or embedded images. Consider this example that uses a single image and some cloning, rather than embedding three separate images. The left hand image is the parent in this case. The top right image is the result of cloning the parent, then scaling the clone before applying a clipping path. The bottom right image is the result of cloning the clipped clone and applying a second clipping path to that. The same effect could also have been achieved by clipping a second clone of the parent, but I also wanted to demonstrate that a clone of a clipped or masked object still retains the clipped appearance – note the curved sides of the bottom right image that result from the elliptical clipping path used on the top image.

Although clones can result in substantial space savings, chaining them too deeply can slow Inkscape's rendering of your image. In the case of the Mona Lisa example, it's clear that the bottom right image can't be processed until after the top one – including its clipping path – has been calculated. Extending the chain further to create clones of clones of clones just exacerbates the problem. Unless your design really does require the sort of attribute inheritance that such chains enable, you're better to create clones that link directly back to a common parent. Remember, either clone from the original parent each time (Alt-D), or clone once then duplicate the clone (Ctrl-D). If you're not sure whether you're cloning the original object or an existing clone of it, check the status bar. If it reads “Clone of Clone of Clone…” then you might want to re-think your approach.

issue88/inkscape.1421678823.txt.gz · Dernière modification : 2015/01/19 15:47 de d52fr