Chapter 5. Positioning and Transforming

Inkscape はオブジェクトとそれに適用する座標変換を区別して管理していると理解できる。

One key thing to know is that transforming a Regular Shape object or a Group of objects by the methods described in this chapter does not (usually) change the underlying description of the object(s).

For example, suppose you have an ellipse that is 100 pixels wide but you need it to have a width of 50 pixels. There are two different ways to achieve the required width. The first is to scale the object by 50% in the horizontal (x) direction. The underlying definition of the ellipse width remains 100 pixels but when the ellipse is drawn a scale factor of 50% is applied in the horizontal direction. The second way to change the ellipse is to use the Ellipse Tool to resize the ellipse. In this case, the underlying description of the ellipse changes and no scale factor is applied.

前者は楕円と縮尺変換で表現し、後者は楕円自身の定義を変更するというものだ。

An exception to this rule is for Rectangle objects. Inkscape will attempt to change the description of the rectangle itself when a simple transformation is applied.

Rectangle の拡縮変換は例外で、Inkscape はなるべく矩形自身を変更しようとする。

Inkscape Coordinates

数学と違い、座標系の距離単位を確認するのが重要だ。

When you open the main Inkscape window, Rulers are drawn by default at the top and left edges of the canvas. -略- The units of the Rulers are the same as the default units of the canvas. If you hover the pointer over a Ruler, a tool tip will show the current unit.

単位系の変換は次にように定められている。Inkscape 以外でも通用するので記憶しておくと便利だ:

Conversion between the units is fairly straightforward: 1 inch = 1/12 ft = 2.54 cm = 25.4 mm = 0.0254 m = 6 pc = 72 pt.

キャンバス座標系と SVG 標準座標系は異なることを理解する:

One confusing aspect is that Inkscape uses a different scale internally. On the canvas, the x and y coordinates increase as one moves right or up. Internally the y coordinate is flipped as per the SVG standard. Thus, (0, 0) is defined from the upper-left corner of the page region internally but at the bottom-left corner in the canvas window.

キャンバスのほうが右手座標系であることに注意したい。すると角度の測量も Inkscape の画面上ではそれに準じる向きを正とする。

以上のシステムは既定値についての記述であり、ユーザー設定でオプションを変更できる。

Transformations

対象に座標変換を適用するには、それをまず選択状態にしておく必要がある:

Each method begins by selecting an object or group of objects to be transformed. The Select Tool must be active for making transformations with the mouse or keyboard.

座標変換に関して注意点がいくつかある。箇条書きにしてまとめておく:

  1. SVG 画素と画面画素の区別がある。後者を使う変換操作はズームレベルに依存する。

  2. オブジェクトの bounding box (BB) に二つの定義がある。視覚的か幾何的かで区別される。

  3. 先述のとおり、座標変換対象は通常その定義を変更されない

  4. Select ツール使用時に Tools コントロールでオンオフを切り替えられるオプションが多数ある。

  5. 回転変換と傾斜変換には中心点の概念がある。

項目 4. は描線の太さ、矩形の丸角、グラデーション、パターンに対する拡縮変換、移動変換に影響する。

Transforms with the Mouse

Translations

左ボタンドラッグでオブジェクトを直観的に移動する。

Alt を押しながらドラッグすると、開始位置に関係なく選択オブジェクトを移動する。開始位置のオブジェクトを選択しない。

Ctrl を押しながらドラッグすると、座標軸に対して平行に移動するようになる。

Shift を押しながらドラッグすると、Grids に対するスナップが一時的に無効になる。

上記のキーを伴う操作は組み合わせても機能する。

Scaling, Rotating, and Skewing

Inkscape オブジェクトを選択すると、座標変換制御用の UI が描画される。それを操作することで表題の座標変換を大まかに指定する。

When an object or objects are first selected, eight double-headed arrows will appear in a rectangle around the selection. A Left Mouse Drag of any handle will rescale the selection. The corner arrows will scale both in the horizontal (x) and vertical (y) directions. The side arrows will scale in only one direction.

オブジェクトを選択すると、最初に拡縮変換指定用のハンドルが現れ、もう一度クリックするか、特定のキー操作によりハンドルが回転変換指定用に切り替わる:

Clicking a second time on a selected object or using the keyboard shortcut Shift + S will change the direction of the double-headed arrows. Now, a Left Mouse Drag of a handle will rotate the selection if used on a corner arrow, or skew the selection if used on a side arrow. Click again to revert to the scaling mode.

また、回転中心ハンドルも指定可能だ:

Rotation takes place around the Rotation center indicated by a “plus”-shaped handle.

回転中心の配置方法は本書参照(細かくてまとめるのが億劫だ)。

移動変換同様に、修飾キーを伴うドラッグ操作が用意されている:

The Shift, Ctrl, and Alt keys can be used with the Left Mouse Drag. They can be used in combination when scaling, rotating, or skewing.

Scaling

Ctrl 押しドラッグは縦横比を維持して拡縮する。

Shift 押しドラッグは選択中心に関して対称的に拡縮する。

Alt 押しドラッグは縮尺を整数倍または分子が 1 の単純な分数に制限する。縮尺が負の値の場合、図形は反転する。

Rotating and Skewing

Ctrl 押しドラッグは回転や傾斜を回転スナップ角の倍数に拘束する。

Shift 押しドラッグは回転の場合は反対側の角を、傾斜の場合は反対側の辺を固定する。拡縮操作の挙動と対照的であることに注意。

Transforms with the Keyboard

キーボードで座標変換を実行する場合、キーの組み合わせによっては、変換の大きさはユーザー設定の Steps タブで設定できるパラメーターによって決まる。

利用者ノート

設定ダイアログには検索欄があるので、そこに Steps と入力すればいい。その他の設定項目についても同じ方法が使える。

Translations

矢印キーで選択オブジェクトを上下左右に動かすことができる。

キーバインド

挙動

矢印キー

Arrow Keys move by 量だけ移動

Shift + 矢印キー

矢印キー単発だけのときの十倍移動

Alt + 矢印キー

画面画素一個分だけ移動

Alt + Shift + 矢印キー

画面画素十個分だけ移動

Scaling

拡縮変換は対象オブジェクトの BB の重心周りになされる。

キーバインド

挙動

. or >

拡大

, or <

縮小

Ctrl + . or Ctrl + >

二倍の大きさになる

Ctrl + , or Ctrl + <

半分の大きさになる

Alt + . or Alt + >

画面画素単位ずつ拡大

Alt + , or Alt + <

画面画素単位ずつ縮小

修飾キーなしの拡縮はユーザー設定の > and < scale 値だけ大きさが変わる。

Alt 押しの拡縮変換では、画面画素一つの長さを BB 中心から最も遠い端までの距離で割った値を係数とする。

利用者ノート

例えば >Shift + . のことだが、要するに Shift を押しても押さなくてもかまわないということだ。

Rotation

先述のとおり、回転変換の中心を BB 中心以外であるようにもできる。ここでのユーザー設定値とは Rotation snaps every が適用される。

キーバインド

操作

[

左にユーザー設定値だけ回転

]

右にユーザー設定値だけ回転

Ctrl + [

左に 90 度回転

Ctrl + ]

右に 90 度回転

Alt + [

左に画面画素一つ分だけ回転

Alt + ]

右に画面画素一つ分だけ回転

Alt 押しの回転変換の量がわかりにくいが、画面画素長を BB 中心からその頂点までの距離で割った値の正接とある。

Flipping

Flip around center point of bounding box if in scaling mode or around horizontal/vertical line passing through Rotation center if in rotation/skewing mode.

キーバインド

操作

H

水平に反転

V

垂直に反転

Transforms with the Tool Controls Bar

Tool Controls BarX, Y, W, H でも移動や寸法変更を適用できる。錠前アイコンをクリックすると、縦横比を固定したまま変換できるようになる。

Transforms with the Object Drop-Down Menu

メインメニュー Object にある項目でも一部の変換操作を実行できる:

  • Object ‣ Rotate 90°CW

  • Object ‣ Rotate 90°CCW

  • Object ‣ Flip Horizontal

  • Object ‣ Flip Vertical

利用者ノート

キーボードのほうが早い。

Transforms with the Transform Dialog

Objects can be moved, scaled, rotated, and skewed using the Transform dialog (Object ‣ Transform… Ctrl + Shift + M). There is a different tab in the dialog for each of these transforms. In addition, there is a Matrix tab that allows the application of a Transformation Matrix to a selection.

細かい数値入力で座標変換する場合にはこの UI を利用する。行列成分を直接指定することも可能だ。

The Transform dialog contains an option to apply the chosen transformation to a selection as a group or to the individual objects within the selection. (This option has no effect for the Matrix tab.)

変換の適用先がグループ全体なのか、グループを構成する要素一つ一つなのかを決められる。Apply to each object separately にチェックを入れると後者を指定することになる。

Move Tab

Relative move だけ注意。入力値が移動量なのか、移動先座標なのかを指定するものだ。変換対象が複数ある場合に挙動の違いが顕著になる。

Scale Tab

Scale proportionally をオンにすると、対象の BB 縦横比を固定しつつ拡縮する。

Rotate Tab

UI が単純なので見ればわかる。回転の向きを切り替えるボタンもあるが、正が左周りを意味するのが Inkscape では基本だ。

Skew Tab

You can skew in the horizontal and vertical directions separately. The skewing is relative to the center of the bounding box. The magnitude of the skew can be specified as a distance, percentage, or angle. In all cases, the skew is relative to the size of the bounding box.

利用者ノート

馴染みのない変換なので後回しにする。

Matrix Tab

このタブでは同次変換行列を直接設定することができる。行列の形は次のとおり:

\begin{aligned} \begin{pmatrix} A & C & E\\ B & D & F\\ 0 & 0 & 1 \end{pmatrix} \end{aligned}

行列は点に対して左から作用する。

The tab includes the option Edit current matrix to select if the entered matrix should post-multiply the existing transformation matrix (option not selected) or if it should replace the current matrix (option selected).

問題は次の仕様だ。どちらの行列を編集するかによって、座標変換が基づく座標系が異なるという:

the transformation matrix is with respect to the point \((0, 0)\) in screen coordinates if not editing the current matrix. If editing the current matrix, the transformation is with respect to the User Coordinate System which, if an object is not in a Group, is equivalent to the SVG coordinate system (Initial View Port) where the origin is at the top-left corner of the page. See the SVG standard for more details.

さらに、ダイアログ上で見えている数値と、SVG に記述されるそれとがユーザー設定により異なる場合があることに注意する:

Second, Inkscape will modify the matrix and other parameters of an object internally so that the internal E and F terms are zero if the Store transformation parameter under the Transforms section in the Inkscape Preferences dialog is set to Optimized. This means, for example, that for a horizontal skew of a rectangle, the internal height parameter may change. The displayed object will still look correct.

Transforms with Paste Size Commands

Edit ‣ Paste Size ‣ Paste something 系コマンドについて。クリップボードにいったん基準となるオブジェクトを置く必要がある。

To use the commands, first copy (or cut) a selection with the desired dimension(s) to load the selection into the clipboard.

次のコマンドは、クリップボードに合わせて選択範囲を全体的に拡縮する:

  • Edit ‣ Paste Size ‣ Paste Size

  • Edit ‣ Paste Size ‣ Paste Width

  • Edit ‣ Paste Size ‣ Paste Height

次のコマンドは、クリップボードに合わせてオブジェクトそれぞれを拡縮する:

  • Edit ‣ Paste Size ‣ Paste Size Separately

  • Edit ‣ Paste Size ‣ Paste Width Separately

  • Edit ‣ Paste Size ‣ Paste Height Separately

寸法は BB によって決まる。

Transforms with the XML Editor

Full control over the transformation of an object is available through the XML Editor dialog (Edit ‣ XML Editor… (Shift + Ctrl + X)).

文書の本体である XML を直接編集することで座標変換を完全に調整することが可能だ。特に行列成分を編集するときには、その出現順序を正確に理解しておく必要がある:

Any transform an object is subject to is described by the transform attribute. A transform can be of type translate, scale, rotate, skewX, skewY, or matrix. In most cases, the transform will be of the matrix type. A matrix entry contains the Transformation Matrix in the order (A, B, C, D, E, F) where (ACE) is the first row of the matrix.

前述の適用座標系が何であるかに関する注意をここでも意識すること。

Snapping

読者ノート

前半のパラグラフの内容が Inkscape 1.2 に即していないので、自分で調べてまとめるしかない。

PreferencesBehavior ‣ Snapping 内の設定項目として流用できる記述がある:

Delay (in seconds)

マウスカーソルの移動が停止してからスナップが行われるまでの遅延時間。スナップ対象が多い場合に効果的だ。

Only snap the node closest to pointer

読んで字のごとく。ノード数が多い場合に効果的。

Weight factor

複数のスナップが可能な場合、この値がスナップ点とスナップ対象の間の最小距離を優先するか、カーソルに最も近いスナップ点を使用するようなスナップを優先するかを決定する。0 に近いほど前者に、1 に近いほど後者に強くスナップする。

Snapping Objects

Snap Controls Bar に様々なスナップ点や対象のオンオフを切り替えるボタンがある。この UI はいくつかの区画からなる。

  1. チェックボックス Enable snapping のみの区画。スナップ(ガイド線とグリッドをも含む)のオンオフを大域的に切り替える。

  2. チェックボックス Bounding boxes が先頭にある区画。BB で定義された点へのスナップと、その点からのスナップに関するものだ。

  3. チェックボックス Nodes が先頭にある区画。ノードとハンドルへのスナップのオプションで構成される。

  4. チェックボックス Other points が先頭にある区画。

  5. チェックボックス Alignment が先頭にある区画。

  6. 残るは、グリッド、ガイド線、ページ境界へのスナップのオンとオフを切り替えるためのチェックボックスそれぞれがある。

Enable snapping はキーバインド % を叩くほうが早い。

本書で解説があるのは 2. と 3. だ。BB のスナップで注意するのは Edges だろうか:

Note that edges are never snap points.

ノード系は CAD でよく世話になっていたから大丈夫。

Guides

Guide Lines are individual lines that can be arbitrarily placed. They are defined by an x-y anchor (origin point) through which the line passes and an angle. The anchor is shown as a small circle on the line.

グリッドが規則性を特徴とするのに対して、ガイド線は任意に配置できる。

ガイド線の表示切り替えはメインメニューから View ‣ Guides を選択するか、キーバインド | を押す。ガイド線は表示状態でなければ有効にならない。

Guide Creation

ガイド線は水平や垂直のものならワープロソフトの感覚で引ける。

To create a Guide Line, Left Mouse Drag from the left Ruler onto the canvas for a vertical Guide Line or from the top Ruler for a horizontal Guide Line.

定規部分からキャンバスにドラッグするとガイド線が追加されていく。

An angled Guide Line can be created by dragging from the end of a Ruler. By default, the angle is set to 45° if a rectangular Grid is displayed or parallel to the angled lines if an axonometric Grid is displayed.

後者の状況がわからない。

Guide Adjustment

Guide Lines can be translated and rotated using the mouse

いったんガイド線を引くと、それをマウスでずらしたり回したりできる。

  • 左ボタンドラッグで直線とアンカーを並進移動。ページの外にドラッグすると削除。

    • Shift を押しながらだとアンカーを中心にガイド線を回転。ドラッグ開始位置をアンカーと一致させないようにすること。

    • Ctrl を押しながらだとアンカーをガイド線上に拘束しつつ移動。

    • Ctrl + Shift を押しながらだと 15 度(既定値)の整数倍だけガイド線を回転。

  • Del: ガイド線上にある限り、それを削除。

    Guide Lines can be precisely placed by using the Guide Line dialog, called up by double-clicking on a Guide Line. A check box toggles between absolute and relative placement.

ラベルを設定可能であるなど、UI がバージョン 1.2 では本書のスクリーンショットと異なる。

Guides Created from Objects

Guide Lines can be created from objects using the Object ‣ Object to Guides (Shift + G) command. -略- In each case, the selected objects are deleted unless the Keep objects after conversion to guides entry is checked in the Tools section of the Inkscape Preferences dialog.

ガイド線をオブジェクトから生成する状況では、用済みになったオブジェクトを削除するのが一般的であるようだ。

本書では矩形、三角形、円などから生成されるガイド線の仕様を説明している。当ノートでは割愛。

グループを選択する場合には、その構成要素それぞれに対してガイド線が生成される。

Grid

グリッドといっても正方形以外にも正三角形からなるものもある:

A Grid is composed of two or three sets of evenly spaced parallel lines. A Rectangular Grid consists of horizontal and vertical lines, much like a sheet of ordinary graph paper. An Axonometric Grid consists of three sets of parallel lines, typically one vertical and two at 30° angles from the horizontal. It is often used to draw three-dimensional objects.

グリッドは編集中の文書に関連付けられていて、アプリケーションの設定ではない:

Grids can be created and edited on the Grids tab of the Document Properties dialog. To create a Grid, select the type (Rectangular or Axonometric) from the drop-down menu at the top of the dialog and then click on the New button. The parameters for the new Grid will then be editable under a tab in the bottom of the dialog. It is possible to have more than one Grid defined (and in use). Each Grid will have a tab entry.

実際に設定画面の UI を見ると、CAD の作業平面のそれと共通する属性もいくつかある。新規グリッドの属性の初期値はアプリケーション設定で決まる:

The default Grid parameters can be modified in the Grids section of the Inkscape Preferences dialog.

複数のグリッドを文書に追加することが可能なのは、図面を異なるウィンドウで表示することを念頭に置いていることによる。グリッドごとに表示状態や有効状態を切り替えられることに注意:

Different “views” of the same drawing share the same Grids but the Grids can be enabled or made visible independently for each view.

Alignment and Distribution of Objects

Align and Distribute ダイアログの表示方法をまず記憶する:

  • Object ‣ Align and Distribute

  • Ctrl + Shift + A

    Two types of positioning are available: alignment where the centers or edges of objects are aligned to one another, and distributing where objects are distributed in some direction based on their centers or edges.

以下、Align タブ UI と操作の記述がしばらく続く。

Align

オブジェクトの位置を揃えるには、Relative to で揃える基準となるものを指定する。次のような選択肢からなる:

  • オブジェクト:最初の選択、最後の選択、最大寸法のもの、最小寸法のもの。

  • ページ

  • 図面

  • 選択範囲

Move selection as group をチェックすると、選択オブジェクト全体が位置合わせ中にだけグループ化されて扱われる。これは手動でグループ化したり解除したりする手間を省く。

どこに揃えるかを対応するボタンを押して指定する。アイコンを見ればどうなるかわかる。

読書ノート

次の便利なキーバインドが定義されている。配列操作には Relative to での指示が反映されるのだが、状況次第ではダイアログを表示せずともオブジェクトを配列することができることが期待できる。

キーバインド

操作

Ctrl + Alt + H

Center on vertical axis

Ctrl + Alt + T

Center on horizontal axis

Ctrl + Alt + Num5

上記の操作の合成

Ctrl + Alt + Num4

Align left edges

Ctrl + Alt + Num8

Align top edges

Ctrl + Alt + Num6

Align right edges

Ctrl + Alt + Num2

Align bottom edges

Distribute: Uniform

オブジェクトを水平または垂直方向に一様にばらけさせる。

The distribution of objects is between the two objects at the extremes (i.e., the leftmost and rightmost objects for horizontal distribution). The definition of which is the leftmost and rightmost object is made using the objects’ bounding boxes, and it may depend on the type of distribution selected. For example, if a distribution is based on the rightmost edge of the objects, then the objects rightmost edge will be used to determine which objects are at the extremes.

わかりやすいアイコンの付いたボタンを押して選択オブジェクトを配置する。

Distribute: Non-Uniform

バージョン 1.2 では Rearrange という区画にさらなる操作とともに整理されている。ツールボタン左から:

  • グラフ構造のノードをいい感じに配置する

  • オブジェクトの位置を入れ替える

    • 選択順

    • z-order

    • 巡回

  • 中心からランダムに配置する

  • オブジェクトの塊を解く(端から端までの距離をより均等にするようにを移動させる)

Distribute: Remove Overlaps

Two entry boxes, one for the horizontal direction and the other for the vertical direction, allow the addition of a minimum space between adjacent objects.

Rows and Columns

この節の記述は Grid タブの UI に相当する。複数オブジェクトを行列に配置するためのものだ。次のような方法で配置しようとする:

The algorithm for determining the order the objects are placed in the array attempts to preserve any existing rows. For this algorithm, the bounding box of each object is used. Technically, the objects are first sorted by their vertical positions. Then objects that overlap vertically are sorted by their horizontal positions. Finally, the objects are placed from left to right and from top to bottom in the array.

ここまでの手順はオブジェクトの並び順しか決めない。座標の調整にまだ指定が要る:

For placing objects, the grid is divided into cells. First, the cell size and placement is determined and then the objects are positioned inside the cells, one object to one cell.

Cells are given the height of the tallest object if the Equal height box is checked; otherwise, they are given the height of the tallest object in their row. A similar policy is followed for width.

セル間隔を等間隔にするのか、手動で距離を指定するのかを選択しなければいけない:

If the Fit into selection option is selected, the rows and columns of cells are evenly spaced with the edge rows and columns flush against the bounding box of the selection. If the Set spacing option is selected, the rows and columns are separated by the amount entered in the Row spacing and Column spacing entry boxes. The spacing can be negative.

Alignment のラジオボタンを押して、各セルにあるオブジェクトをどの辺に揃えるのかを決める。その際、注意点がある:

Note that the bounding box of all the objects after alignment may not be the same as the bounding box of the selection prior to alignment even though the Fit to selection option has been chosen. This is because the selection bounding box has been used to place the cells. The objects within the cells may not touch the cell walls.