Ceci est une ancienne révision du document !
This month, we're going to look at setting colors for our objects. So far we've applied colors to the fill and stroke of our objects by clicking and SHIFT-clicking on the palette at the bottom of the screen. You can also set either to transparent by using the leftmost palette entry – the one with a cross through it. You've probably already discovered the scroll bar that usually lives between the palette and the status bar, and which lets you scroll through the full collection of colors in the palette, but have you noticed the tiny little button to the right of the palette area – the one that looks like a small “<” character? Clicking on that presents you with a pop-up menu of palette options (far right). Most of this menu is taken up by a list of palettes you can use. Try switching between a few of them to see how they look. Then play with the Size and Width sub-menus to find a swatch size that you're comfortable with. Finally, try the Wrap checkbox to see whether you prefer to see all of your palette at once (even if it takes up more vertical space), or are happy to use the scrollbar when you need to access the more distant colors.
Ce mois-ci, nous allons nous pencher sur la colorisation de nos objets. Jusqu'ici, nous avons appliqué des couleurs à la pipette et frappé nos objets en cliquant et MAJ-clicquant sur la palette au bas de l'écran. Vous pouvez également les définir transparents à l'aide du bouton le plus à gauche de la palette (celui avec une croix en travers). Vous avez sans doute déjà remarqué la barre de défilement qui se place habituellement entre la palette et la barre d'état, et qui permet de faire défiler l'intégralité des couleurs de la palette, mais avez-vous remarqué le petit bouton à droite de la zone de la palette (celui qui ressemble à un petit caractère «<»)? Cliquer dessus vous affiche un menu déroulant des options de la palette (extrême droite).
Une grande partie de ce menu est occupé par une liste de palettes que vous pouvez utiliser. Essayez de cliquer sur quelques-unes d'entre elles pour voir à quoi elles ressemblent. Ensuite, jouez avec les sous menus de la taille et la largeur pour trouver une taille de nuancier avec laquelle vous êtes à l'aise. Enfin, essayez la case à cocher Wrap pour voir si vous préférez voir l'ensemble de votre palette en une fois (même si cela prend plus de place verticale), ou si çà vous va d'utiliser la barre de défilement lorsque vous avez besoin d'accéder à des couleurs plus éloignées.
If you want to use your own palette – perhaps to fit in with a corporate color scheme or to integrate with other icons in an application – you can drop a GIMP palette file (.gpl) into your .inkscape/palettes directory, or into /usr/share/inkscape/palettes if you want it to be available to all users on your computer. The palette is great for quickly selecting a color for your fill or stroke, but what if you want a color that's not present in the palette? That's where the Fill & Stroke dialog comes in. There are various ways to open the dialog, including the button on the Commands toolbar, selecting an object then picking 'Fill and Stroke' from the right-click context menu, pressing CTRL-SHIFT-F, or simply clicking on the current fill and stroke swatches at the bottom-left of the window. You may dock the dialog to the right-hand side of the Inkscape window, or move it into a window of its own, by dragging it using the grey title bar at the top.
Si vous souhaitez utiliser votre propre palette, peut-être pour s'adapter à un jeu de couleurs d'entreprise ou s'intégrer avec d'autres icônes dans une application, vous pouvez déposer un fichier palette GIMP (.gpl) dans votre dossier .inkscape ou dans /usr/share/inkscape/palettes si vous voulez qu'elle soit accessible à tous les utilisateurs de votre ordinateur.
La palette est géniale pour choisir rapidement une couleur pour votre fond ou vos aplats, mais que faire si vous voulez une couleur qui n'est pas présente dans la palette? C'est là qu'entre en jeu la boite de dialogue . Il y a plusieurs façons d'ouvrir la boîte de dialogue, y compris cliquer sur le bouton de la barre d'outils Commandes, activer un objet puis choisir «Remplissage et contour“
dans le menu contextuel du clic droit, appuyer sur CTRL-MAJ-F, ou tout simplement en cliquant sur le nuancier actuel en bas à gauche de la fenêtre. Vous pouvez ancrer la boîte de dialogue sur le côté droit de la fenêtre d'Inkscape, ou le déplacer dans une fenêtre qui lui est propre, en le faisant glisser à l'aide de la barre de titre grise du haut.
At the top of the dialog are three tabs for setting the Fill, the Stroke Paint, and the Stroke Style. The first two offer almost identical options, so we'll just discuss the Fill tab and you can extrapolate from there. Immediately below the tab is a row of buttons which are used to determine what type of paint is used for the fill or stroke. At the left is a button for 'No Paint' which looks like a cross and has the same effect as using the crossed swatch at the left of the palette in the main drawing window. If both the fill and stroke are set to No Paint, then your object will be completely invisible. The second button lets you choose a single color for your fill or stroke. In that respect, it's the same as selecting from the palette, except that you have much finer control over the color. Choosing this button presents you with yet more tabs offering a few different methods for picking your color. Don't be fooled though: Inkscape uses RGB (Red, Green, Blue) values in its files even if you select a color via the HSL or CMYK tabs. This is one example of Inkscape being restricted by the capabilities of the SVG format. The CMS tab is only of use if you set up a color management system on your computer, and is outside the scope of this series.
Whichever color picker you choose, you'll find a slider at the bottom labelled with an 'A'. This is the 'alpha channel', which is just another term for opacity. If this slider is moved to the far left, then your fill or stroke will be completely transparent. To the far right, it's completely opaque. Anywhere in between will make it partially transparent. This image demonstrates the same two objects with the stroke fully opaque, but the top object's fill alpha being set at the 0, 128 and 255 levels (above). As with the No Paint option, setting the alpha channel for both the fill and stroke to zero will render your object completely invisible. If the fill or stroke is partially transparent, the color swatches in the bottom-left corner of the status bar in the main window will show a two-part arrangement: the left half shows the color with the alpha applied over a checkerboard effect, while the right half shows an opaque version of the same color. You can easily make a translucent fill or stroke completely opaque via the context menu on the swatch.
The third and fourth buttons let you use a gradient for your fill or stroke. Gradients will be the subject of next month's article, so remember that these buttons exist, but we'll skip over them for now. The next button lets you paint your fill or stroke using a pattern. Inkscape ships with a variety of stripes and polka dots which are available via a pop-up menu when you select this option. Most patterns are black or white, with just one color pattern (Camouflage) and three grayscale bitmap images that can be used as patterns, right at the bottom of the list. It is possible to create your own patterns and to adjust the size and scale of the built-in patterns, but those are subjects for another day. Also being put off for later articles are the Unset Paint button that looks like a question mark and the two splodges on the right of the Fill tab.
The third main tab on the Fill and Stroke dialog is labelled as Stroke Style. While the Stroke Paint tab is used to set the color, gradient or pattern that is used for the stroke, this tab lets you manage all the other parameters. Most of these settings can be adjusted only by using this dialog, so it's worth becoming familiar with it. At the top is a spin-box for setting the width of the stroke, and an associated pop-up menu for picking the units that the width is measured in. These duplicate the functionality available from the right-click menu on the status bar, but offer a greater choice of units and finer control over the width. SVG currently allows the stroke to only straddle the outline of the object, half inside and half outside it. You can see this clearly by reducing the alpha channel on a thick stroke – notice that the fill shows through the inner half of the stroke. It's worth remembering, as Inkscape novices often wonder why increasing the stroke also reduces the area inside their shapes.
Next are three radio buttons labelled as Join. These determine how the corners of your objects are drawn – either as sharp (mitred), rounded or bevelled corners. The difference between them can easily be seen by drawing a star (above left). When a mitred corner is particularly sharp, the point of the join may extend quite some way. In this case Inkscape will switch to drawing a bevelled corner instead. The length that the point is allowed to grow to, before this switch occurs, is set by the Mitre Limit spin-box. The Cap buttons affect the ends of your lines. Most of the objects we've drawn so far are continuous loops, so the ends aren't really clear, but if you use the circle handles to turn an ellipse into an arc then you'll have an object with obvious ends. The middle option, Round Cap, finishes your lines with a semicircular smooth extension to the end. The other two options, Butt Cap and Square Cap, both give a squared-off end to your line, and differ only in whether the square extends beyond the nominal end of the line (Square Cap), or stops precisely at that point (Butt Cap).
The stroke doesn't have to be a single continuous line, it can consist of a repeating pattern of dashes. Anyone who has spent time with technical drawings will be familiar with the dash-dot-dash of a center line, and a series of dashes can be used to give a stitched effect for artistic purposes. The Dashes pop-up lets you choose from a variety of dash patterns built into Inkscape, with the adjacent spinbox letting you adjust the relative start position of your pattern. The Cap buttons also play a big part when it comes to dash patterns – this image shows our star with a thick dashed stroke using each of the three cap settings (above right). The three pop-up menus for Start, Mid and End Markers allow you to select arrowheads, circles, squares and other shapes which will be positioned on your stroke. Once again, the Start and End options make most sense on an unclosed line, such as an arc. On a closed line, you'll probably want to use only one or the other. The Mid Markers appear wherever there is a corner or a transition to a different line segment – which includes the transition from straight to curved segments on a rounded rectangle. This image shows just three examples of markers and dash patterns in use (bottom).
One big caveat with markers is that they will appear in black, regardless of the color of your stroke. Fortunately Inkscape does ship with an extension that tweaks the necessary SVG internals for you, so making the colors match is as simple as selecting your marker-laden object, and then heading up to the menu bar to choose Extensions > Modify Path > Color Markers to Match Stroke. Even using this extension, however, markers are always opaque, regardless of the alpha setting of your stroke. The last part of the Fill and Stroke dialog to explain is the pair of sliders at the bottom – to adjust the Blur and Opacity. The former is a convenient shortcut for adding the Gaussian Blur filter to an object. SVG filters are a major topic of their own that we'll look at in a later article, but, for now, it's enough to know that increasing this slider will cause your object to become blurred. The more you increase it, the more blurred your object will be. Don't go too overboard: usually a small value will give you a good effect, whilst larger values just dissipate your object into mist. Be aware that using filters will slow the speed at which Inkscape redraws the screen, especially if you're zoomed in closely.
The opacity slider has the same effect as the 'O' spin-box and context menu on the status bar, but with more fine-grained control. Changing this value affects the opacity of the entire object – both the fill and the stroke. Effectively, the object is drawn in memory using the fill and stroke alpha values, then that whole image is drawn to the screen using the object opacity. This cumulative effect makes it possible to combine transparency values in complex ways that wouldn't be possible with just alpha or just opacity. In this rather garish example the squares have 100% opacity and alpha throughout, but the circles have the fill, stroke and opacity values indicated: The opacity slider is one way to make some use out of those colorless fill patterns. By duplicating an object (Edit > Duplicate), and then filling the copy with a pattern and reducing its opacity, you can let the original object's color show through. Why not use that trick on your snowman image to give a little graininess to the covering of snow on the ground with the addition of the Sand texture at a low opacity. Add in some color tweaks, a bit of blurring, and some translucency on the shadows, and you should find that, with your new found mastery of the Fill and Stroke dialog, your image is starting to look a little less flat.