4.2 The Bounding Box

Generally, an object is just a visible thing on the canvas, a part of your drawing. Of course it’s not always that simple; sometimes, what looks like a separate object is either a part of some other object or a combination of several objects. Identifying individual objects may require some work and Inkscape experience.

Nevertheless, whenever an object is visible on the canvas, we can measure its size and position, using the familiar rectangular coordinate system, with a horizontal X axis and a vertical Y axis. In Inkscape, the coordinate origin is always in the bottom-left corner of the page frame (usually visible as the gray frame on your canvas), with Y values increasing upward and X values increasing to the right.

Note

However, in SVG the coordinate origin is in the top-left corner of the page, and the Y coordinate grows downward. Inkscape moves the origin and flips the Y coordinate when displaying the coordinates to the user, but saves everything in the SVG document per SVG rules. You should always remember this when viewing or editing raw SVG code—for example, in the XML Editor (4.7 The XML Editor).

The rulers at the edge of your canvas area are one way to measure the coordinates (press to reveal them if they are hidden). As you move your mouse over the canvas, small triangular markers on the rulers reflect its current position. Also, the X and Y coordinates of the mouse pointer are always displayed on the right end of the status bar, just before the zoom field marked Z:

The coordinate system of Inkscape

Figure 4-2. The coordinate system of Inkscape

The measurement unit used by the rulers is the same as the document unit that you can set in the Document Properties dialog (3.4 Page Setup). To figure out which unit the rulers currently use without opening the dialog, hover your mouse cursor over a ruler until a floating tooltip appears.

Now let’s create some object; for example, draw an ellipse with the Ellipse tool. You will see that the object, when selected, is framed by a dashed rectangle (Figure 4-3). This rectangle is the visual representation of what is called the bounding box of the object—the smallest possible rectangle which completely encloses the entire object. The bounding box is always upright, that is, its sides are parallel to the coordinate axes; if you rotate an object, its bounding box may or may not change its size, but it won’t rotate with the object. (Try rotating the ellipse by pressing the square bracket keys, and .)

The bounding box of an object is always upright.

Figure 4-3. The bounding box of an object is always upright.

The width, height, and coordinates of the selected object’s bounding box are always reported by the four editable fields in the controls bar of the Selector tool. The X and Y display the coordinates of the bottom-left corner of the box, and the W and H indicate its width and height. (If multiple objects are selected, the values reflect the overall bounding box of the entire selection.) The unit of measurement can be chosen in the drop-down menu on the right; initially it’s the document unit which, by default, is SVG pixel (px, see A.6 Coordinates and Units).

Of course, you can click inside any of these fields and type your own value, which will result in the object being moved (for X and Y) or scaled (for W and H). If you want the change in width to cause proportional change in height or vice versa, click the lock button between W and H to lock them together.

In Inkscape, bounding boxes of objects can be of one of the two types: visual (the default) and geometric. The program always uses only one of these types; to switch from one type to the other, go to the Tools tab of the Inkscape Preferences dialog. The difference is that the visual bounding box, unlike the geometric, includes everything that’s visible about the object—most notably its entire stroke (9.1 Stroke Width) but also markers (9.5 Markers) and filter margins (17.4.4 The Filter Area), while the geometric box enframes only the geometric outline of the object’s path.

Thus, with the geometric box, the outer fringe of a stroked object falls outside of the bounding box; this kind of box corresponds to the object as it is visible in the Outline mode (3.11 Rendering Modes). Usually, the geometric bounding box is preferred by those who use Inkscape for technical drawing, while the visual option makes more sense for almost everyone else. Figure 4-3 shows the visual bounding box; note that it fully encloses the black stroke of the ellipse.