Inkscape tutorial: Nâng cao

Inkscape

Tutorial | Nâng cao

Bài hướng dẫn này đề cập đến thao tác chép và dán, sửa nốt, nét vẽ tự do và cung bezier, xử lý đường nét, các phép tập hợp, đối tượng co rút/mở rộng, đơn giản hoá, và công cụ văn bản.

Use Ctrl+arrows, mouse wheel, or middle button drag to scroll the page down. For basics of object creation, selection, and transformation, see the Basic tutorial in HelpTutorials.

Các kỹ thuật dán

After you copy some object(s) by Ctrl+C or cut by Ctrl+X, the regular Paste command (Ctrl+V) pastes the copied object(s) right under the mouse cursor or, if the cursor is outside the window, to the center of the document window. However, the object(s) in the clipboard still remember the original place from which they were copied, and you can paste back there by Paste In Place (Ctrl+Alt+V).

Another command, Paste Style (Shift+Ctrl+V), applies the style of the (first) object on the clipboard to the current selection. The “style” thus pasted includes all the fill, stroke, and font settings, but not the shape, size, or parameters specific to a shape type, such as the number of tips of a star.

Yet another set of paste commands, available from EditPaste..., scales the selection to match the desired size attribute of the clipboard object(s). There are a number of commands for pasting size and are as follows: Size, Width, Height, Size Separately, Width Separately, and Height Separately.

EditPaste…Size scales the whole selection to match the overall size of the clipboard object(s). Width/Height scale the whole selection horizontally/vertically so that it matches the width/height of the clipboard object(s). These commands honor the scale ratio lock on the Selector Tool controls bar (between W and H fields), so that when that lock is pressed, the other dimension of the selected object is scaled in the same proportion; otherwise the other dimension is unchanged. The commands containing “Separately” work similarly to the above described commands, except that they scale each selected object separately to make it match the size/width/height of the clipboard object(s).

Clipboard is system-wide - you can copy/paste objects between different Inkscape instances as well as between Inkscape and other applications (which must be able to handle SVG on the clipboard to use this).

Vẽ nét tự do và các đường nét chính quy

The easiest way to create an arbitrary shape is to draw it using the Pencil (freehand) tool (P):

If you want more regular shapes, use the Pen (Bezier) tool (B):

With the Pen tool, each click creates a sharp node without any curve handles, so a series of clicks produces a sequence of straight line segments. click and drag creates a smooth Bezier node with two collinear opposite handles. Press Shift while dragging out a handle to rotate only one handle and fix the other. As usual, Ctrl limits the direction of either the current line segment or the Bezier handles to 15 degree increments. Pressing Enter finalizes the line, Esc cancels it. To cancel only the last segment of an unfinished line, press Backspace.

Trong cả 2 công cụ Bút và Bút chì, đường nét đang được chọn sẽ có những điểm neo nhỏ hình vuông ở 2 đầu. Những điểm neo này cho phép bạn vẽ tiếp nét này (bằng cách vẽ từ một trong các điểm neo) hoặc đóng nét lại (bằng cách vẽ từ điểm neo này đến điểm neo còn lại) thay vì tạo ra một nét mới.

Chỉnh sửa đường nét

Unlike shapes created by shape tools, the Pen and Pencil tools create what is called paths. A path is a sequence of straight line segments and/or Bezier curves which, as any other Inkscape object, may have arbitrary fill and stroke properties. But unlike a shape, a path can be edited by freely dragging any of its nodes (not just predefined handles) or by directly dragging a segment of the path. Select this path and switch to the Node tool (N):

You will see a number of gray square nodes on the path. These nodes can be selected by click, Shift+click, or by dragging a rubberband - exactly like objects are selected by the Selector tool (including the very similar way to use the Alt key to draw around the nodes you want to select). You can also click a path segment to automatically select the adjacent nodes. Selected nodes become highlighted and show their node handles - one or two small circles connected to each selected node by straight lines. The ! key inverts node selection in the current subpath(s) (i.e. subpaths with at least one selected node); Alt+! inverts in the entire path.

Paths are edited by dragging their nodes, node handles, or directly dragging a path segment. (Try to drag some nodes, handles, and path segments of the above path.) Ctrl works as usual to restrict movement and rotation. The arrow keys, Tab, [, ], <, > keys with their modifiers all work just as they do in selector, but apply to nodes instead of objects. You can add nodes anywhere on a path by either double clicking or by Ctrl+Alt+click at the desired location.

You can delete nodes with Del or Ctrl+Alt+click. When deleting nodes, Inkscape will in most cases try to retain the shape of the path. Only on sharp corners, it will instead create a straight line. If you want it to always try to preserve the shape, you can use Ctrl+Del. Additionally, you can duplicate (Shift+D) selected nodes. The path can be broken (Shift+B) at the selected nodes, or if you select two endnodes on one path, you can join them (Shift+J).

A node can be made cusp (Shift+C), which means its two handles can move independently at any angle to each other; smooth (Shift+S), which means its handles are always on the same straight line (collinear); symmetric (Shift+Y), which is the same as smooth, but the handles also have the same length; and auto-smooth (Shift+A), a special node that automatically adjusts the handles of the node and surrounding auto-smooth nodes to maintain a smooth curve. When you switch the type of node, you can preserve the position of one of the two handles by hovering your mouse over it, so that only the other handle is rotated/scaled to match.

Also, you can retract a node's handle altogether by Ctrl+clicking on it. If two adjacent nodes have their handles retracted, the path segment between them is a straight line. To pull out the retracted node, Shift+drag away from the node.

Đường nét thành phần

Một nét có thể có nhiều nét thành phần. Một đường nét thành phần là một chuỗi các nút được nối lại với nhau. Nếu một đường nét có nhiều hơn 1 nét thành phần có thể có các nút không được nối với nhau. Trong hình dưới, bên trái là 3 nét con trong 1 nét phức và bên phải là 3 nét độc lập:

Lưu ý rằng một đường nét phức (có nhiều nét thành phần) không giống như 1 nhóm. Đó là 1 đối tượng duy nhất, mà bạn chỉ có thể chọn toàn bộ chứ không thể chọn rời rạc từng đường nét thành phần được. Nếu bạn chọn đối tượng bên trái khi dùng công cụ Nút, bạn sẽ thấy các nút xuất hiện trên cả 3 nét thành phần, trong khi với hình bên phải, bạn chỉ có thể chọn riêng từng nét để chỉnh sửa.

Inkscape can Combine paths into a compound path (Ctrl+K) and Break Apart a compound path into separate paths (Ctrl+Shift+K). Parts of a path (i.e. a selection of nodes) can also be copied with Ctrl+C and inserted as a new subpath (into the same path or a different one) with Ctrl+V. Try these commands on the above examples. Since an object can only have one fill and stroke, a new compound path gets the style of the first (lowest in z-order) object being combined.

When you combine or paste overlapping paths with fill, usually the fill will disappear in the areas where the paths overlap:

Đây là cách dễ nhất để tạo một đối tượng có các khoen trống trên đó. Để biết thêm về các lệnh xử lý nét mạnh hơn, hãy xem phần “Các phép logic” dưới đây.

Chuyển thành đường nét

Any shape or text object can be converted to path (Shift+Ctrl+C). This operation does not change the appearance of the object but removes all capabilities specific to its type (e.g. you can't round the corners of a rectangle or edit the text anymore); instead, you can now edit its nodes. Here are two stars - the left one is kept a shape and the right one is converted to path. Switch to node tool and compare their editability when selected:

Moreover, you can convert to a path (“outline”) the stroke of any object. Below, the first object is the original path (no fill, black stroke), while the second one is the result of the Stroke to Path command (black fill, no stroke):

Các phép toán tập hợp

The commands in the Path menu let you combine two or more objects using boolean operations:

The keyboard shortcuts for these commands allude to the arithmetic analogs of the boolean operations (union is addition, difference is subtraction, etc.). The Difference and Exclusion commands can only apply to two selected objects; others may process any number of objects at once. The result always receives the style of the bottom object.

The result of the Exclusion command looks similar to Combine (see above), but it is different in that Exclusion adds extra nodes where the original paths intersect. The difference between Division and Cut Path is that the former cuts the entire bottom object by the path of the top object, while the latter only cuts the bottom object's stroke and removes any fill (this is convenient for cutting fill-less strokes into pieces).

For some common use cases, the Path menu also contains a few commands that combine multiple basic Boolean operations into one, to save you some time – and on top, they also keep the color and style of the objects, unlike the basic operations: Split Path splits a path into a set of non-overlapping sections (so a text-like path would be split into letters), Fracture fractures a set of overlapping paths along every line in any path, and Flatten will remove every part of each overlapping path that is not visible, because it is covered by another path in the selection.

Shape Builder tool

For building up new shapes from multiple paths by using the mouse only, the Shape Builder tool (X) can be used.

Before you switch to the tool, select some overlapping objects. After you switch to the tool, the canvas will only show the outlines of the objects that you have selected. Now, the Shape Builder tool can be used to choose which sections to keep and which to discard.

Click to add a section to the result, or Shift+click to remove it to create a hole in its place. click+drag to connect multiple sections to one, or Shift+click+drag to remove a contiguous section.

Finally, you can accept or discard the result using one of the buttons in the tool controls bar.

Co rút và mở rộng hình

Inkscape can expand and contract shapes not only by scaling, but also by offsetting an object's path, i.e. by displacing it perpendicular to the path in each point. The corresponding commands are called Inset (Ctrl+() and Outset (Ctrl+)). Shown below is the original path (red) and a number of paths inset or outset from that original:

The plain Inset and Outset commands produce paths (converting the original object to path if it's not a path yet). Often, more convenient is the Dynamic Offset (Ctrl+J) which creates an object with a draggable handle (similar to a shape's handle) controlling the offset distance. Select the object below, switch to the node tool, and drag its handle to get an idea:

Một đối tượng dời hình động như vậy luôn nhớ đường nét gốc là như thế nào, nên nó không “xuống cấp” khi bạn thay đổi nhiều lần khoảng cách dịch chuyển. Khi bạn không cần điều chỉnh khoảng cách này nữa, bạn luôn có thể chuyển một đối tượng dời hình về đường nét gốc.

Tương tự như phép dời hình động, đối tượng dời hình liên kết là đối tượng dời hình động, được nối với 1 đường nét khác. Bạn có thể có nhiều đối tượng dời hình liên kết từ cùng 1 nét nguồn. Hình dưới đây, đường nét nguồn được tô màu đỏ, 1 đối tượng dời hình liên kết có màu đen và không có màu tô, còn một nét khác có màu đen nhưng không cos nét viền.

Select the red object and node-edit it; watch how both linked offsets respond. Now select any of the offsets and drag its handle to adjust the offset radius. Finally, notehow you can move or transform the offset objects independently without losing their connection with the source.

Đơn giản hoá

The main use of the Simplify command (Ctrl+L) is reducing the number of nodes on a path while almost preserving its shape. This may be useful for paths created by the Pencil tool, since that tool sometimes creates more nodes than necessary. Below, the left shape is as created by the freehand tool, and the right one is a copy that was simplified. The original path has 28 nodes, while the simplified one has 17 (which means it is much easier to work with in node tool) and is smoother.

The amount of simplification (called the threshold) depends on the size of the selection. Therefore, if you select a path along with some larger object, it will be simplified more aggressively than if you select that path alone. Moreover, the Simplify command is accelerated. This means that if you press Ctrl+L several times in quick succession (so that the calls are within 0.5 sec from each other), the threshold is increased on each call. (If you do another Simplify after a pause, the threshold is back to its default value.) By making use of the acceleration, it is easy to apply the exact amount of simplification you need for each case.

Besides smoothing freehand strokes, Simplify can be used for various creative effects. Often, a shape which is rigid and geometric benefits from some amount of simplification that creates cool life-like generalizations of the original form - melting sharp corners and introducing very natural distortions, sometimes stylish and sometimes plain funny. Here's an example of a clipart shape that looks much nicer after Simplify:

Tạo văn bản

Inkscape cho phép bạn tạo ra các văn bản dài và phức tạp. Dĩ nhiên, bạn có thể tạo ra các văn bản nhỏ như tiêu đề, khẩu hiệu, biểu hình (logo), nhãn biểu đồ và phụ đề... Phần này sẽ giới thiệu các khả năng xử lý văn bản cơ bản của Inkscape

Creating a text object is as simple as switching to the Text tool (T), clicking somewhere in the document, and typing your text. To change font family, style, size, and alignment, open the Text and Font dialog (Shift+Ctrl+T). That dialog also has a text entry tab where you can edit the selected text object - in some situations, it may be more convenient than editing it right on the canvas (in particular, that tab supports as-you-type spell checking).

Like other tools, Text tool can select objects of its own type - text objects -so you can click to select and position the cursor in any existing text object (such as this paragraph).

One of the most common operations in text design is adjusting spacing between letters and lines. As always, Inkscape provides keyboard shortcuts for this. When you are editing text, the Alt+< and Alt+> keys change the letter spacing in the current line of a text object, so that the total length of the line changes by 1 pixel at the current zoom (compare to Selector tool where the same keys do pixel-sized object scaling). As a rule, if the font size in a text object is larger than the default, it will likely benefit from squeezing letters a bit tighter than the default. Here's an example:

Chữ trên chưa thực sự hoàn hảo: khoảng cách giữa các chữ là không đồng đều. Ví dụ, chữ “a” và “t” quá xa nhau trong khi “t” và “i” lại quá gần. Khoảng cách giữa các chữ không đồng đều (đặc biệt khi ta dùng phông chữ lớn) hay xuất hiện khi ta dùng phông chữ kém chất lượng; tuy nhiên, trong chuỗi văn bản bất kỳ, ta có thể gặp 1 cặp chữ cần điều chỉnh lại khoảng cách.

Inkscape makes these adjustments really easy. Just move your text editing cursor between the offending characters and use Alt+arrows to move the letters right of the cursor. Here is the same heading again, this time with manual adjustments for visually uniform letter positioning:

In addition to shifting letters horizontally by Alt+Left or Alt+Right, you can also move them vertically by using Alt+Up or Alt+Down:

Of course you could just convert your text to path (Shift+Ctrl+C) and move the letters as regular path objects. However, it is much more convenient to keep text as text - it remains editable, you can try different fonts without removing the kerns and spacing, and it takes much less space in the saved file. The only disadvantage to the “text as text” approach is that you need to have the original font installed on any system where you want to open that SVG document.

Similar to letter spacing, you can also adjust line spacing in multi-line text objects. Try the Ctrl+Alt+< and Ctrl+Alt+> keys on any paragraph in this tutorial to space it in or out so that the overall height of the text object changes by 1 pixel at the current zoom. As in Selector, pressing Shift with any spacing or kerning shortcut produces 10 times greater effect than without Shift.

Inkscape can also create flowed texts: simply click and drag with the text tool to draw a text box for your text to flow in. To control the flow, use the alignment button in the tool controls bar.

Lastly, there is a third type of text in Inkscape: the column-type text. This text's width can be set, while the height is not limited. You can turn any normal, non-flowed text (the one that is created by only clicking) into a fixed-width text by dragging the handle opposite the text anchor.

Bộ sửa XML

The ultimate power tool of Inkscape is the XML editor (Shift+Ctrl+X). It displays the entire XML tree of the document, always reflecting its current state. You can edit your drawing and watch the corresponding changes in the XML tree. Moreover, you can edit any text, element, or attribute nodes in the XML editor and see the result on your canvas. This is the best tool imaginable for learning SVG interactively, and it allows you to do tricks that would be impossible with regular editing tools.

Kết luận

This tutorial shows only a small part of all capabilities of Inkscape. We hope you enjoyed it. Don't be afraid to experiment and share what you create. Please visit inkscape.org for more information, latest versions, and help from user and developer communities.

Authors: Bulia Byak; Jonathan Leighton; Josh Andler; Colin Marquardt; Nicolas Dufour; Gellért Gyuris; Maren Hachmann

Translators: Clytie Siddall — 2006; Nguyễn Đình Trung — 2008

Header / footer design: Esteban Capella — 2019