1. 序論
~INFORMATIVEこの~moduleは~2D画像を表現するための追加の仕方を導入する 例えば, `~fallback色を伴う~URL$ / `円錐型~勾配$として / 文書~内の別の要素の描画として。 ◎ This module introduces additional ways of representing 2D images, for example as a URL with color fallback, as conic gradients, or as the rendering of another element in the document.
2. 画像~値: `image^t 型
`image$t 値~型は、~2D画像を表し,[ `~url参照$ / `~fallback色を伴う~URL$ / 勾配~記法 ]をとり得る。 その構文は、次で与えられる: ◎ The <image> value type denotes a 2D image. It can be a url reference, image notation, or gradient notation. Its syntax is:
`image@t = `url$t | `image$ft | `image-set$ft | `cross-fade$ft | `gradient$t
`image$t は、[ `background-image$p, `list-style-image$p, `cursor$p ]~prop `CSS21$r なども含め,数多くの~CSS~propにて利用できる(それらの値~内の `url$t 成分を置換する)。 ◎ An <image> can be used in many CSS properties, including the background-image, list-style-image, cursor properties [CSS21] (where it replaces the <url> component in the property’s value).
一部の事例では、妥当な画像~形式でない資源を指している `url$t など,画像は無効になる。 `無効な画像@ は、内在~寸法を伴わない,単色の `transparent$v 画像として描画される。 しかしながら, `image$f 記法などの一部の文脈~下では、`無効な画像$には特別な挙動がある。 ◎ In some cases, an image is invalid, such as a <url> pointing to a resource that is not a valid image format. An invalid image is rendered as a solid-color transparent image with no intrinsic dimensions. However, invalid images have special behavior in some contexts, such as the image() notation.
2.1. 画像~file形式
~propにおいて `image$t 値から参照~される妥当な画像に対しては、~UAは,最低限,次の~file形式を~supportし~MUST: ◎ At minimum, the UA must support the following image file formats when referenced from an <image> value, for all the properties in which using <image> is valid:
- `PNG$r により指定される, PNG ◎ PNG, as specified in [PNG]
- `SVG11$r により指定される,`~secure静的~mode$を利用している~SVG( `SVG-INTEGRATION$r を見よ) ◎ SVG, as specified in [SVG11], using the secure static mode (See [SVG-INTEGRATION])
- ~UAが~animate化 `image$t を~supportする場合、 `SVG11$r により指定される,`~secure~animate化~mode$を利用している~SVG( `SVG-INTEGRATION$r を見よ) ◎ If the UA supports animated <image>s, SVG, as specified in [SVG11], using the secure animated mode (See [SVG-INTEGRATION])
~UAは、他の~file形式を~supportしても~MAY。 ◎ The UA may support other file formats as well.
2.2. 画像~参照: `url^f 記法
`url-notation^L32.3. 解像度の折衝: `image-set^f 記法
利用者の機器に最も適切な解像度の画像を送達することは、困難な仕事にもなり得る。 理想的には、画像~解像度は、利用者~間で様々な,機器それぞれの解像度と同じになるべきである。 しかしながら、送信する画像をどれにするか決める要因になるものは、他にもあり得る — 例えば,低速な~mobile接続の下では、利用者は,解像度は適正でも,巨大になる画像を読込むのを待つより,低~解像度の画像を受信する方を選好するかもしれない。 `image-set$f 関数により、作者は,これらの課題のほとんどを無視して、単に,画像に複数の解像度を供することで,与えられた状況で最も適切なものを UA に決めさせることが可能になる。 ◎ Delivering the most appropriate image resolution for a user’s device can be a difficult task. Ideally, images should be in the same resolution as the device they’re being viewed in, which can vary between users. However, other factors can factor into the decision of which image to send; for example, if the user is on a slow mobile connection, they may prefer to receive lower-res images rather than waiting for a large proper-res image to load. The image-set() function allows an author to ignore most of these issues, simply providing multiple resolutions of an image and letting the UA decide which is most appropriate in a given situation.
この解決策は、解像度が~filesizeを代理するものと見做しているので、[ 複数の解像度からなる一連の~vector画像や, 一連の画像に~vectorと~rasterが混在しているとき(例えば~icon) ]を,適切に取扱わない。 例えば、高~解像度 向けには~vector画像, 低~解像度 向けには画素に最適化された~bitmap, 低~帯域幅 向けには同じ~vector画像(高~解像度であってもずっと小さいので)など。 ◎ This solution assumes that resolution is a proxy for filesize, and therefore doesn’t appropriately handle multi-resolution sets of vector images, or mixing vector images with raster ones (e.g. for icons). For example, use a vector for high-res, pixel-optimized bitmap for low-res, and same vector again for low-bandwidth (because it’s much smaller, even though it’s higher resolution).
`image-set^f の構文は: ◎ The syntax for image-set() is:
`image-set@f = image-set( `image-set-option$t# ) `image-set-option@t = [ `image$t | `string$t ] `resolution$t
~HTMLの `picture$e 要素の機能性に合致させるため、 `w^u / `h^u 次元, および `format^f 関数 を追加すべき。 ◎ We should add "w" and "h" dimensions as a possibility, and a "format()" function, to match the functionality of HTML’s picture.
`image-set$f 関数は、直接的にも(他の `image$t 型の引数として)間接的にも,入子にできない。 ◎ The image-set() function can not be nested inside of itself, either directly or indirectly (as an argument to another <image> type).
この制約は必要か? ◎ Is this restriction needed?
`image-set$f の中の各 `string$t は、 `url$t を表現する。 ◎ Each <string> inside image-set() represents a <url>.
`image-set$f 関数~内の各 `image-set-option$t の `resolution$t は,互いに異なら~MUST — さもなければ,関数は無効になる。 ◎ Every <image-set-option> in a given image-set() must have a different <resolution>, or else the function is invalid.
~UAは、どの `image-set-option$t を読込むかについて、自身に関連する判定基準(~displayの解像度, 接続~速度, 等々)を何であれ見出して,それに基づいて選ば~MUST。 しかる後、 `image-set$f は,その~~選択に結び付けられている画像を表現し、その`内在~解像度$は,その~~選択に結び付けられている解像度になる。 ~UAは、頁が存続する間,与えられた `image-set$f に対し利用する `image-set-option$t を,変更してよい — 選択肢を選ぶために利用された判定基準が,~UAの見積もりにおいて変更に価する程に十分~変化したならば。 ◎ UAs must make a UA-specific choice of which <image-set-option> to load, based on whatever criteria they find relevant (such as the resolution of the display, connection speed, etc). The image-set() then represents the image associated with the URL of that choice. The image’s intrinsic resolution is the resolution associated with that choice. UAs may change which <image-set-option> they wish to use for a given image-set() over the lifetime of the page, if the criteria used to determine which option to choose change significantly enough to make it worthwhile in the UA’s estimation.
次の例に、 `image-set$f を用いて 3 種の画像を供する方法を示す。 “通常”, “高~解像度”, (高品質の印刷~用の) “極高~解像度” (印刷機は 極めて 高い解像度を持ち得るので): ◎ This example shows how to use image-set() to provide an image in three versions: a "normal" version, a "high-res" version, and an extra-high resolution version for use in high-quality printing (as printers can have extremely high resolution):
background-image: image-set( "foo.png" 1x, "foo-2x.png" 2x, "foo-print.png" 600dpi );
2.4. 画像~fallbackと注釈: `image^f 記法
`image$f 関数により、作者は次が可能になる: ◎ The image() function allows an author to:
- `媒体~素片$を利用して、画像の一部分を切抜く。 ◎ use media fragments to clip out a portion of an image
- 単色を画像として利用する。 ◎ use a solid color as an image
- 指定された URL にある画像が[ ~downloadできない, または復号できない ]ときの,単色~画像への~fallbackを指定する。 ◎ fallback to a solid-color image, when the image at the specified url can’t be downloaded or decoded
- 画像の~metadataに指定されている画像の方位に,自動的に従うようにする。 ◎ automatically respect the image orientation specified in the image’s metadata
`image$f 記法は,次で定義される: ◎ The image() notation is defined as:
`image@f = image( `image-tags$t? [ `image-src$t? , `color$t? ]! ) `image-tags@t = [ ltr | rtl ] `image-src@t = [ `url$t | `string$t ]
`image$f 内で利用される `string$t は、 `url$t を表現する。 CSS における通例的な~URLと同様、 `image$f 値に指定された相対~URLは,算出値を得るときに( “値と単位” 仕様 `css-values-3$r に従って)絶対~URLに解決される。 ◎ A <string> used in image() represents a <url>. As usual for URLs in CSS, relative URLs are resolved to an absolute URL (as described in Values & Units [css-values-3]) when a specified image() value is computed.
EXIF などの画像の~metadataにて,方位が指定されている場合、~UAは,その~metadataの指定に従って,画像を回転させたり裏返して 正しく方位させ~MUST。 ◎ If the image has an orientation specified in its metadata, such as EXIF, the UA must rotate or flip the image to correctly orient it as the metadata specifies.
2.4.1. 画像の~fallback
`image$f に~URLと `color$t の両者が指定された下で,~URLが`無効な画像$を表現するときには、 `image$f 関数は,URL が元々指定されていなかったかのように 単色の画像 を描画する。 ◎ If both a URL and a <color> are specified in image(), then whenever the URL represents an invalid image, the image() function renders as if the URL were not specified at all; it generates a solid-color image as specified in §2.4.3 Solid-color Images.
~fallback色を利用すれば、画像の読込みに失敗したときでも,少なくとも~textは読めるようになる。 例えば次の旧来~codeは、画像が透明度を持たない矩形であれば,~~問題なく働く。 ◎ The fallback color can be used to ensure that text is still readable even when the image fails to load. For example, the following legacy code works fine if the image is rectangular and has no transparency:
body { color: black; background: white; } p.special { color: white; background: url("dark.png") black; }
画像が読込めなくても、背景~色により,依然として白色~textは読める。 しかしながら,画像に透明度がある場合、背後の黒色が可視になり,おそらく欲されない結果になる。 `image$f 関数は、これに取組む: ◎ When the image doesn’t load, the background color is still there to ensure that the white text is readable. However, if the image has some transparency, the black will be visible behind it, which is probably not desired. The image() function addresses this:
body { color: black; background: white; } p.special { color: white; background: image("dark.png", black); }
今度は、画像を読込めたときには黒色は全く現れなくなる一方、何らかの理由で画像の読込みに失敗した場合には,黒色がそれに代わり,白色~背景に白色~textが設定されるのを防げる。 ◎ Now, the black won’t show at all if the image loads, but if for whatever reason the image fails, it’ll pop in and prevent the white text from being set against a white background.
2.4.2. 画像~断片
`image$f に指定された~URLが,(例えば,`媒体~素片~識別子$の利用により)資源の一部分を表現するとき、その一部分は,その文脈から切抜かれた上で,自立的な画像として利用されるようになる。 ◎ When a URL specified in image() represents a portion of a resource (e.g. by the use of media fragment identifiers) that portion is clipped out of its context and used as a standalone image.
例えば,次の画像と~CSSが与えられたとする: ◎ For example, given the following image and CSS:
background-image: image('sprites.svg#xywh=80,0,40,40')
要素の背景は、この画像の, ( 80px, 0px ) の所から,右下へ高さ幅ともに 40px の部分(画像の中では黒の四分円)で埋尽くされることになる。 ◎ ...the background of the element will be the portion of the image that starts at (40px,0px) and is 20px wide and tall, which is just the circle with a quarter filled in.
作者が,~CSSの前方互換な構文解析~規則の利点を活かして,画像~slice用の~fallbackを供せるようにするため、 `image$f 記法を~supportする実装は,[ `image$f を通して指定された画像 ]に対する `xywh=#,#,#,#^c 形による`媒体~素片~識別子$ `MEDIA-FRAGS$r を~supportし~MUST。 ◎ So that authors can take advantage of CSS’s forwards-compatible parsing rules to provide a fallback for image slices, implementations that support the image() notation must support the xywh=#,#,#,# form of media fragment identifiers for images specified via image(). [MEDIA-FRAGS]
画像~断片は `url$f 記法でも利用し得ることに注意。 しかしながら、`媒体~素片$ 記法を解せない旧来の~UA は,素片を無視して,単純に画像~全体を表示することになる。 ◎ Note that image fragments can also be used with the url() notation. However, a legacy UA that doesn’t understand the media fragments notation will ignore the fragment and simply display the entirety of the image.
`image$f 記法は~UA による`媒体~素片$の~supportを要するので、作者は,画像~素片~URLを利用する際に,~fallbackを供する CSS の前方互換な構文解析~規則の利点を活かせる: ◎ Since the image() notation requires UAs to support media fragments, authors can take advantage of CSS’s forward-compatible parsing rules to provide a fallback when using an image fragment URL:
background-image: url('swirl.png'); /* 旧~UA */ background-image: image('sprites.png#xywh=10,30,60,20'); /* 新~UA */
~URLに利用されている素片~識別子の構文が,実装が解せない, あるいはその画像~型において妥当でない場合、その~URLは,`無効な画像$を表現しているものと扱われ~MUST。 ◎ If a URL uses a fragment identifier syntax that the implementation does not understand, or does not consider valid for that type of image, the URL must be treated as representing an invalid image.
注記: 旧来との互換性の理由から、この~errorの取扱いは, ~URL【そのもの】の定義ではなく, `image$f 【の中の~URL】に限られる。 ◎ Note: This error-handling is limited to image(), and not in the definition of URL, for legacy compat reasons.
2.4.3. 単色の画像
`image$f 関数の引数に(~URLなしで) `color$t のみが指定された場合、内在~寸法を伴わない,指定された色による単色~画像を表現する。 ◎ If the image() function is specified with only a <color> argument (no URL), it represents a solid-color image of the specified color with no intrinsic dimensions.
例えば,これを、他の画像の上層に半透明な色を重ねて 背景~画像を “淡く染める” 簡単な方法として利用できる: ◎ For example, one can use this as a simple way to "tint" a background image, by overlaying a partially-transparent color over the top of the other image:
background-image: image(rgba(0,0,255,.5)), url("bg-image.png");
`background-color$p は、これに対しては働かない。 それが生成する単色は、常に,すべての背景~画像の~~背後に回るので。 ◎ background-color does not work for this, as the solid color it generates always lies beneath all the background images.
2.4.4. 双向性に応じる画像
作者は、 `image$f 内の `image-src$t の前に、画像~用の方向性( `image-tags$t )を指定しても~MAY — これは、~HTML要素に `dir$a 属性を追加するのに似る。 要素~上で/内で逆~方向の `direction$p を伴う画像が利用された場合、その画像は,行内~方向に裏返され~MUST(行内~方向が X 軸であれば,例えば `scaleX(-1)^v で変形されたかのように)。 ◎ Before listing any <image-src>s, the author may specify a directionality for the image, similar to adding a dir attribute to an element in HTML. If a directional image is used on or in an element with opposite direction, the image must be flipped in the inline direction (as if it was transformed by, e.g., scaleX(-1), if the inline direction is the X axis).
注記: この宣言が不在の場合の既定では、画像の方向性は全くないので,周囲の要素の方向性にも応じない。 ◎ Note: Absent this declaration, images default to no directionality at all, and thus don’t care about the directionality of the surrounding element.
~listが,~bulletとして内容の中を指す矢印を利用していて、左横書きの~textを包含する~list~itemと, 右横書きのそれとが混在している場合、~bulletは,左端にも右端にも生じる。 その結果、一方の側では~textの中を指すよう設計された画像は、他方の側では~textの外を指すことになる。 これは、次の様な~codeで修正できる: ◎ A list may use an arrow for a bullet that points into the content. If the list can contain both LTR and RTL text, though, the bullet may be on the left or the right, and an image designed to point into the text on one side will point out of the text on the other side. This can be fixed with code like:
<ul style="list-style-image: image(ltr 'arrow.png');"> <li dir='ltr'>左に~bulletがあります。</li> <li dir='rtl'>~bulletは右にあります。</li> </ul>
これは次の様に描画されるべきである: ◎ This should render something like:
☞ 左に~bulletがあります。 。すまりあに右は~tellub ☜
【 便宜上,日本語で記しているが、実際には,右横書きの言語でなければ、このように左方へ流れる表示にはならない。 】
左横書き~list~itemにおいては,画像はそのまま利用され、右横書き~list~itemにおいても内容を指すように,画像は行内~方向に裏返されることになる。 ◎ In LTR list items, the image will be used as-is. In the RTL list items, however, it will be flipped in the inline direction, so it still points into the content.
2.5. 画像を組合せる: `cross-fade^f 記法
`cross-fade-function^L32.6. 要素を画像として利用する: `element^f 記法
`element$f 関数により、作者は,文書~内の要素を画像として利用することが可能になる。 参照先の要素の外観が変化するに伴い、画像も変化するようになる。 これを利用すれば,例えば、~slideshow内の次の/前の~slideの~live~previewを作成したり,~fancyな勾配を生成するために `canvas$e 要素を参照~したり,背景を~animate化することさえ可能になる。 ◎ The element() function allows an author to use an element in the document as an image. As the referenced element changes appearance, the image changes as well. This can be used, for example, to create live previews of the next/previous slide in a slideshow, or to reference a canvas element for a fancy generated gradient or even an animated background.
注記: `element$f 関数が再生産するのは、参照先の要素の外観に限られ,実際の内容やその構造を再生産することはない。 作者は、装飾的な目的に限り,これを利用するべきである。 `element$f を,頁にまたがる有意な内容を伴う要素を再生産するために利用しては~MUST_NOT — 代わりに、単に文書の中に要素の複数の複製を挿入すること。 ◎ Note: The element() function only reproduces the appearance of the referenced element, not the actual content and its structure. Authors should only use this for decorative purposes, and must not use element() to reproduce an element with significant content across the page. Instead, just insert multiple copies of the element into the document.
`element$f の構文は、次で与えられる: ◎ The syntax for element() is:
`element@f = element( `id-selector$t )
ここで `id-selector$t は`~ID選択子$である。 `SELECT$r ◎ where <id-selector> is an ID selector [SELECT].
外部~文書~内の要素(~SVGの`塗り~server$など)を参照できるようにする必要はあるか? あるいは、この用途には `url^f を利用するだけで十分か? ◎ Do we need to be able to refer to elements in external documents (such as SVG paint servers)? Or is it enough to just use url() for this?
この名前は、 GCPM の似た関数と競合する。 これはどうにかして解決される必要がある。 ◎ This name conflicts with a somewhat similar function in GCPM. This needs to be resolved somehow.
要素の “反映” を行う能が求まれる — 要素~上の背景~画像として, または擬似要素~内で。 循環の検出を誘発するのを避けるため、これは特別に取扱われる必要がある。 ◎ Want the ability to do "reflections" of an element, either as a background-image on the element or in a pseudo-element. This needs to be specially-handled to avoid triggering the cycle-detection.
`overflow^p が `paged^v にされている~view内の単独の頁にはどう取組むか? ◎ When we have overflow:paged, how can we address a single page in the view?
`element$f 関数は、その引数に与えた~IDに合致する要素を参照~する。 ~IDは、先ず `elementSources$m ~map内で検索される。 見出されなかった場合,文書に対し照合され、合致した要素が複数あれば,関数は それらのうち最初の要素を参照~する。 ◎ The element() function references the element matched by its argument. The ID is first looked up in the elementSources map, as described in that section. If it’s not found, it’s then matched against the document. If multiple elements are matched, the function references the first such element.
`element$f 関数により表現される画像は、要素が文書~内で可視かどうかに基づいて変わり得る: ◎ The image represented by the element() function can vary based on whether the element is visible in the document:
- 要素は`描画され$ていて,`置換~要素$の子孫ではない, かつ`積層~文脈$を生成する場合: ◎ an element that is rendered, is not a descendant of a replaced element, and generates a stacking context
-
関数は、内在~sizeが参照先の要素の `装飾限界~box@ に等しい画像を表現する: ◎ The function represents an image with its intrinsic size equal to the decorated bounding box of the referenced element:
- ~CSS描画~modelを利用して描画される要素に対しては、`装飾限界~box$は,`主要~box$のすべての断片の`~border画像~区画$を包含する, かつ軸に~~平行な,最も小さい矩形になる。 ◎ for an element rendered using a CSS rendering model, the decorated bounding box is the smallest axis-aligned rectangle that contains the border image areas of all the fragments of the principal box
- ~SVG描画~modelを利用して描画される要素に対する`装飾限界~box$は, SVGにより定義されるそれになる。 【大雑把に言えば,外形線の太さも含め,図形~全体を囲う最小の矩形】 ◎ for an element rendered using the SVG rendering model, the decorated bounding box is defined by SVG
注記: 画像は,その限界の外側にあるものは既定で切取るので、~box影の様な`装飾限界~box$の外側へ拡張する装飾は,切取られることになる。 ◎ Note: Because images clip anything outside their bounds by default, this means that decorations that extend outside the decorated bounding box, like box shadows, may be clipped.
- 画像は、広さ無限の `transparent$v ~canvas上に参照先の要素とその子孫を描画して構築され (文書~内にあるときの~sizeと同じになる)、`装飾限界~box$の各~辺は画像の各~辺に接合されるように,位置される。 ◎ The image is constructed by rendering the referenced element and its descendants (at the same size that they would be in the document) over an infinite transparent canvas, positioned so that the edges of the decorated bounding box are flush with the edges of the image.
- 実装を効率的にするためには、要素には積層~文脈またはそれに準じるものが要求されるよう見受けられる。 全部的な積層~文脈は必要か?あるいは疑似的な積層~文脈で済むか? それは通常の積層~文脈になる必要はあるか?あるいは `element^f に描画するときに積層~文脈として描画するだけで済むか? ◎ Requiring some degree of stacking context on the element appears to be required for an efficient implementation. Do we need a full stacking context, or just a pseudo-stacking context? Should it need to be a stacking context normally, or can we just render it as a stacking context when rendering it to element()?
- 参照先の要素またはその先祖に変形-が適用されている場合、要素を画像として描画するときには,変形-は無視され~MUST。 `CSS3-TRANSFORMS$r ◎ If the referenced element has a transform applied to it or an ancestor, the transform must be ignored when rendering the element as an image. [CSS3-TRANSFORMS]
- 参照先の要素が何~頁かに分断されている場合、要素は,頁の内容~区画が頁割~方向に接合されていたかのように表示される — 頁の各~辺は初期~包含塊の対応する始端~辺に整列された上で。 何~行0か/何~柱か に分断されている要素は、単に`装飾限界~box$と伴に描画される ◎ If the referenced element is broken across pages, the element is displayed as if the page content areas were joined flush in the pagination direction, with pages' edges corresponding to the initial containing block’s start edge aligned. Elements broken across lines or columns are just rendered with their decorated bounding box.
- 実装は、参照先の要素~用に生成した既存の~bitmap~dataを再~利用しても~MAY。 あるいは,要素の表示-を再~生成して、当の~sizeにおける画像の品質を最大化しても~MAY(例えば、参照先の要素は~SVG素片であると検出された場合)。 再~生成する場合でも、結果の画像における~layoutが参照先の要素から変化しては~MUST_NOT。 すなわち,画像の見かけは、~raster化の品質の違いを除き,参照先の要素と一致し~MUST。 ◎ Implementations may either re-use existing bitmap data generated for the referenced element or regenerate the display of the element to maximize quality at the image’s size (for example, if the implementation detects that the referenced element is an SVG fragment); in the latter case, the layout of the referenced element in the image must not be changed by the regeneration process. That is, the image must look identical to the referenced element, modulo rasterization quality.
-
`p$e 要素を文書~内の他所で背景として再利用する例: ◎ As a somewhat silly example, a p element can be reused as a background elsewhere in the document:
`efunc1^dgm - 要素は`描画され$ないが、`塗り~source$を供する場合: ◎ an element that is not rendered, but which provides a paint source
- 関数は、`塗り~source$の[ 内在~size, 外観 ]を伴う画像を表現する — ~sizeと外観は、~host言語により定義される。 ◎ The function represents an image with the intrinsic size and appearance of the paint source. The host language defines the size and appearance of paint sources.
-
例えば, `element$f 関数は、~HTML文書~内の ~SVG `pattern$e 要素を参照~できる: ◎ For example, the element() function can reference an SVG <pattern> element in an HTML document:
<!DOCTYPE html> <svg> <defs> <pattern id='pattern1'> <path d='...'> </pattern> </defs> </svg> <p style="background: element(#pattern1)"> ここでは~patternを背景に用いてます。 ~patternが変化したり~animateされた場合、背景も更新されることになります。 ◎ I’m using the pattern as a background! If the pattern is changed or animated, my background will be updated too! </p>
~HTMLは[ `canvas$e, `img$e, `video$e ]など、塗り~sourceを供する,数種の要素を定義する。 頁~内には表示されてないが,中に何か描かれている `canvas$e を,~CSSから参照~できることを意味する: ◎ HTML also defines that a handful of elements, such as canvas, img, and video, provide a paint source. This means that CSS can, for example, reference a canvas that’s being drawn into, but not displayed in the page:
<!DOCTYPE html> <script> var %canvas = document.querySelector('#animated-bullet'); %canvas.width = 20; canvas.height = 20; drawAnimation(%canvas); </script> <canvas id='animated-bullet' style='display:none'></canvas> <ul style="list-style-image: element(#animated-bullet);"> <li> ここでは `canvas$e を~bulletに用いてます。 ◎ I’m using the canvas as a bullet! </li> <li> ここでも。 ◎ So am I! </li> <li> `canvas$e が~JSで変更される度に,すべての~bullet画像も更新されます。 ◎ As the canvas is changed over time with Javascript, we’ll all update our bullet image with it! </li> </ul>
- その他の場合: ◎ anything else
- 関数は`無効な画像$を表現する。 ◎ The function represents an invalid image.
-
例えば,次に挙げる `element$f の利用は、どれも透明な背景になる: ◎ For example, all of the following element() uses will result in a transparent background:
<!DOCTYPE html> <p id='one' style="display:none; position: relative;">one</p> <iframe src="http://example.com"> <p id='two' style="position: relative;"> ~fallback内容 ◎ I’m fallback content! </p> </iframe> <ul> <li style="background: element(#one);"> 要素 `p id='one'^e は、 `display^p が `none^v にされていて`描画され$ないので,塗り~sourceを供さない。 ◎ A display:none element isn’t rendered, and a P element doesn’t provide a paint source. </li> <li style="background: element(#two);"> `element^f には `iframe$e の様な`置換~要素$の子孫は利用できない。 ◎ The descendants of a replaced element like an IFRAME can’t be used in element() either. </li> <li style="background: element(#three);"> `id^a "`three^v" の要素はないので、この背景も透明になる。 ◎ There’s no element with an id of "three", so this also gets rendered as a transparent image. </li> </ul>
結付けられている~boxがない要素は、 `描画され@ ないとされる。 これは例えば、要素またはその ある先祖にて `display^p が `none^v にされている場合などに起こり得る。 ~host言語は、要素が描画されないと見なされ得る追加の仕方を定義して~MAY — 例えば,~SVGにおいては、 `defs$e 要素のどの子孫も描画されないものと見なされる。 ◎ An element is not rendered if it does not have an associated box. This can happen, for example, if the element or an ancestor is display:none. Host languages may define additional ways in which an element can be considered not rendered; for example, in SVG, any descendant of a <defs> element is considered to be not rendered.
`element$f 関数には、多くの用途に利用できる。 例えば、~slideshow内の次の/前の~slideの~previewを示すために利用できる: ◎ The element() function can be put to many uses. For example, it can be used to show a preview of the previous or next slide in a slideshow:
<!DOCTYPE html>
<script>
function navigateSlides() {
var %currentSlide = ...;
document.querySelector('#prev-slide').id = '';
document.querySelector('#next-slide').id = '';
%currentSlide.previousElementSibling.id = 'prev-slide';
%currentSlide.nextElementSibling.id = 'next-slide';
}
</script>
<style>
.slide {
/*
`element^f 可能になるためには、積層~文脈にする必要がある。
◎
Need to be a stacking context to be element()-able.
*/
position: relative;
}
#prev-preview, #next-preview {
position: fixed;
...
}
#prev-preview { background: element(#prev-slide); }
#next-preview { background: element(#next-slide); }
</style>
<a id='prev-preview'>前の~slide</a>
<a id='next-preview'>次の~slide</a>
<section class='slide'>...</section>
<section class='slide current-slide'>...</section>
...
この例の `navigateSlides()^c 関数は、次の/前の~slideの `id^a を更新する — それは、~slideの傍に浮動している小さい~box内に表示される。 `element$f 関数による~slideとは対話できないので(それは単なる画像である)、~preview~box上で `click^et ~handlerを利用して頁を~navigateし易くすることもできる。 ◎ In this example, the navigateSlides function updates the ids of the next and previous slides, which are then displayed in small floating boxes alongside the slides. Since you can’t interact with the slides through the element() function (it’s just an image), you could even use click handlers on the preview boxes to help navigate through the page.
2.6.1. 塗り~source
~host言語は、何らかの要素を `塗り~source@ を供するものとを定義して~MAY。 塗り~sourceは、内在的~外観を持ち,[ ~layoutする/描画- ]する必要なく`実obj~size$を得れるので、`描画され$ていなくとも画像として利用できる。 ◎ Host languages may define that some elements provide a paint source. Paint sources have an intrinsic appearance and can obtain a concrete object size without having to do layout or rendering, and so may be used as images even when they’re not rendered.
~HTMLにおいては、[ `img$e / `video$e / `canvas$e ]要素が塗り~sourceを供する。 ◎ In HTML, the img, video, and canvas elements provide paint sources.
~SVGにおいては、`塗り~server$を供する要素が,塗り~sourceを供する。 注記: SVG1.1 においては,[ `linearGradient$e, `radialGradient$e, `pattern$e ]要素が塗り~sourceを供する。 それらは,その仕様にて述べるように描かれる — 次に定義される座標系の下で: ◎ In SVG, any element that provides a paint server provides a paint source. Note: In SVG1.1, the <linearGradient>, <radialGradient>, and <pattern> elements provide paint sources. They are drawn as described in the spec, with the coordinate systems defined as follows:
- `objectBoundingBox^v
- 原点は,描かれている`実obj~size$により定義される矩形の左上隅。 寸法は,`実obj~size$と同じ。 1 `利用単位$は,`実obj~size$の横幅, 縦幅。 ◎ The coordinate system has its origin at the top left corner of the rectangle defined by the concrete object size that it’s being drawn into, and the same width and height as the concrete object size. A single user coordinate is the width and height of the concrete object size.
- `userSpaceOnUse^v
- 原点は,描かれている`実obj~size$により定義される矩形の左上隅。 寸法は,`実obj~size$と同じ。 1 `利用単位$は, 1 `px$u 単位に等価。 ◎ The coordinate system has its origin at the top left corner of the rectangle defined by the concrete object size that it’s being drawn into, and the same width and height as the concrete object size. User coordinates are sized equivalently to the CSS px unit.
注記: この~moduleの将来の~versionでは、[ 外部~文書~内の/ もっぱら~scriptにより作成され文書~内に全く挿入されない ]塗り~sourceを参照する仕方を定義することが期待されている。 ◎ Note: It is expected that a future version of this module will define ways to refer to paint sources in external documents, or ones that are created solely by script and never inserted into a document at all.
2.6.2. 文書~外~sourceの利用-法: `ElementSources^I ~interface
`element$f 関数は、通常は文書の中の要素を選択するが、`塗り~source$を供する要素は,必ずしも文書~内にある必要はない。 例えば、~scriptにより 作成され, 保守され, 描かれ,文書に直に挿入されてはいない~HTML `canvas$e 要素など。 ◎ The element() function normally selects elements within a document, but elements that provide a paint source don’t necessarily need to be in-document. For example, an HTML canvas element can be created, maintained, and drawn into entirely in script, with no need for it to be inserted into the document directly.
`~ID選択子$は,文書の外側にある要素は選択できないので、要素を参照する仕方が必要になる。 `elementSources$m ~map~objがこれを供する。 ◎ All that’s needed is a way to refer to the element, as an ID selector cannot select elements outside of the document. The elementSources Map object provides this.
partial namespace `CSS$I { [`SameObject$] readonly attribute Map `elementSources@m; };
IDL namespaces don’t support attributes yet. <https://github.com/w3c/csswg-drafts/issues/428>
`elementSources$m ~map内の~entryのうち,次を満たすものが、 `element$f 関数にて可用になる ⇒ [ 文字列を~keyとする ]~AND[ `塗り~source$を供している~objを値にとる ] ◎ Any entries in the elementSources map with a string key and a value that is an object providing a paint source are made available to the element() function.
`element$f に与えた `id-selector$t に対しては、先ず `elementSources$m ~map内で,~ID(先頭の文字 `#^c は含めない)が検索される: ◎ Whenever element() uses an <id-selector>, the ID’s value (without the leading # character) is first looked up in the elementSources map:
- ~IDを~keyとする~entryが見出された場合、 `element$f 関数は,~entryの値で与えられる~objが`塗り~source$を供して[ いるならば その塗り~source / いないならば`無効な画像$ ]を表現する。 ◎ If it’s found, and the object associated with it provides a paint source, the element() function represents that paint source. ◎ If it’s found, but the object associated with it doesn’t provide a paint source, the element() function represent an invalid image.
- 見出されなかった場合、通常通り,文書~内を探す。 ◎ If the ID isn’t found in the map at all, it’s then looked for in the document as normal.
この`~ID選択子$の再利用は、 Mozilla の挙動に合致する。 編集者は、文法の先頭を `custom-ident$t で塞ぐのは避けたいと~~考えている — それは構文空間を食い過ぎるので。 別の可能性として、値を言語により定義される~keywordから開始させ, `custom-ident$t を後続させる案も考えられる — `element(external fancy)^v か何かの様に。 何か命名の示唆があれば歓迎する。 ◎ This reuse of the ID selector matches Moz behavior. I’m trying to avoid slapping a <custom-ident> right in the beginning of the grammar, as that eats too much syntax-space. Another possibility, though, is to start the value with a language-defined keyword followed by a <custom-ident>, like element(external fancy) or something. Naming suggestions welcome.
外部~canvasを用いて~fancyな背景を~animateする例: ◎ For example, fancy animating backgrounds can be done with an external canvas:
<script> var %bg = document.createElement('canvas'); %bg.height = 200; %bg.width = 1000; drawFancyBackground(%bg); CSS.elementSources.set('fancy', %bg); </script> <style> h1 { background-image: element(#fancy); } </style>
“~fancy” ~canvasの中に何かが描かれ,~animateされるに伴い,すべての `h1^e 要素の背景も自動的かつ一斉に更新されることになる。 ◎ As the "fancy" canvas is drawn into and animated, the backgrounds of all the H1 elements will automatically update in tandem.
`elementSources$m ~mapは,文書に対し`~ID選択子$を照合する前にあたられるので、文書~内に `#fancy^v に合致する要素があっても,背景は依然として `elementSources$m 値から来ることに注意。 ◎ Note that the elementSources map is consulted before the document to match the ID selector, so even if there’s an element in the document that would match #fancy, the backgrounds will still predictably come from the elementSources value instead.
2.6.3. 循環の検出
`element$f 関数は、無為な循環関係を生産し得る — 自身を自前の背景に利用する要素など。 が,これらの関係性は、依存関係~graphを保ち続け, 共通的な循環~検出~algoを用いれば,容易かつ依拠-可能に検出して解決できる。 ◎ The element() function can produce nonsensical circular relationships, such as an element using itself as its own background. These relationships can be easily and reliably detected and resolved, however, by keeping track of a dependency graph and using common cycle-detection algorithms.
依存関係~graphは、次に挙げる辺からなる: ◎ The dependency graph consists of edges such that:
- どの要素も、その子たちに依存する。 ◎ every element depends on its children
- 要素 A 上のある~propが `element$f 関数を利用していて,要素 B を指しているならば、 A は B に依存する ◎ for any element A with a property using the element() function pointing to an element B, A depends on B
- ~host言語が,要素が他の要素の描画を参照する仕方を定義しているならば、参照元の要素は参照先の要素に依存する。 例えば,~SVGにおいては、 `use$e 要素は参照先の要素に依存する。 ◎ if a host language defines a way for elements to refer to the rendering of other elements, the referencing element depends on the referenced element. For example, in SVG, a <use> element depends on the element it referenced.
この~graphが循環を包含する場合、その循環に関与しているどの `element$f 関数も,`無効な画像$になる。 ◎ If the graph contains a cycle, any element() functions participating in the cycle are invalid images.
3. 勾配
【 この節の内容は未訳。 】
4. ~CSSにおける画像/~objの~sizing
注記: この節の他の内容は、 [css3-images] と 同じ。
4.1. ~objの~sizing: `object-fit^p ~prop
◎名 `object-fit@p ◎値 `fill$v | `none$v | [`contain$v | `cover$v] || `scale-down$v ◎初 `fill$v ◎適 `置換~要素$ ◎継 されない ◎百 受容しない ◎算 指定値 ◎順 文法に従う ◎ア 不可 ◎表終`object-fit$p ~propは、置換~要素の内容が,その使用~横縦幅により確立される~boxに,どのように収められるべきかを指定する。 ◎ The object-fit property specifies how the contents of a replaced element should be fitted to the box established by its used height and width.
【 以下、 ~level 3 の内容 と同じ部分 — “L3” と記されている箇所 — の和訳は省略する。 】
- `fill@v
- L3 ◎ The replaced content is sized to fill the element’s content box: the object’s concrete object size is the element’s used width and height.
- `none@v
- L3 ◎ The replaced content is not resized to fit inside the element’s content box: determine the object’s concrete object size using the default sizing algorithm with no specified size, and a default object size equal to the replaced element’s used width and height.
- `contain@v
- L3 ◎ The replaced content is sized to maintain its aspect ratio while fitting within the element’s content box: its concrete object size is resolved as a contain constraint against the element’s used width and height.
- `scale-down$v も併用された場合、内容は[ `none$v, `contain$v ]のうち,`実obj~size$が小さくなる方が指定されたかのように~sizeされる。 ◎ If the scale-down flag is used, size the content as if none or contain were specified, whichever would result in a smaller concrete object size.
- 注記: `none$v, `contain$v の両者とも内容の内在的~縦横比を保たせるので、大きさの比較は可能になる。 ◎ Note: Both none and contain respect the content’s intrinsic aspect ratio, so the concept of "smaller" is well-defined.
- `cover@v
- L3 ◎ The replaced content is sized to maintain its aspect ratio while filling the element’s entire content box: its concrete object size is resolved as a cover constraint against the element’s used width and height.
- `scale-down$v も併用された場合、内容は[ `none$v, `cover$v ]のうち,`実obj~size$が小さくなる方が指定されたかのように~sizeされる。 ◎ If the scale-down flag is used, size the content as if none or cover were specified, whichever would result in a smaller concrete object size.
- 注記: `none$v, `cover$v の両者とも内容の内在的~縦横比を保たせるので、大きさの比較は可能になる。 ◎ Note: Both none and cover respect the content’s intrinsic aspect ratio, so the concept of "smaller" is well-defined.
- `scale-down@v
- `contain scale-down^v と等価。 ◎ Equivalent to contain scale-down.
L3 ◎ If the content does not completely fill the replaced element’s content box, the unfilled space shows the replaced element’s background. Since replaced elements always clip their contents to the content box, the content will never overflow. See the object-position property for positioning the object with respect to the content box.
注記: L3 ◎ Note: The object-fit property has similar semantics to the fit attribute in [SMIL10] and the <meetOrSlice> parameter on the preserveAspectRatio attribute in [SVG11].
注記: L3 ◎ Note: Per the object size negotiation algorithm, the concrete object size (or, in this case, the size of the content) does not directly scale the object itself - it is merely passed to the object as information about the size of the visible canvas. How to then draw into that size is up to the image format. In particular, raster images always scale to the given size, while SVG uses the given size as the size of the "SVG Viewport" (a term defined by SVG) and then uses the values of several attributes on the root <svg> element to determine how to draw itself.
5. 画像~処理
5.1. 画像~解像度の上書き法: `image-resolution^p ~prop
`画像~解像度@ は、単位~長さあたりの画像~画素~数として定義される。 例えば、~inchあたりの画素~数。 画像~形式には、画像の解像度についての情報を記録するものもある。 この情報は、整形~処理-にあたって画像の実際の~sizeを決定する補助になり得るが、誤ったものにもなり得るので,その場合には,無視されるべきである。 ~CSSの既定では、 ~CSS `px$u 単位が 1 画像~画素に等しい解像度と見做すが、 `image-resolution$p ~propにより,他の解像度も利用できるようになる。 ◎ The image resolution is defined as the number of image pixels per unit length, e.g., pixels per inch. Some image formats can record information about the resolution of images. This information can be helpful when determining the actual size of the image in the formatting process. However, the information can also be wrong, in which case it should be ignored. By default, CSS assumes a resolution of one image pixel per CSS px unit; however, the image-resolution property allows using some other resolution.
◎名 `image-resolution@p ◎値 [ `from-image$v || `resolution$t ] && `snap$v? ◎初 `1dppx^v ◎適 すべての要素 ◎継 される ◎百 受容しない ◎算 指定値 — ただし, `snap$v の~~計算により `resolution$t が改められる場合(下記を見よ)は除く。 ◎ as specified, except with <resolution> possibly altered by computed for snap (see below) ◎順 文法に従う ◎ア 不可 ◎表終`image-set$f 記法は、画像の内在~解像度を改め得る — それは、この~propを設定しなくても,自動的に尊守されるのが理想的だが【?】。 これをどう~~解決すべきか? 初期値を、 “~CSSが他を~~指示しない限り `1dppx^v とする” を意味する `auto^v に変えるか? `image-resolution^p は、解像度が~CSSにおける他の何かで設定された画像には効果がないようにするか? あるいは、 `image-set$f を,それが常に何らかの方法で `1dppx^v 画像を生産するように,どうにか wordsmithing するか? ◎ The image-set() notation can alter the intrinsic resolution of an image, which ideally would be automatically honored without having to set this property. How should we best address this? Change the initial value to auto, meaning "1dppx, unless CSS says otherwise"? Say that image-resolution has no effect on images whose resolution was set by something else in CSS? Or somehow wordsmithing image-set() in some way such that it always produces 1dppx images somehow?
`image-resolution$p ~propは、[[ 要素~内/要素~上 ]で利用されるすべての~raster画像 ]の`内在~解像度$を,指定する。 それは、内容~画像(例えば,`置換~要素$や`生成内容$)にも, 装飾的な画像( `background-image$p など)にも影響する。 画像の `内在~解像度@ は、画像の`内在~寸法$を決定するために利用される。 各種 値の意味は: ◎ The image-resolution property specifies the intrinsic resolution of all raster images used in or on the element. It affects both content images (e.g. replaced elements and generated content) and decorative images (such as background-image). The intrinsic resolution of an image is used to determine the image’s intrinsic dimensions. Values have the following meanings:
- `resolution$t
- 内在~解像度を数値的に指定する。 この場合の 1 “~dot” は, 1 画像~画素に対応する。 ◎ Specifies the intrinsic resolution explicitly. A "dot" in this case corresponds to a single image pixel.
- 【 すなわち、[ `css-values-3$r による `resolution^t の定義 ]に記されている “~dot” は 1 画像~画素と解釈される。 】
- `from-image@v
- 画像の内在~解像度は、画像~形式から指定される。 画像が自前の解像度を指定していない場合、 `resolution$t が明示的に指定されていれば,それが利用され、他の場合は既定の `1dppx^v になる。 ◎ The image’s intrinsic resolution is taken as that specified by the image format. If the image does not specify its own resolution, the explicitly specified resolution is used (if given), else it defaults to 1dppx.
- `snap@v
- この~keywordが伴われている `resolution$t は、 1 画像~画素が機器~画素の整数~倍に対応するような,最も近い値に丸めた結果に算出される。 解像度が画像からとられる【 `from-image$v が供されている】場合、内在~解像度の使用値は,画像~自身による解像度を同様に調整した結果になる。 ◎ If the "snap" keyword is provided, the computed <resolution> (if any) is the specified resolution rounded to the nearest value that would map one image pixel to an integer number of device pixels. If the resolution is taken from the image, then the used intrinsic resolution is the image’s native resolution similarly adjusted.
SVG などの~vector形式には、内在~解像度はない。 この~propは、~vector画像には効果がない。 ◎ As vector formats such as SVG do not have an intrinsic resolution, this property has no effect on vector images.
印刷機の解像度は、~computer-monitorより,かなり高いのが常なので、~screen上ではきれいな画像でも,印刷~時には画素が目立つ。 `image-resolution$p ~propを利用すれば、文書~内に高~解像度の画像を埋込んで 適切な~sizeを保守しつつ,~screen上でも紙~上でも美麗に表示できるようになる: ◎ Printers tend to have substantially higher resolution than computer monitors; due to this, an image that looks fine on the screen may look pixellated when printed out. The image-resolution property can be used to embed a high-resolution image into the document and maintain an appropriate size, ensuring attractive display both on screen and on paper:
img.high-res { image-resolution: 300dpi; }
この規則の下では、 300dpi で 5 ~inch幅になるようにされた画像は,実際に 5 ~inch幅で表示されることになる。 この規則が無い下では、~CSSの既定による 1 ~inchあたり 96 画像~画素の表示になるので、画像は[ 300 × 5 ÷ 96 = 約 15.6 ]~inch幅で表示されることになる。 ◎ With this set, an image meant to be 5 inches wide at 300dpi will actually display as 5in wide; without this set, the image would display as approximately 15.6in wide since the image is 15000 image pixels across, and by default CSS displays 96 image pixels per inch.
画像~形式には、自身の~data内に解像度を符号化するものもある。 次の規則は、~UAが,解像度を画像~自身から見出すように指定する — 見出されない場合、~CSS `px$u 単位あたり 1 画像~画素に~fallbackする。 ◎ Some image formats can encode the image resolution into the image data. This rule specifies that the UA should use the image resolution found in the image itself, falling back to 1 image pixel per CSS px unit.
img { image-resolution: from-image }
次の規則は、~UAが,解像度を画像~自身から見出すように指定しつつ、見出せないときは,解像度を既定の `1dppx^v でなく `300dpi^v に設定する。 ◎ These rules both specify that the UA should use the image resolution found in the image itself, but if the image has no resolution, the resolution is set to 300dpi instead of the default 1dppx.
img { image-resolution: from-image 300dpi } img { image-resolution: 300dpi from-image }
次の規則は、画像~解像度を 300dpi に設定する(画像~自身の解像度は,無視される)。 ◎ Using this rule, the image resolution is set to 300dpi. (The resolution in the image, if any, is ignored.)
img { image-resolution: 300dpi }
一方で,次の規則では、~screen解像度が 96dpi の下であれば,画像を解像度 288dpi で描画することになる( 3 画像~画素が 1 機器~画素に対応する): ◎ This rule, on the other hand, if used when the screen’s resolution is 96dpi, would instead render the image at 288dpi (so that 3 image pixels map to 1 device pixel):
img { image-resolution: 300dpi snap; }
`snap$v ~keywordは、解像度が画像から取得されるときにも利用できる: ◎ The snap keyword can also be used when the resolution is taken from the image:
img { image-resolution: snap from-image; }
画像~自身に備わる解像度が 300dpi のときには 288dpi で描画する( 3 画像~画素が 1 機器~画素に対応する)一方で、 72dpi のときには 96dpi で描画することになる( 1 画像~画素が 1 機器~画素に対応する)。 ◎ An image declaring itself as 300dpi will, in the situation above, display at 288dpi (3 image pixels per device pixel) whereas an image declaring 72dpi will render at 96dpi (1 image pixel per device pixel).
6. 補間
`interpolation^L37. 直列化
`serialization^L3~privacy/~security上の考慮点
`privsec^L3変更点
2012 年 9 月 11 日付 作業草案 からの変更点は: ◎ Changes Since the 11 September 2012 Working Draft
- 色~補間~hint を追加した。 ◎ Added color interpolation hints
- 勾配の色停に 2 個の所在による構文 を追加した。 ◎ Added the two location syntax for gradient color stops
- `円錐型~勾配$に開始-角度を追加した。 ◎ Added start angles to conic gradients
- 色停の位置(たち)は、今や色より前にも来れる ◎ The position(s) of a color stop can now come before the color
- `css3-images$r に一致する~textは、 `css3-images$r への参照に置換した。 ◎ Text that is identical to [css3-images] has been replaced with a reference to [css3-images].
~Level 3 からの変更点は: ◎ Changes Since Level 3
- (~level 3 から先送りされた) `image$f 記法を追加した。 ◎ Added the image() notation (deferred from Level 3)
- (~level 3 から先送りされた) `image-resolution$p ~propを追加した。 ◎ Added the image-resolution property (deferred from Level 3)
- (~level 3 から先送りされた) `element$f 記法を追加した。 ◎ Added the element() notation (deferred from Level 3)
- `円錐型~勾配$を追加した。 ◎ Added conic gradients