issue140: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 | ||
issue140:inkscape [2019/01/04 08:36] – d52fr | issue140:inkscape [2019/01/07 15:58] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
Through this technique, you can effectively turn a single image into a number of named tiles, spread out along the x and y plane. This month, you’ll discover that it’s possible to perform a similar trick in the z-axis. In other words, you can stack several sub-images on top of each other, and then choose to show only one of them by putting its ID into the fragment identifier.** | Through this technique, you can effectively turn a single image into a number of named tiles, spread out along the x and y plane. This month, you’ll discover that it’s possible to perform a similar trick in the z-axis. In other words, you can stack several sub-images on top of each other, and then choose to show only one of them by putting its ID into the fragment identifier.** | ||
- | La fois dernière, je vous ai montré comment vous pouvez utiliser un identificateur de fragment dans l'URL qui pointe vers votre fichier SVG de façon à faire qu'un navigateur | + | La dernière |
- | Par cette technique, vous pouvez effectivement transformer une simple image en une quantité de tuiles nommées, réparties sur la surface en x et y. Ce mois-ci, vous découvrirez qu'il est possible | + | Par cette technique, vous pouvez effectivement transformer une simple image en quantité de tuiles nommées, réparties sur la surface en x et y. Ce mois-ci, vous découvrirez qu'il est possible |
**The starting point for this technique isn’t actually SVG, but HTML. The way this trick works relies heavily on inheriting certain behaviours from the HTML and CSS world that can be manipulated into doing something useful in SVG. Let’s start with a simple HTML file (shown top right). | **The starting point for this technique isn’t actually SVG, but HTML. The way this trick works relies heavily on inheriting certain behaviours from the HTML and CSS world that can be manipulated into doing something useful in SVG. Let’s start with a simple HTML file (shown top right). | ||
Ligne 13: | Ligne 13: | ||
With a lengthy page of text, it would be nice to be able to jump straight to a section via a list of links at the top of the page – a table of contents. To do that, we use the <a> tag in two different forms: around each section to “name” the link target, and in the table of contents to create a link that will jump straight to the named target. Skipping the boilerplate code and the content of the <p> tags we get the code shown on the previous page (bottom right).** | With a lengthy page of text, it would be nice to be able to jump straight to a section via a list of links at the top of the page – a table of contents. To do that, we use the <a> tag in two different forms: around each section to “name” the link target, and in the table of contents to create a link that will jump straight to the named target. Skipping the boilerplate code and the content of the <p> tags we get the code shown on the previous page (bottom right).** | ||
- | Le point de départ de cette technique n'est pas vraiment SVG, mais HTL. Pour fonctionner, | + | Le point de départ de cette technique n'est pas vraiment |
- | Il est ainsi pour que les listings du magazine | + | Compte tenu du fait que les listings du magazine |
- | Avec une longue page de texte, il serait sympa d' | + | Avec une longue page de texte, il serait sympa de pouvoir |
**A quick trip to a “lorem ipsum” generator to fill out the content, and the web page looks something like this when loaded into a browser: | **A quick trip to a “lorem ipsum” generator to fill out the content, and the web page looks something like this when loaded into a browser: | ||
Ligne 30: | Ligne 30: | ||
}** | }** | ||
- | Un passage rapide dans un générateur de « lorem ipsum » pour remplir le contenu et la page Web ressemble à quelque chose comme ça en la chargeant | + | Un passage rapide dans un générateur de « lorem ipsum » pour remplir le contenu et la page Web ressemble à quelque chose comme ceci quand elle est chargée |
- | En cliquant sur les liens du Sommaire, le navigateur fera défiler le texte pour rendre la cible du lien visible à l' | + | En cliquant sur les liens du sommaire, le navigateur fera défiler le texte pour rendre la cible du lien visible à l' |
+ | |||
+ | Ainsi, l' | ||
+ | |||
+ | < | ||
+ | :target { | ||
+ | color: red; | ||
+ | } | ||
**This tells the browser to run this little algorithm: | **This tells the browser to run this little algorithm: | ||
Ligne 48: | Ligne 55: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Ceci dit au navigateur de lancer ce petit algorithme : | ||
+ | • L'URL a-t-elle un identificateur de fragment ? | ||
+ | • Si oui, correspond-il à un identifiant cible de la page ? | ||
+ | • Si oui, appliquer la propriété « color: red » à l' | ||
+ | |||
+ | Maintenant, quand vous cliquez sur les lignes du sommaire ou que vous bricolez l'URL à la main, la section cible est rendue avec le texte en rouge, plutôt qu'en noir. Nous avons trouvé une façon d' | ||
+ | |||
+ | < | ||
+ | a { display: none; } | ||
+ | |||
+ | :target { | ||
+ | display: initial; | ||
+ | } | ||
+ | </ | ||
+ | |||
**This will hide all the <a> elements, and their descendants, | **This will hide all the <a> elements, and their descendants, | ||
Ligne 54: | Ligne 77: | ||
The first thing we’ll need, therefore, is a type of element that can act as a container for the content we want to show and hide. In SVG terms, that would be a <g>, which in Inkscape is exposed as a group, but is also used for layers (as noted in previous instalments, | The first thing we’ll need, therefore, is a type of element that can act as a container for the content we want to show and hide. In SVG terms, that would be a <g>, which in Inkscape is exposed as a group, but is also used for layers (as noted in previous instalments, | ||
+ | |||
+ | Ceci cachera tous les éléments <a>, et leurs descendants, | ||
+ | |||
+ | Ainsi, nous avons trouvé une façon de ne montrer qu'un élément unique (et ses descendants), | ||
+ | |||
+ | Ainsi donc, la première chose dont nous avons besoin est un type d' | ||
**But layers have one big advantage: they’re much easier to show and hide when working in Inkscape. Given that this workflow requires each image to be stacked upon the others, this advantage becomes invaluable for anything more than a couple of groups. For the rest of this tutorial, therefore, I’ll be using layers. Continuing from last month’s instalment, I’m going to stack the same four objects I used previously – a circle, a star, a spiral and some text – putting them into individual layers. | **But layers have one big advantage: they’re much easier to show and hide when working in Inkscape. Given that this workflow requires each image to be stacked upon the others, this advantage becomes invaluable for anything more than a couple of groups. For the rest of this tutorial, therefore, I’ll be using layers. Continuing from last month’s instalment, I’m going to stack the same four objects I used previously – a circle, a star, a spiral and some text – putting them into individual layers. | ||
It’s worth reiterating at this point that each layer could contain more than a single element – I just didn’t want to clutter up the screenshots too much by introducing more content. In practice, each layer would typically be an SVG image in its own right, potentially containing multiple elements, groups, clones and filters. In a more complex situation, you can clearly see how the ability to hide and lock individual layers makes this method generally superior to just using Inkscape groups.** | It’s worth reiterating at this point that each layer could contain more than a single element – I just didn’t want to clutter up the screenshots too much by introducing more content. In practice, each layer would typically be an SVG image in its own right, potentially containing multiple elements, groups, clones and filters. In a more complex situation, you can clearly see how the ability to hide and lock individual layers makes this method generally superior to just using Inkscape groups.** | ||
+ | |||
+ | Mais les calques ont un gros avantage : dans Inkscape, ils se montrent et se cachent bien plus facilement. Étant donné que notre déroulé de programme nécessite que chaque image soit placée au-dessus des autres, cet avantage devient inestimable pour celui qui a besoin de plus d'une paire de groupes. Aussi, pour le reste de ce tutoriel, j' | ||
+ | |||
+ | Je me permets de redire ici que chaque calque peut contenir plus d'un élément - je souhaitais juste ne pas trop encombrer les copies d' | ||
**With my layers created, the next step is to open the XML Editor (Edit > XML Editor) and set the IDs for the layers. In the screenshot, you can see that I’ve already set the IDs for “circle”, | **With my layers created, the next step is to open the XML Editor (Edit > XML Editor) and set the IDs for the layers. In the screenshot, you can see that I’ve already set the IDs for “circle”, | ||
+ | |||
While you’ve got the XML editor open, it’s worth noting what happens when you show and hide a layer. Each layer has a “style” attribute which contains “display: inline” if it’s visible, or “display: none” if it’s hidden. We’ll come back to this later but, for now, just remember that there’s a “style” attribute that holds the “display” property directly on each layer. | While you’ve got the XML editor open, it’s worth noting what happens when you show and hide a layer. Each layer has a “style” attribute which contains “display: inline” if it’s visible, or “display: none” if it’s hidden. We’ll come back to this later but, for now, just remember that there’s a “style” attribute that holds the “display” property directly on each layer. | ||
Once your stack of drawings is complete, and your layer IDs have all been set, you’ll need to save the file and open it in a text editor. It’s time to add a block of CSS that will turn off the layers, then turn on only the layer specified in the fragment identifier. The placement of the CSS in the file doesn’t matter too much, but I usually put it just after the opening <svg …> tag (shown below).** | Once your stack of drawings is complete, and your layer IDs have all been set, you’ll need to save the file and open it in a text editor. It’s time to add a block of CSS that will turn off the layers, then turn on only the layer specified in the fragment identifier. The placement of the CSS in the file doesn’t matter too much, but I usually put it just after the opening <svg …> tag (shown below).** | ||
+ | |||
+ | Mes calques étant créés, l' | ||
+ | |||
+ | Pendant que l' | ||
+ | |||
+ | Une fois que votre empilage de dessins sera terminé et que vous aurez inscrit tous les identifiants des calques, vous devrez sauvegarder votre fichier et l' | ||
**The “svg > g” syntax just means “this rule should affect only <g> elements that are immediate children of an <svg> element”, so it doesn’t affect any sub-layers. Otherwise, it’s pretty similar to the HTML rules we used earlier, but with the addition of “!important” on the properties. This tells the browser that these rules should take precedence over those in the “style” attributes on the layer – without them our new block of code would be ignored. You could avoid them if you manually removed the properties from the style attributes on each layer, but as Inkscape will add them back in again if you ever need to edit the file, it quickly becomes a thankless chore. Sprinkling a few “!important” declarations around isn’t particularly good coding practice, but it’s a lot more practical. | **The “svg > g” syntax just means “this rule should affect only <g> elements that are immediate children of an <svg> element”, so it doesn’t affect any sub-layers. Otherwise, it’s pretty similar to the HTML rules we used earlier, but with the addition of “!important” on the properties. This tells the browser that these rules should take precedence over those in the “style” attributes on the layer – without them our new block of code would be ignored. You could avoid them if you manually removed the properties from the style attributes on each layer, but as Inkscape will add them back in again if you ever need to edit the file, it quickly becomes a thankless chore. Sprinkling a few “!important” declarations around isn’t particularly good coding practice, but it’s a lot more practical. | ||
With our SVG stack set up, we can reference the images with a fragment identifier in the HTML, in a similar manner to the named views we used last time (shown top right).** | With our SVG stack set up, we can reference the images with a fragment identifier in the HTML, in a similar manner to the named views we used last time (shown top right).** | ||
+ | |||
+ | La syntaxe « svg > g » signifie simplement que « cette règle ne doit affecter que les éléments <g> qui sont des enfants directs d'un élément <svg> » ; ainsi, elle n'a pas d' | ||
+ | |||
+ | Notre pile SVG étant paramétrée, | ||
**The resultant web page looks like this: | **The resultant web page looks like this: | ||
Ligne 77: | Ligne 121: | ||
With named views and stacks giving broadly similar results, you might want to know which one is better to use. For many cases, either will work: named views arguably require more work to set up, but provide an advantage of being able to see all the individual images in Inkscape at once. Views also work better if your images are different sizes. Stacks, on the other hand, work well if your images require a single common background, or if it’s easier to draw each image by stacking it on top of the previous ones to help with alignment. As is so often the case, the real answer is to try both approaches and see which one works best for you.** | With named views and stacks giving broadly similar results, you might want to know which one is better to use. For many cases, either will work: named views arguably require more work to set up, but provide an advantage of being able to see all the individual images in Inkscape at once. Views also work better if your images are different sizes. Stacks, on the other hand, work well if your images require a single common background, or if it’s easier to draw each image by stacking it on top of the previous ones to help with alignment. As is so often the case, the real answer is to try both approaches and see which one works best for you.** | ||
+ | |||
+ | La page Web résultante ressemble à ceci : | ||
+ | |||
+ | Avec les piles du SVG, il est aussi possible d' | ||
+ | |||
+ | #background { | ||
+ | display: initial !important; | ||
+ | } | ||
+ | |||
+ | Les vues nommées et les piles donnant en gros des résultats similaires, vous pourriez aimer savoir laquelle est la meilleure à utiliser. Dans de nombreux cas, les deux fonctionnent : les vues nommées nécessitent sans doute plus de travail pour les paramétrer, |
issue140/inkscape.1546587383.txt.gz · Dernière modification : 2019/01/04 08:36 de d52fr