SVG Tiny 1.2 – 20081222

3 描画モデル

目次

3.1 概要

SVGの実装には、この章で述べられる描画(画像化)モデルに従って実装されたかのようにふるまうことが求められている。現実の実装がこのモデルに従わなくともよいが、実装でサポートされるすべての装置に現れる結果はこのモデルに適合しなければならない。【描画 - rendering :「レンダリング」と称されるのが一般的だが、 SVG はグラフィックス描画が主要目的の言語なので、当訳では簡明に描画という語を用いることにする。】 Implementations of SVG are expected to behave as though they implement a rendering (or imaging) model corresponding to the one described in this chapter. A real implementation is not required to implement the model in this way, but the result on any device supported by the implementation shall match that described by this model.

付録 適合性の要件 において、現実の実装がここでの記述から逸脱しても良い範囲を述べる。現実問題として、出力装置の限界(例えば、表現可能な色域が限られているかもしれない)、あるいは精度の数学モデルを実装するための実施上の限界(例えば、現実の実行においては適合性の要求基準が満たされる程度に曲線を直線で近似させることなど)により、実装が多少異なり得ることが予想される。 The appendix on conformance requirements describes the extent to which an actual implementation may deviate from this description. In practice an actual implementation will deviate slightly because of limitations of the output device (e.g. only a limited gamut of colors might be supported) and because of practical limitations in implementing a precise mathematical model (e.g. for realistic performance curves may be approximated by straight lines, the approximation need only be sufficiently precise to match the conformance requirements).

3.2 画家のモデル

SVG の描画では「画家のモデル」が用いられる。出力装置に対する一連の操作は 塗り の適用によって行われる。各々の操作は出力装置のある領域に対する塗りである。領域が前の操作による領域と重なりあう場合は、前の塗りが部分的あるいは完全に隠される。塗りが完全に不透明でなければ、出力装置に現れる結果は 単純アルファ合成 で述べられる(数学的な)合成規則に従う。 SVG uses a "painters model" of rendering. Paint is applied in successive operations to the output device such that each operation paints over some area of the output device. When the area overlaps a previously painted area the new paint partially or completely obscures the old. When the paint is not completely opaque the result on the output device is defined by the (mathematical) rules for compositing described under simple alpha compositing.

3.3 描画順序

SVG は 描画木 を定める。描画木に属する要素には暗黙に描画順序が与えられる。要素は SVG 文書片 において、先行順に深さ優先走査で描画される。後続の要素は前に塗られた要素の上に塗られる。 SVG defines a rendering tree. Elements in the rendering tree have an implicit drawing order. Elements are rendered using a pre-order, depth-first walk of the SVG document fragment. Subsequent elements are painted on top of previously painted elements.

3.4 グラフィックス要素の種類

SVG は キャンバス へ描画され得るものとして、3種類の基本的な グラフィックス要素 をサポートする: SVG supports three fundamental types of graphics elements that can be rendered onto the canvas:

3.4.1 図形とテキストの描画

図形とテキストにより、 フィル (塗りを図形の内部に適用すること)および ストローク (塗りを図形の外形線に適用すること)ができる。ストローク操作ではオブジェクトの外形線が中央線に据えられる。その結果、塗りの半分は図形の内部になされ、残り半分は図形の外部になされる。 Shapes and text can be filled (i.e., paint can be applied to the interior of the shape) and stroked (i.e., painted applied along the outline of the shape). A stroke operation is centered on the outline of the object; thus, in effect, half of the paint falls on the interior of the shape and half of the paint falls outside of the shape.

最初にフィル、次にストロークによる塗りが行われる。 The fill is painted first, then the stroke.

フィルとストローク操作のそれぞれが自身の不透明度を持つ。従って、図形の外形線と内部をフィルとストローク操作で不透明度の異なる別の色で塗ることができる。 Each fill and stroke operation has its own opacity settings; thus, you can fill and/or stroke a shape with a semi-transparently drawn solid color, with different opacity values for the fill and stroke operations.

フィルとストロークは互いに全く独立した描画操作である。従って図形に対してフィルとストロークの両方を行った場合、ストロークの半分はフィルを上塗りする。 The fill and stroke operations are entirely independent rendering operations; thus, if you both fill and stroke a shape, half of the stroke will be painted on top of part of the fill.

SVG では、フィルとストローク操作に適用できる塗りとして、次の種類のものが組み込まれている: SVG Tiny supports the following built-in types of paint which can be used in fill and stroke operations:

3.4.2 ラスター画像の描画

ラスター画像が描画される際には、出力装置上の領域に合わせた標本を生成をするために、元の標本が標準的なアルゴリズムを用いて「再標本化」される。再標本化における要件は 適合性基準 にて明らかにする。 When a raster image is rendered, the original samples are "resampled" using standard algorithms to produce samples at the positions required on the output device. Resampling requirements are discussed under conformance requirements.

3.4.3 動画の出力

動画ストリームはラスター画像の時間刻みの並びであり、その描画はラスター画像の描画と多少の類似性がある。しかしながら、動画ストリームの復号処理も要求されるので、すべての実装が動画出力を SVG の利用空間へ変換できるわけではない。代わりにデバイス空間への出力に制限されるかもしれない。より詳細な情報は 動画 の定義を見よ。 As a video stream is a timed sequence of raster images, rendering video has some similarity to rendering raster images. However, given the processing required to decode a video stream, not all implementations may be able to transform the video output into SVG's userspace. Instead they may be limited to rendering in device space. More information can be found in the definition for video.

3.5 オブジェクトの不透明度

フィルあるいはストロークによるそれぞれの塗り操作は、あたかも、単色またはグラデーションによる塗りを適用すべく用意された黒地透明【色値も不透明度も 0 】に初期化された中間処理用のキャンバスに対し最初に実行されたかのように、ふるまわねばならない。しかる後、中間処理用のキャンバスのアルファ値に fill-opacity または stroke-opacity の値が掛け合わされる。この処理結果のキャンバスが 単純アルファ合成 により背景に合成される。 Each fill or stroke painting operation must behave as though the operation were first performed to an intermediate canvas which is initialized to transparent black onto which either the solid color or gradient paint is applied. Then, the alpha values on the intermediate canvas are multiplied by the 'fill-opacity' or 'stroke-opacity' values. The resulting canvas is composited into the background using simple alpha compositing.

3.6 親への合成

SVG 文書片 は半透明にすることもできる。多くの環境においては(例えばウェブブラウザなど)、最終的な合成の段階で SVG 文書片 が全体として半透明に背景のキャンバスと混色される。 SVG document fragments can be semi-opaque. In many environments (e.g., Web browsers), the SVG document fragment has a final compositing step where the document as a whole is blended translucently into the background canvas.