Outils pour utilisateurs

Outils du site


issue216:inkscape

Ceci est une ancienne révision du document !


Let’s begin this month by talking about grids. These are a feature that I rarely use, but there’s no denying that they can be invaluable when trying to keep objects neatly aligned – such as when using Inkscape as a makeshift DTP program in which you want text boxes to live on an underlying structure, defined with a rectangular grid. Some artistic or engineering work can also make heavy use of grids, particularly if you’re using an axonometric grid to create lines using an isometric (30°) or oblique (45°) projection.

Rectangular and axonometric grids have been part of Inkscape for a long time, but version 1.4 adds a third: modular grids. These share some similarity with rectangular grids, in that they are based on horizontal and vertical lines. But whereas rectangular grids use lines that extend to infinity to mark out squares and rectangles in the page, modular grids instead use an infinite array of rectangular blocks, with optional spacing between them.

For any new Inkscape users, it’s worth pointing out exactly how grids work. They’re purely a construction aid, and do not appear in exported or printed output from the program. Most commonly they’re used in conjunction with snapping, causing the cursor to snap to grid lines and intersections as you draw shapes on the canvas. Pressing the ‘#’ key will toggle the visibility of all the grids at once, and when they’re not visible then they can’t be snapped to. This makes it easy to use grids for general layout, but to turn them off quickly if you need to draw something off the grid lines without turning off snapping in general.

Creating grids has been made slightly easier in 1.4. They still live in the Grids tab inside the File > Document Properties dialog, but the previous approach of picking the grid type from a popup menu and then having to click the New button has been streamlined into direct creation buttons for each type of grid. You can still create multiple grids, mixing the types and parameters as you see fit, with each of them appearing as a separate tab in the lower part of the dialog.

It can be useful to have multiple grids active at once if you carefully tweak the parameters to create some kind of relationship between them. For example, here’s a modular grid (red) and axonometric grid (blue), adjusted so that the modular grid creates a series of ‘frames’ inside of which the axonometric grid could be used to draw isometric designs. Consider something like a sprite sheet for an isometric game, or trying to design a coherent set of icons with a faux-3D effect, to see where such a capability could be useful.

But it can also be useful to create multiple grids that may not be so obviously related to each other. Usually in this situation you’ll use the fact that each grid has its own ‘Visible’ checkbox to turn them on and off without having to remove any of them completely. Unfortunately there’s no keyboard shortcut to make toggling individual grids easier, so if you do want to use multiple grids like this, you’ll be making frequent trips to the tabs in this dialog to turn each one on and off.

I covered rectangular and axonometric grids a decade ago, in FCM #97, and not a great deal has changed about their configuration since then. All the grid types now feature the ‘Align to page’ buttons – an array of 9 icon buttons that just act as shortcuts for setting the Origin X and Origin Y fields to some common values. But otherwise the controls for configuring rectangular grids remain largely identical.

Axonometric grids, on the other hand, have gained one other convenience feature with 1.4. Next to the Angle X and Angle Y fields is a button to open a small door-hanger dialog. This contains a single field in which you can put a width:height ratio from which the angles will be calculated. This just saves you performing a little trigonometry if you know the ratio you want. For example, putting a value of “2:1” into this field results in the angles being set to 26.565051°. I’m sure you’ll agree that, for most people, entering the ratio would be preferable to calculating the angles for yourself. Few people are likely to use this feature, though, as for the most common angles of 30° or 45° it’s still easier to type them into the fields directly as degrees. “1.73205 :1” and “1:1” would be the equivalent ratios if you really want to know.

Although little has changed regarding rectangular and axonometric grids, the star of the 1.4 grid party is, of course, the modular grid, so let’s take a look at the parameters for those.

I’m sure you can work out what the Grid Units control does. The two Origin fields set the position of the top-left corner of the grid. You might expect values of 0 to result in a block being positioned so that its top-left corner is perfectly aligned with the top-left corner of the page, but that’s not the case due to the Gap values. These fields set the distance between blocks, but they’re dished out equally on opposite sides of the block: a Gap X of 10 mm will result in a space of 5 mm to both the left and the right of each block, and similar logic applies to Gap Y. So if you do want your first block to be right in the corner of the page, you’ll need to set the Origin values to a negative value of half the corresponding Gap field. In other words, with a Gap X of 10 mm you need to set Origin X to -5 mm (and the same for the Y values). In most cases, however, a bit of a space between the page border and the grid is desirable, so leaving the origin values at zero might be fine. As usual, the exact parameters you need will be highly dependent on what you’re drawing, and how your image relates to the underlying grid.

The Block Width and Block Height fields are pretty self-explanatory, other than the fact that it seems to be impossible to set them to nice, round, equal numbers. Having entered “40” into each field, you can see from the screenshot that one has been nudged slightly up, and the other slightly down. Similar discrepancies seem to happen regardless of the Grid Units, so it’s not just a problem with some internal conversion from millimetres to pixels. The differences are tiny, and unlikely to cause a genuine problem for anyone – but it is rather annoying.

The Margin X and Margin Y fields set an offset that is used to draw a second block, centered on the first. This can be used to draw a margin box around each block, or to draw an inset box by using negative values. The margin boxes are drawn in the color set by the Minor Grid Line Color field, while the main block uses the corresponding Major Grid Line Color. In this screenshot, I’ve set the Minor Color to solid red, and the Major Color to solid blue – you can see how different margin values result in different minor boxes. Both major and minor blocks can be snapped to, so careful use of these fields might provide you with some useful snap points without requiring an additional grid to be created (though that’s still an option, of course).

I think the new modular grid type is a great addition to Inkscape, but it’s a little limited by the lack of some convenience features similar to the new Aspect Ratio option for axonometric grids. I’d love to be able to define a modular grid by telling Inkscape that I want each block to be 40 mm × 30 mm, and have it work out the Gap values required to fit as many blocks as possible onto the page, neatly centered. Or, conversely, set the gap value and number of blocks on the page, and have Inkscape work out the block dimensions.

Moving on from grids, there have been some small updates to a couple of the Live Path Effects (LPEs). First of all, the Ruler LPE has gained three extra parameters: Mark Angle, Minor Mark Gap, and Major Mark Gap:

The Mark Angle parameter allows you to create rulers in which the tick marks extend from the base path at an arbitrary angle, rather than always being perpendicular to it. The value is in degrees, and can be either positive or negative, depending on which way you want the marks to slant.

The Minor and Major Mark Gap fields let you offset the start of each tick some distance away from the base path. The value is a percentage of the overall mark length, but the mark is also shortened by this amount such that its end point remains the same. This means that if you want to shift the marks away from the base path while retaining their length, you’ll need to adjust the Major Length and/or Minor Length parameter as well.

This image (next page, top right) shows the result of using the parameters from the screenshot above – a Mark Angle of 30°, and a Minor Mark Gap of 5.

Unfortunately, the Gap fields won’t accept negative values, so they can’t be used to shift the marks out of the opposite side of the base path in order to produce an asymmetric design in which, say, the tick marks extend 1/3 of their length on one side, and 2/3 on the other.

The only other LPE to have received an update worthy of the Inkscape 1.4 release notes is Taper Stroke. This adds a new option of ‘Clamp’ for the Start Direction and End Direction parameters. These parameters determine whether the taper at each end veers towards one side or is centered, with the new option cutting the shape off squarely, with no taper at all. To that end I think the use of ‘Clamp’ as the option name is a bad one; ‘None’ or ‘Square’ would have been more descriptive, while ‘Butt’ would have better mirrored the naming used in the Fill & Stroke dialog.

The following image shows a line without the LPE applied, then two copies which do have it. The second line has the Start Direction set to ‘Center’ and the End Direction set to ‘Left’. The last line uses ‘Clamp’ and ‘Right’. You can see that the ‘Clamp’ option drastically reduces the length of the line, cutting it off where the taper would usually begin, so you may need to create an artificially long base path if you want to use this option.

Next month we’ll continue exploring more of the changes that have been introduced in Inkscape 1.4.

issue216/inkscape.1745820988.txt.gz · Dernière modification : 2025/04/28 08:16 de d52fr