issue139:inkscape
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue139:inkscape [2018/12/03 07:55] – d52fr | issue139:inkscape [2018/12/07 14:48] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
By default, creating a new document in Inkscape will create an A4 page (210x297mm), | By default, creating a new document in Inkscape will create an A4 page (210x297mm), | ||
+ | |||
+ | Une partie de l’interface utilisateur d’Inkscape est tellement classique, et tellement prise pour acquise, que vous n’avez probablement jamais pris le temps d’y réfléchir : | ||
+ | |||
+ | Par défaut, la création d’un nouveau document dans Inkscape créera une page A4 (210 x 297 mm), sur laquelle sont affichés un fin contour qui représente le bord de la page et une ombre portée qui la fait ressembler plus à une feuille de papier qu’à un simple rectangle. Je ne peux pas dire si le A4 est utilisé par défaut partout, ou s’il y a un lien de localisation qui crée des pages au format Letter aux USA, par exemple, mais, quoiqu’il en soit, vous obtenez une taille par défaut et un bord de page visible. Le changement de la taille de la page s’obtient via le dialogue Fichier > Propriétés du document (Ctrl-Alt-D) : | ||
**I’ve seen a few video tutorials where the presenter heads straight to this dialog to turn off the page border, but I think that’s usually a mistake. If you’re designing for print then having an idea of how your work fits into the page is essential. But the border is just as important for web work, as anything that is drawn outside it won’t be rendered by the browser. If you turn the border off, there’s a real danger that parts of your design might inadvertently fall outside it, preventing them from rendering as expected. | **I’ve seen a few video tutorials where the presenter heads straight to this dialog to turn off the page border, but I think that’s usually a mistake. If you’re designing for print then having an idea of how your work fits into the page is essential. But the border is just as important for web work, as anything that is drawn outside it won’t be rendered by the browser. If you turn the border off, there’s a real danger that parts of your design might inadvertently fall outside it, preventing them from rendering as expected. | ||
The non-display, | The non-display, | ||
+ | |||
+ | J’ai vu quelques tutoriels vidéo où le présentateur fonce vers ce dialogue pour masquer le bord de page, mais je pense que que c’est une erreur la plupart du temps. Si vous dessinez pour ensuite imprimer, avoir une idée de comment votre travail s’intègre dans la page est essentiel. Mais la bordure est tout aussi importante pour un travail pour le Web, car tout ce que vous dessinez en dehors ne sera pas rendu par le navigateur. Si vous masquez la bordure, il y a un vrai danger que des parties de votre dessin se trouvent à l’extérieur par inadvertance, | ||
+ | |||
+ | Le non-affichage, | ||
**For many uses, the page size can natively be set in the Document Properties dialog, with no need to concern yourself any further. This sets the “width” and “height” attributes on the main <svg> which determines the default size that your image will be drawn in the browser. For an icon design, for example, you might set the dimensions to 32px by 32px, and that’s the size it will be rendered. But what happens when you want to use a different scale inside your drawing? Your drawing might be in metres or even miles, yet you still want it displayed at a reasonable size in the browser. For this, there is the viewBox attribute. | **For many uses, the page size can natively be set in the Document Properties dialog, with no need to concern yourself any further. This sets the “width” and “height” attributes on the main <svg> which determines the default size that your image will be drawn in the browser. For an icon design, for example, you might set the dimensions to 32px by 32px, and that’s the size it will be rendered. But what happens when you want to use a different scale inside your drawing? Your drawing might be in metres or even miles, yet you still want it displayed at a reasonable size in the browser. For this, there is the viewBox attribute. | ||
Ligne 15: | Ligne 23: | ||
height=" | height=" | ||
viewBox=" | viewBox=" | ||
- | … >** | + | … > |
+ | ** | ||
+ | |||
+ | Dans de nombreuses utilisations, | ||
+ | |||
+ | L’attribut viewBox est une liste de quatre nombres, représentant les coordonnées x et y de l’origine du dessin et les largeur et hauteur de ce dessin en « unités utilisateur ». Laissez-moi prendre quelques exemples : | ||
+ | |||
+ | <svg … | ||
+ | width=" | ||
+ | height=" | ||
+ | viewBox=" | ||
+ | … > | ||
**This one’s simple. The width and height of the image will default to 100px by 200px, and the coordinates in the drawing are mapped to the image on a 1:1 basis. If you draw a rectangle that’s 100 units wide and 200 units tall, it will fill the available space in the browser window (assuming you position it at the top left of your drawing). Let’s try another: | **This one’s simple. The width and height of the image will default to 100px by 200px, and the coordinates in the drawing are mapped to the image on a 1:1 basis. If you draw a rectangle that’s 100 units wide and 200 units tall, it will fill the available space in the browser window (assuming you position it at the top left of your drawing). Let’s try another: | ||
Ligne 26: | Ligne 45: | ||
Again the image will render to a size of 100px by 200px in the browser. But the viewBox defines a different coordinate system. Now 500 units in the drawing map to 100px in the browser. If you draw a rectangle that’s 100 units wide and 200 units tall this time, it will occupy only one corner of the image (actually being drawn as 20px by 40px in the browser). To fill the image, you would need to draw a rectangle that’s 500 units by 1000 units.** | Again the image will render to a size of 100px by 200px in the browser. But the viewBox defines a different coordinate system. Now 500 units in the drawing map to 100px in the browser. If you draw a rectangle that’s 100 units wide and 200 units tall this time, it will occupy only one corner of the image (actually being drawn as 20px by 40px in the browser). To fill the image, you would need to draw a rectangle that’s 500 units by 1000 units.** | ||
+ | |||
+ | Celui-ci est simple. Les largeur et hauteur de l’image seront de 100 px par 200 px par défaut, et les coordonnées du dessin formeront une image sur une base de 1:1. Si vous dessinez un rectangle de 100 unités de large pour 200 unités de hauteur, il remplira l’espace disponible dans la fenêtre du navigateur (en supposant que vous le positionnez en haut à gauche de votre dessin). Essayons-en un autre : | ||
+ | |||
+ | <svg … | ||
+ | width=" | ||
+ | height=" | ||
+ | viewBox=" | ||
+ | … > | ||
+ | |||
+ | À nouveau, l’image est affichée dans une taille de 100 px par 200 px dans votre navigateur. Mais l’attribut viewBox définit un autre système de coordonnées. Les 500 px de votre dessin deviennent 100 px dans le navigateur. Si vous dessinez un rectangle qui, cette fois, est large de 100 px et haut de 200 px, il n’occupera seulement qu’un coin de l’image (étant dessiné réellement en 20 px par 40 px dans le navigateur). Pour remplir l’image, vous devrez dessiner un rectangle de 500 unités par 1 000 unités. | ||
**Changing the x and y values lets you move the origin of your coordinate system. It lets you say “the origin for the browser (i.e. the point that’s used as the top left of the image) should actually be 100 units down and 50 units across in my drawing”. Another way to think of it is that the viewBox lets you create a viewport into your drawing of a specific size and location: everything inside the viewport will be scaled up or down to fill the image in the browser; everything outside the viewport will be cropped and left un-drawn. | **Changing the x and y values lets you move the origin of your coordinate system. It lets you say “the origin for the browser (i.e. the point that’s used as the top left of the image) should actually be 100 units down and 50 units across in my drawing”. Another way to think of it is that the viewBox lets you create a viewport into your drawing of a specific size and location: everything inside the viewport will be scaled up or down to fill the image in the browser; everything outside the viewport will be cropped and left un-drawn. | ||
For use in a web page, this capability to render only part of the image lets us perform a rather neat trick. By changing the viewBox values, we can selectively display subsections of the file, letting us store multiple images in one file. This reduces the number of network requests needed by your page, in turn speeding up your site.** | For use in a web page, this capability to render only part of the image lets us perform a rather neat trick. By changing the viewBox values, we can selectively display subsections of the file, letting us store multiple images in one file. This reduces the number of network requests needed by your page, in turn speeding up your site.** | ||
+ | |||
+ | Le changement des valeurs | ||
+ | |||
+ | Dans le cas de son utilisation dans une page Web, la possibilité de ne rendre qu’une partie de l’image nous permet de réaliser une astuce plutôt sympa. En changeant les valeurs dans viewBox, nous pouvons afficher sélectivement des sous-ensembles du fichier, nous laissant stocker plusieurs images dans un seul fichier. Ceci réduit le nombre des requêtes sur le réseau demandées par votre page, accélérant ainsi votre site. | ||
**Consider this collection of four images – a star, a circle, a spiral path, and some text in the rather wonderful free font, Trump Grotesk Bold. I’ve drawn them in four sections of a tall, thin page that is 250px wide by 1000px tall (so each element occupies 250px by 250px). With the viewBox set to “0 0 250 1000”, we have a 1:1 mapping when the image is drawn in the browser. You can pretty much ignore the “Scale x” and “Scale y” values – they get set automatically by Inkscape as you change the viewBox fields. | **Consider this collection of four images – a star, a circle, a spiral path, and some text in the rather wonderful free font, Trump Grotesk Bold. I’ve drawn them in four sections of a tall, thin page that is 250px wide by 1000px tall (so each element occupies 250px by 250px). With the viewBox set to “0 0 250 1000”, we have a 1:1 mapping when the image is drawn in the browser. You can pretty much ignore the “Scale x” and “Scale y” values – they get set automatically by Inkscape as you change the viewBox fields. | ||
Ligne 35: | Ligne 68: | ||
As you might expect, when I save this image and load it into the browser, I see all four elements, taking up a space of 250px by 1000px. But look what happens if I change both the page height and the viewBox height to 250: | As you might expect, when I save this image and load it into the browser, I see all four elements, taking up a space of 250px by 1000px. But look what happens if I change both the page height and the viewBox height to 250: | ||
- | As you can see, the page border only surrounds the text. If I save the page and load it into the browser, all I get is a 250px by 250px image showing the text element.** | + | As you can see, the page border only surrounds the text. If I save the pge and load it into the browser, all I get is a 250px by 250px image showing the text element.** |
+ | |||
+ | Intéressons-nous à cet ensemble de quatre images - une étoile, un cercle, un chemin en spirale, et un texte dans une police gratuite assez merveilleuse, | ||
+ | |||
+ | Comme vous pourriez vous y attendre, quand je sauvegarde mon image et la charge dans le navigateur, je vois les quatre éléments, occupant une surface de 250 px par 1 000 px. Mais regardez ce qui arrive si je remplace à la fois la hauteur de la page et la hauteur dans viewBox par 250 : | ||
+ | |||
+ | Comme vous pouvez le voir, le bord de page n’entoure plus que le texte. Si j’enregistre la page et la recharge dans le navigateur, tout ce que je verrai, c’est un carré de 250 px par 250 px montrant le morceau de texte. | ||
**If I now set the “y” value for the viewBox to -250, thus moving the viewport upwards, only the spiral appears in the page. Saving the file and loading it in a browser now only renders the spiral, hiding the other three elements. | **If I now set the “y” value for the viewBox to -250, thus moving the viewport upwards, only the spiral appears in the page. Saving the file and loading it in a browser now only renders the spiral, hiding the other three elements. | ||
Ligne 46: | Ligne 85: | ||
<img src=" | <img src=" | ||
+ | |||
+ | Si, maintenant, je règle la valeur « y » dans viewBox à -250, déplaçant ainsi la fenêtre visuelle vers le haut, seule la spirale apparaît dans le cadre. En sauvegardant le fichier et en le rechargeant dans le navigateur, seule la spirale est visible, les trois autres éléments étant cachés. | ||
+ | |||
+ | Je suis sûr que vous avez déjà déduit qu’un réglage de la valeur « y » à -500 déplacera la page autour du cercle, alors qu’avec -750, elle sera placée autour de l’étoile. Maintenant, faisons un petit rappel pour nous-mêmes de ce à quoi ressemble la balise HTML <img> pour rendre une telle image : | ||
+ | |||
+ | <img src=" | ||
+ | |||
+ | C’est plutôt bref et directe. Cela indique simplement au navigateur de montrer le fichier « views.svg » en utilisant les hauteur et largeur indiquées dans le fichier SVG, et d’afficher le cadre par défaut paramétré dans l’attribut viewBox. Mais nous pouvons ajouter une touche magique au nom du fichier pour dire au navigateur d’écraser les valeurs par défaut de viewBox : | ||
+ | |||
+ | <img src=" | ||
**By changing the viewBox values in the URL we can therefore select a specific region of the image to display. In this case, it allows us to choose between one of several sub-images, making this approach ideal for files that contain multiple icons or logos. An alternative is to use viewBox values that focus on a particular part of your design, or cause some section to be zoomed in. That gives you the possibility of showing, for example, an overview and a detail view, both taken from the same image. | **By changing the viewBox values in the URL we can therefore select a specific region of the image to display. In this case, it allows us to choose between one of several sub-images, making this approach ideal for files that contain multiple icons or logos. An alternative is to use viewBox values that focus on a particular part of your design, or cause some section to be zoomed in. That gives you the possibility of showing, for example, an overview and a detail view, both taken from the same image. | ||
Hard-coding the viewBox dimensions into the URLs does have one significant problem: if your image changes, such that elements are swapped or moved, you also need to update the HTML or CSS file containing the URLs. SVG has an answer to this problem as well: named views.** | Hard-coding the viewBox dimensions into the URLs does have one significant problem: if your image changes, such that elements are swapped or moved, you also need to update the HTML or CSS file containing the URLs. SVG has an answer to this problem as well: named views.** | ||
+ | |||
+ | En changeant les valeurs de viewBox dans l’URL, nous pouvons donc sélectionner une zone spécifique de l’image à afficher. Dans ce cas, ça nous permet d’en choisir une parmi les sous-images, | ||
+ | |||
+ | Du codage en dur des dimensions de viewBox dans l’URL découle forcément un sérieux problème : | ||
**Named views are, as you might have guessed, a way of giving a particular set of viewBox values a name – that can then be referenced from elsewhere. Unfortunately, | **Named views are, as you might have guessed, a way of giving a particular set of viewBox values a name – that can then be referenced from elsewhere. Unfortunately, | ||
In this example, the viewBox attribute in the <svg> element is set to show the text content, but I could equally have set it to show all four objects, just a couple of them, a smaller part of one of the objects, or any other rectangular space in the image. This is the viewBox that will be used by default if nothing else is specified in the document’s URL.** | In this example, the viewBox attribute in the <svg> element is set to show the text content, but I could equally have set it to show all four objects, just a couple of them, a smaller part of one of the objects, or any other rectangular space in the image. This is the viewBox that will be used by default if nothing else is specified in the document’s URL.** | ||
+ | |||
+ | Les vues nommées sont, comme vous pouvez le deviner, une façon de donner un nom à un ensemble spécifique de valeurs de viewBox | ||
+ | |||
+ | Dans cet exemple, l’attribut viewBox dans l’élément <svg> est paramétré pour montrer le contenu textuel, mais j’aurai pu tout aussi bien le régler pour voir les quatre objets, ou juste deux d’entre eux, une partie limitée de l’un d’eux, ou toute autre zone rectangulaire de l’image. C’est viewBox qui est utilisé par défaut si rien d’autre n’est spécifié dans l’URL du document. | ||
**In the < | **In the < | ||
Ligne 60: | Ligne 117: | ||
<img src=" | <img src=" | ||
+ | |||
+ | Dans la section < | ||
+ | |||
+ | L’utilisation de votre vue nommée dans une balise <img> est tout à fait simple : vous avez juste à paramétrer l’ID approprié comme l’identifiant du fragment (le petit bout qui suit le caractère # dans une URL) : | ||
+ | |||
+ | <img src=" | ||
**Of course there’s nothing to stop you referencing the same image more than once in a web page, with a different fragment identifier each time. You can also mix and match named views, the “svgView()” syntax, and the default viewBox. In this way, a single SVG image can easily be used to provide a whole host of icons and other images for your page. To finish off, here’s an example of an HTML document that uses the SVG image from this tutorial: | **Of course there’s nothing to stop you referencing the same image more than once in a web page, with a different fragment identifier each time. You can also mix and match named views, the “svgView()” syntax, and the default viewBox. In this way, a single SVG image can easily be used to provide a whole host of icons and other images for your page. To finish off, here’s an example of an HTML document that uses the SVG image from this tutorial: | ||
Ligne 65: | Ligne 128: | ||
You should now be able to understand how our single SVG image is used multiple times to give the final result:** | You should now be able to understand how our single SVG image is used multiple times to give the final result:** | ||
+ | Bien sûr, rien ne vous empêche de faire référence plus d’une fois à la même image dans une page Web, avec un identifiant de fragment différent à chaque fois. Vous pouvez aussi mélanger et grouper les vues nommées, la syntaxe « svgView() » et l’attribut par défaut viewBox. De cette façon, une image SVG unique peut facilement être utilisée pour héberger un ensemble complet d’icônes et d’autres images pour votre page. Pour terminer, voici un exemple de document HTML qui utilise l’image SVG de ce tutoriel : | ||
+ | |||
+ | Vous devriez maintenant pouvoir comprendre comment notre image SVG unique est utilisée plusieurs fois pour donner ce résultat final. |
issue139/inkscape.1543820152.txt.gz · Dernière modification : 2018/12/03 07:55 de d52fr