Inkscape tutorial: 高级

Inkscape

教程 | 高级

本教程包括:复制/粘贴、节点编辑、手绘线和贝塞尔曲线、路径操作、布尔操作、偏移、简化、以及文本工具。

使用Ctrl+方向键鼠标滚轮,或者鼠标中键拖动可以向下滚动页面。关于创建、选择和变换对象的基础操作知识,请参考菜单帮助教程中的"基础"教程。

粘贴技巧

Ctrl+C 复制对象或通过Ctrl+X剪切对象后,常规的粘贴 命令(Ctrl+ V)会把复制的对象粘贴到鼠标光标所在的位置;如果光标位于窗口外,则粘贴到文档窗口的中心位置。但是,剪贴板中的对象会保存被复制对象的原始位置,您可以通过原地粘贴命令(Ctrl+Alt+V)来粘贴到原始位置。

另一个命令是粘贴样式(Shift+Ctrl+V),此命令会把复制到剪贴板中(第一个)的对象的样式应用到当前选中的对象。这样操作所粘贴的"样式"包括所有的填充、描边和字体设置,但不包括形状、尺寸或特定于形状类型的参数,例如星形的星尖数量。

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).

剪贴板是系统级别的 - 您可以在不同的Inkscape文件之间以及Inkscape和其他应用程序(必须能够处理剪贴板上的SVG才能使用此功能)之间复制/粘贴对象。

绘制手绘线和常规路径

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):

使用钢笔工具,每次点击鼠标左键都会创建一个没有控制手柄的尖角节点,一系列点击操作会生成一系列直线段。单击鼠标左键拖动鼠标会创建一个平滑的贝塞尔节点,节点会带有两个共线相对的手柄。在拖出手柄的同时按Shift键时,可以仅旋转两个手柄中的一个,保持另一个手柄为固定不动。同样,按Ctrl键会限制当前线段或贝塞尔手柄的方向步进为15度的整数倍。按Enter键可以结束绘制,按Esc键可以取消绘制。如果仅想取消未完成绘制的曲线的最后一段,请按Backspace键。

使用钢笔工具和铅笔工具时,当前选中的路径在两端都会显示小方形节点。这两个小正方形节点允许您继续绘制这条路径(比如从一个小正方形节点绘制)或关闭这条路径(从一个小正方形节点绘制到另一个),而不是创建一条新的路径。

编辑路径

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.

您可以通过鼠标左键拖动节点、节点手柄或直接拖动路径段来编辑路径。(尝试拖动上面路径上的节点、控制手柄和路径段。) 按Ctrl键限制移动和旋转步进。方向键Tab[]<>及辅助快捷键与选择工具的工作方式相同,只不过是适用于节点而不是对象。您可以通过双击,或通过Ctrl+Alt+鼠标左键单击路径上的任何位置来在点击位置添加节点。

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).

节点类型可以修改为尖角节点(Shift+C),这意味着该节点的两个控制手柄可以分别独立移动和调整;或者修改为平滑节点(Shift+S),这意味着该节点的两个控制手柄会保持在一条直线上(共线);或者修改为对称节点(Shift+Y),这意味着该节点不仅是平滑节点,并且节点的两个控制手柄长度完全相同;还可以修改为自动平滑节点(Shift+A),自动平滑节点是一种特殊的节点,它可以自动调整本节点的控制手柄以及两侧的其它自动平滑节点的手柄以保持曲线平滑。当您按上面的快捷键调整节点类型时,可以将鼠标指针悬停在节点的一个手柄上来保持该手柄的长度和方向,仅旋转/缩放另外一个手柄。(悬停时,指针应该位于手柄圆点正上方,且圆点由空心变为红色,这表示inkscape已经检测到悬停动作)

此外,您可以通过Ctrl+鼠标左键单击某个控制手柄的圆点来收回该手柄。如果两个相邻节点的手柄缩回,则它们之间的路径段会变为一条直线。要重新拉出缩回的节点,使用Shift+鼠标左键拖动节点一段距离即可。

子路径和路径合并

一个路径对象可能包含多个子路径。子路径是一系列相互连接的节点序列。(因此,如果一条路径包含多个子路径,则并非所有节点都连接。)下面左图,三个子路径属于同一条复合路径;而在右图中,三个子路径则是完全独立的路径对象:

请注意,复合路径与群组是完全不同的概念。复合路径是单个对象,只能作为整体来选择(复合路径可能通过多个路径组合而成)。如果在上方选择左侧对象并切换到节点工具,则三个子路径会同时显示节点。而在右侧同样切换到节点工具后,只有一个路径会显示节点。

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:

这是创建带孔对象的最简单方法。更多关于路径的操作命令,请参考下面的"布尔运算"。

对象转路径

任何形状或文本对象都可以转换为路径(Shift+Ctrl+ C)。此操作不会改变对象的外观,但会删除特定于其类型的所有功能(例如,矩形的圆角调整功能或文本的再编辑功能);相反,因为已经成为路径,所以您可以对其节点进行编辑。下面有两颗星形 - 左边一颗保持为形状形态,右边一颗已经转换为路径形态。切换到节点工具,然后选中左侧再选中右侧,比较检查看有什么不同:

此外,您可以将任何对象的描边转换为路径(轮廓)。下图中,左侧对象是原始路径(无填充,黑色描边),而右侧对象是执行了描边转路径命令之后的结果(黑色填充,无描边):

布尔运算

路径菜单中的命令允许您使用布尔运算来组合两个或多个路径对象:

这些命令的快捷键也提示了布尔运算的结果(并集用加号,差集用减号,等等)。差集命令和互斥命令只能应用于两个选定的对象;其他命令可以一次处理任意数量的对象。如果几个对象的填充和描边不相同,那么布尔运算的结果会采用底部对象的填充和描边(z顺序)。

互斥运算的结果看起来类似于合并(见上文),二者的不同之处在于互斥运算结果会在原始路径相交处增加额外的节点。分割命令和剪切路径命令的区别在于,前者通过顶部对象的路径切割整个底部对象(包括填充和描边),而后者只切割底部对象的描边并删除所有填充(这便于将无填充的描边切割成多份)。

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.

向内偏移和向外偏移(收缩和扩张)

Inkscape不仅可以通过尺寸缩放操作来放大和缩小形状,还可以通过偏移对象的路径来收缩和扩张对象,即把路径上的每一个点都按垂直于路径的方向进行位移调整。对应的偏移命令称为向内偏移 (Ctrl+()和向外偏移(Ctrl+))。下图中,红色路径是原始路径,非红色路径是从原始路径向内偏移或向外偏移后得到的新路径:

上面是使用向内偏移向外偏移命令生成路径(如果目标对象还不是路径,则会将其转换为路径)。实际上,动态偏移命令(Ctrl+J)有可能使用起来更方便,它可以创建一个带有可拖动手柄的对象来控制偏移距离。使用下面的对象来练习动态偏移控制手柄的作用:

这样的动态偏移对象会记住原始路径,因此当您一次又一次地改变偏移距离时,它不会"退化"。当您不再需要调整它时,可以随时将偏移对象转换成路径。

更方便的命令是链接偏移,它与动态偏移相似,但是会链接到另一个仍可编辑的路径。一个源路径可以具有任意数量的链接偏移路径。在下面,源路径为红色,与之链接的一个偏移路径有黑色描边且没有填充,另一个链接偏移具有黑色填充但没有描边。

选择红色对象并对其某个节点位置进行调整;观察两个链接偏移路径如何关联响应。现在选择一个偏移路径并拖动其手柄来调整偏移半径。最后,请注意如何独立移动或变换偏移路径对象,同时又不会失去它们与源路径的链接。

路径简化

简化 命令(Ctrl+L)的主要用途是减少目标路径上的节点数量,同时尽量保持目标路径的原始形状。这对于那些用"铅笔(绘制手绘线)"工具创建的路径可能很有用,因为该工具创建的路径通常节点数量会比较多。下面两个形状,左边的形状是由铅笔工具创建的,右边的形状是左边对象经过"简化"命令处理后的副本。左侧原始路径有28个节点,而经过简化命令处理后,新路径只有17个节点(这意味着后续使用节点工具编辑时会更容易)且更平滑。

简化幅度(阈值)取决于所选对象的尺寸。因此,选择路径的同时也一并选择了其他较大的对象,那么简化幅度会更明显。此外,简化命令自己会加速。这意味着,如果您快速连续多按Ctrl+L几次(操作间隔都在 0.5 秒内),则结果是每一次简化命令的阈值会越来越大。(如果您在暂停后再次执行"简化"操作,则阈值会恢复为默认值。)充分利用加速的特性,可以比较精确的控制所需的简化精细程度。

除了平滑铅笔工具所创建的手绘路径,简化命令还可用于其它创意效果。正常情况下,可以通过简化命令,把刻板和方块化的形状,简化为更生动和更活泼的样子,例如将尖锐的角钝化处理,并引入比较自然的变形,可以显得更时尚,同时又很有趣。下面是一个示例,可以看到在简化后看起来更舒适:

创建文本

Inkscape能够创建超长且复杂的文本内容。但是,创建短小的文本对象(例如标题、横幅、logo、流程图标签和说明等)也非常方便。本节是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).

与其他工具一样,文本工具可以选择文本类型的对象 - 文本对象 - 因此,您可以单击以选择文字对象,并且可以将光标定位在现有的文本对象的任何位置(例如本段)。

文字设计最常见的操作之一是调整字距和行距。Inkscape为此提供了键盘快捷键。编辑文字内容时,Alt+<Alt+>可以修改文本对象当前行中的字母间距,使当前行的总长度以1个像素为步进进行缩放(与选择工具相比,相同的快捷键可以进行像素级的尺寸缩放)。通常,如果文字对象中的字号大于默认字号,那么缩小字间距可能会更好看一些。示例如下:

缩小字距后,作为标题时看起来更好看一些,但仍然不够完美:字母之间的距离并不均匀,例如a和t的距离太远,而t和i的距离太近。字体本身的质量如果不好,那么出现此类问题的频率就会比较高(特别是在大字体中)。但是,在任何文本字符串和任何字体中,字距调整都会带来明显的好处。

Inkscape中调整字距非常容易。只需将光标放在需要调整距离的字符中间,然后使用Alt+方向键来移动光标右侧的字母的位置即可实现。下面是与上面相同的标题文字,这一次是通过手动调整字距来实现视觉上统一的字母间距效果:

除了通过Alt+左方向键Alt+右方向键水平移动文字对象,也可以使用Alt+上方向键Alt+下方向键垂直移动文字对象:

当然,您可以将文字转换为路径(Shift+Ctrl+C)后将文字作为路径对象进行移动。但是,将文本属性保留(不转换为路径)其实更方便 - 文字仍然是可编辑的,您可以尝试不同的字体而无需关注字距,并且在保存文件时,占用的空间要小很多。"文字不转换为路径"的唯一缺点是,您需要在要打开该SVG文档的系统上安装原始字体。

与字母间距类似,如果是多行文本对象,那么您可以调整行间距。在本教程中的任意段落上尝试Ctrl+Alt+<Ctrl+Alt+>,使文本对象的整体高度在当前缩放下改变1个像素(此快捷键目前正在升级,v1.1.1可能无效)。和选择工具一样,使用调整时按辅助快捷键Shift会以10倍位移进行调整。

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.

XML编辑器

Inkscape的终极强大工具是XML编辑器(Shift+Ctrl+X)。它显示文档的整个XML树,反映其当前状态。您可以在编辑图形的同时查看XML树中的相应变化。此外,您可以在XML编辑器中编辑任何文本、元素或属性节点,并在画布上查看编辑效果。这是可以想象到的最好的交互式学习SVG的工具,它使您可以实现常规编辑工具无法实现的技巧。

总结

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: 柳小勤Liu Xiaoqin — 2008; 驿窗 — 2022

Header / footer design: Esteban Capella — 2019