Inkscape 0.48 Illustrator's Cookbook
上QQ阅读APP看书,第一时间看更新

Designing plate rims using Layers

If you have worked with a raster graphics program such as The Gimp or Photoshop, you might have used the layers system to view and manipulate different parts of a picture.

In Inkscape, we will find that there is less emphasis on this concept and more on objects. Still, using layers can prove quite handy in some situations and therefore Inkscape provides a system to create and manage them.

In this recipe, our goal will be to draw a kitchen plate with two options for the pattern rim design. This is the drawing with one of the patterns active:

How to do it...

The following steps will show you how to design your plate rims:

  1. Open the Fill and Stroke (Shift + Ctrl + F) and Layers How to do it... dialogs (Shift + Ctrl + L).
  2. Create a circle using the Ellipse tool (F5 or E) while holding Ctrl, make it as large as the page. Set its fill to none, its stroke to White (it will blend with the background), and set the stroke width to 150.
  3. Duplicate the circle (Ctrl + D). Set its stroke color to 30% Gray and Blur: slider to 3.
  4. Press the Esc key once. The focus will shift from the Fill and Stroke dialog window and back to the object.
  5. Move the duplicated circle to the bottom of the stack using the End or Page Down key on your keyboard.
  6. Move the duplicated circle a little to the bottom and right with the bottom and right arrow keys.
  7. Open the Layers dialog (Shift + Ctrl + L). Click on the current layer and rename it to "Plate Shadow".
  8. Click on the Plus button How to do it... on the Layers dialog to add a new layer (Shift + Ctrl +N). In the pop-up window, enter "Plate pattern" as the name for the new layer. Select Above current, and click Add.
  9. Click on the Plus button on the Layers dialog to add a new layer (Shift + Ctrl +N). In the pop-up window, enter "Plate 3D" as the name for the new layer. Select Above Current and click Add.
  10. Click on the white stroke of the visible circle to select it. Duplicate it twice using Ctrl + D. Press the Shift + Page Up twice to move the object two layers up; it will end up in the Plate 3D layer.
  11. Hold Alt while clicking on the white stroke to select the object below the one that is currently selected. Press the Shift + Page Up once to move the object one layer up; it will end up in the Plate pattern layer.
  12. On the Stroke paint tab in the Fill and Stroke dialog, click on the Pattern button, select the Polka dots, large pattern from the drop-down menu. It won't be visible because the object from the Plate 3D layer is covering it.
  13. Click on the white stroke on the canvas to select the object from the Plate 3D layer. Change its stroke color to Black.
  14. Select the Gradient tool (Ctrl + F1 or G) and create a symmetric radial gradient in the stroke, and set the end stop to 30% Gray.
  15. Edit the gradient to create a 3D illusion on the plate rim edges. To do this, create a new stop close to the start stop and move it towards the inner stroke edge, release before you reach the edge. Then create another one near the end stop, select it and lower the Opacity, % slider to 2. Finally, create the third stop within the stroke near the inner edge. Then select it, change its color to White, and set the Opacity, % slider to 0.
  16. Right-click on the Plate pattern layer in the Layers dialog and select Duplicate Current Layer.
  17. In the Stroke paint tab in the Fill and Stroke dialog, select the Ermine pattern from the drop-down menu.
  18. Toggle Plate pattern copy layer visibility by clicking on the Eye icon How to do it...

How it works...

To improve the photorealism of our kitchen plate, we used a couple objects, one below the drawing and one on top. In between lies the actual pattern. This kind of a "sandwich" can be achieved in one layer by stacking objects on top of each other.

But what happens when we need to create a different pattern? We can reuse all of the objects and only change the object with the pattern. However, this way we lose the pattern we first created. We can duplicate the pattern object but then switching between which pattern object is currently used can be somewhat difficult When drawings become complex, micromanaging the objects can be time consuming.

That is why we separated objects into different layers. Bottom and top layers hold the bottom and top shadows, while in between we can have as many patterns as needed. Layer visibility can be easily toggled so making sure that only one pattern is visible at a time is a matter of a few simple clicks.

In this recipe, we created two patterns for our plate; each is on its own layer so we can easily switch between them by toggling their visibility. The examples from this recipe can be found in the LayersPlate.svg file. More fun with plates can be had by checking out LayersPlateFull.svg, where plates can be optionally filled with treats through the use of layers:

There's more...

Some operations involving layers can be done without having the Layers dialog open. In the bottom-left of the Inkscape window there are some layer options: switch layer with the current layer selected, layer visibility, and lock icons. If you don't need to duplicate layers or use blends, you can do everything with these options and a few memorized shortcuts that can be found on the Layer menu.

If you are working with many different layers and objects, and things are becoming confusing, you can use the lock button to freeze that particular layer and prevent any changes from being made to it, or the eye button to hide that layer from view.

XML editor as textual layers dialog

The SVG file format is based on XML (Extensible Markup Language) and can be edited using a simple text editor, such as Notepad or TextEdit. Inkscape parses the textual data and renders it in graphical elements on the canvas, while also providing a WYSIWYG editing environment. Additionally, it also provides a specialized text editor that can manipulate XML/SVG markup.

To open the XML editor, we can use the Shift + Ctrl + X shortcut or the View and edit the XML tree of the document button XML editor as textual layers dialog on the toolbar. Open it when viewing the LayersPlate.svg from this recipe and expand the layer elements using the little triangle icons next to them:

We can see that the position of layers and objects in an SVG document resembles the graphical z-order we see on the Canvas the sooner they appear in markup, the lower they appear visually.

Selecting an object in the XML editor (by clicking on it) also selects it on the Canvas and vice-versa. This can be used to select objects that appear below others in complex drawings with lots of objects stacked on top of one another.

We also see the objects are enclosed within the tags of the layers they belong to. Elements can be dragged and dropped so we can use this editor to rearrange where layers and objects appear within the vertical stack or move objects between different layers.

Tip

SVG format and layers Root layer

SVG doesn't have layers as part of its specification. To introduce this functionality into Inkscape, the already existing SVG group element was used, with an additional label defining the name of the layer. In other words, we must always remember that layers are Inkscape-only features and when saving a document into Plain SVG, our labels will be deleted and our layers will turn into plain SVG groups;

The area in the document that holds objects and layers if they exist is generally referred to as the "root".

Blend modes

You're probably familiar with layer blend modes as many graphics editing applications provide support for them. Inkscape comes with four layer blend modes in addition to Normal: Multiply, Screen, Darken, and Lighten. As expected, the Blend mode selector can be found in the Layers dialog.

The file LayersBlends.svg accompanying this chapter provides a convenient playground for testing blend modes: