Skip to content

Commit a3ee3a2

Browse files
committed
[css-images] Per WG resolution, punt interpolation of images to level 4.
1 parent ab20b4c commit a3ee3a2

File tree

2 files changed

+153
-135
lines changed

2 files changed

+153
-135
lines changed

css-images-3/Overview.bs

Lines changed: 9 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Abstract: This module contains the features of CSS level 3 relating to the <<ima
1717
definitions for interpolating several <<image>> types,
1818
and several properties controlling the interaction of replaced elements and CSS's layout models.
1919
At Risk: 'image-orientation'
20-
At Risk: [[#interpolating-gradients]]
21-
At Risk: recursive interpolation of ''cross-fade()'' arguments
2220
Issue Tracking: Tracker http://www.w3.org/Style/CSS/Tracker/products/27
2321
Previous Version: https://www.w3.org/TR/2012/CR-css3-images-20120417/
2422
Previous Version: https://www.w3.org/TR/2012/WD-css3-images-20120112/
@@ -93,10 +91,7 @@ Image Values: the <<image>> type {#image-values}
9391

9492
The <<image>> value type denotes a 2D image.
9593
It can be a
96-
<a href="#url-notation">url reference</a>,
97-
a <a href="#cross-fade-function">cross-fade expression combining two images</a>,
98-
<!-- an <a href="#image-notation">image notation</a>, -->
99-
<!-- <a href="#element-reference">element reference</a>, -->
94+
<a href="#url-notation">url reference</a>
10095
or a <a href="#gradients">color gradient</a>.
10196
Its syntax is:
10297

@@ -966,7 +961,7 @@ Sizing Images and Objects in CSS {#sizing}
966961
As well, a document may contain many other types of objects,
967962
such as video, plugins, or nested documents.
968963
These images and objects
969-
(just <dfn noexport lt local-lt=object>objects</dfn> hereafter)
964+
(just <dfn noexport local-lt=object>objects</dfn> hereafter)
970965
may offer many types of sizing information to CSS,
971966
or none at all.
972967
This section defines generically the size negotiation model between the object and the CSS layout algorithms.
@@ -1590,127 +1585,13 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
15901585
Interpolation {#interpolation}
15911586
==============================
15921587

1593-
This section describes how to interpolate between new value types defined in this specification,
1594-
for use with modules such as CSS Transitions and CSS Animations.
1595-
1596-
If an algorithm below simply states that two values should be "interpolated" or "transitioned" without further details,
1597-
then the value should be interpolated as described by the Transitions spec.
1598-
Otherwise, the algorithm may reference a variable <var>t</var>
1599-
in its detailed description of the interpolation.
1600-
This is a number which starts at 0% and goes to 100%,
1601-
and is set to a value that represents the progress through the transition,
1602-
based on the duration of the transition,
1603-
the elapsed time,
1604-
and the timing function in use.
1605-
For example, with a linear timing function and a 1s duration,
1606-
after .3s <var>t</var> is equal to 30%.
1607-
1608-
Interpolating <<image>> {#interpolating-images}
1609-
-----------------------------------------------
1610-
1611-
All images can be interpolated,
1612-
though some special types of images
1613-
(like some gradients)
1614-
have their own special interpolation rules.
1615-
In general terms,
1616-
images are interpolated by scaling them to the size of the start image
1617-
and cross-fading the two while they transition to the size of the end image.
1618-
1619-
In specific terms,
1620-
at each point in the interpolation
1621-
the image is equal to <code>cross-fade( (100% - <var>t</var>) <var>start image</var>, <var>end image</var>)</code>.
1622-
1623-
Issue: Special-case interpolating to/from no image,
1624-
like "background-image: url(foo);" to "background-image: none;".
1625-
1626-
1627-
Interpolating cross-fade() {#interpolating-image-combinations}
1628-
--------------------------------------------------------------
1629-
1630-
The three components of ''cross-fade()'' are interpolated independently.
1631-
Note this may result in nested ''cross-fade()'' notations.
1632-
1633-
Interpolating <<gradient>> {#interpolating-gradients}
1634-
-----------------------------------------------------
1635-
1636-
Issue: This section needs review and improvement.
1637-
In particular, I believe the handling of linear-gradient() is incomplete -
1638-
I think we want to specifically interpolate the "length" of the gradient line
1639-
(the distance between 0% and 100%)
1640-
between the starting and ending positions explicitly,
1641-
so it doesn't grow and then shrink over a single animation.
1642-
1643-
Gradient images can be interpolated directly in CSS transitions and animations,
1644-
smoothly animating from one gradient to another.
1645-
There are only a few restrictions on what gradients are allowed to be interpolated:
1646-
1647-
1. Both the starting and ending gradient must be expressed with the same function.
1648-
(For example, you can transition from a ''linear-gradient()'' to a ''linear-gradient()'',
1649-
but not from a ''linear-gradient()'' to a ''radial-gradient()'' or a ''repeating-linear-gradient()''.)
1650-
1651-
2. Both the starting and ending gradient must have the same number of <<color-stop>>s.
1652-
For this purpose, all repeating gradients are considered to have infinite color stops,
1653-
and thus all repeating gradients match in this respect.
1654-
1655-
3. Neither gradient uses a combination of <<length>> and <<percentage>> color stops.
1656-
1657-
If the two gradients satisfy all of those constraints,
1658-
they must be interpolated as described below.
1659-
If they fail the third one only,
1660-
they must be abruptly transitioned at 50%
1661-
(unless otherwise specified by a future specification).
1662-
If they fail either of the first two constraints,
1663-
they must be interpolated using ''cross-fade()''
1664-
as for generic images.
1665-
1666-
Note: The abrupt transition at 50% is so that content will not rely on cross-fading,
1667-
and smarter interpolation rules can be added for this case in the future.
1668-
1669-
1. Convert both the start and end gradients to their explicit forms:
1670-
1671-
: For linear gradients:
1672-
:: * If the direction is specified as an <<angle>>,
1673-
it is already in its explicit form.
1674-
1675-
* Otherwise,
1676-
change its direction to an <<angle>> in [''0deg'',''360deg'')
1677-
that would produce an equivalent rendering.
1678-
1679-
If both the start and end gradients had their direction specified with keywords,
1680-
and the absolute difference between the angles their directions mapped to is greater than 180deg,
1681-
add 360deg to the direction of the gradient with the smaller angle.
1682-
<span class='note'>This ensures that a transition from, for example,
1683-
"to left" (270deg) to "to top" (0deg)
1684-
rotates the gradient a quarter-turn clockwise,
1685-
as expected,
1686-
rather than rotating three-quarters of a turn counter-clockwise.</span>
1687-
1688-
: For radial gradients:
1689-
:: * If the size is specified as two <<length>>s or <<percentage>>s,
1690-
it is already in its explicit form.
1691-
1692-
* Otherwise, the size must be changed to a pair of <<length>>s
1693-
that would produce an equivalent ending-shape.
1694-
If the <<ending-shape>> was specified as ''circle'',
1695-
change it to ''ellipse''.
1696-
1697-
2. Interpolate each component and color-stop of the gradients independently.
1698-
For linear gradients,
1699-
the only component is the angle.
1700-
For radial gradients,
1701-
the components are the horizontal and vertical position of the center
1702-
and the horizontal and vertical axis lengths.
1703-
1704-
3. To interpolate a color-stop,
1705-
first match each color-stop in the start gradient
1706-
to the corresponding color-stop at the same index in the end gradient.
1707-
For repeating gradients,
1708-
the first specified color-stop in the start and end gradients
1709-
are considered to be at the same index,
1710-
and all other color-stops following and preceding are indexed appropriately,
1711-
repeating and shifting each gradient's list of color-stops as needed.
1712-
Then, for each pair of color-stops,
1713-
interpolate the position and color independently.
1588+
Interpolation of <<image>> values is not defined in this level.
1589+
Implementations must abruptly transition them
1590+
(at 50% transition progress, like other unsupported interpolations),
1591+
unless otherwise defined by a future specification.
1592+
1593+
Note: CSS Images Level 4 is expected to define specialized interpolation for gradients,
1594+
and define that all other images interpolate by cross-fading.
17141595

17151596
<!--
17161597
██████ ████████ ████████ ████ ███ ██ ████ ████████ ███ ████████ ████ ███████ ██ ██
@@ -1735,9 +1616,6 @@ Serialization {#serialization}
17351616
joining space-separated tokens with a single space,
17361617
and following each serialized comma with a single space.
17371618

1738-
For ''cross-fade()'',
1739-
always serialize the <<percentage>>.
1740-
17411619
<div class='example'>
17421620
For example, a gradient specified as:
17431621

@@ -1781,8 +1659,6 @@ Changes Since the <a href="https://www.w3.org/TR/2012/CR-css3-images-20120417/">
17811659
and the <<angle>> values deprecated.
17821660
- Added the 'image-rendering' property
17831661
- Added the ''cross-fade()'' notation
1784-
- Defined <a href="#interpolation">Interpolation</a>
1785-
- Defined <a href="#serialization">Serialization</a>
17861662

17871663
<h3 class=no-num id=changes-last-call>
17881664
Changes Since Last Call</h3>

css-images-4/Overview.bs

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,7 @@ Overriding Image Resolutions: the 'image-resolution' property {#the-image-resolu
18251825
(1 image pixel per device pixel).
18261826
</div>
18271827

1828+
18281829
<!--
18291830
████ ██ ██ ████████ ████████ ████████ ████████ ███████ ██ ███ ████████ ████ ███████ ██ ██
18301831
██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
@@ -1838,7 +1839,127 @@ Overriding Image Resolutions: the 'image-resolution' property {#the-image-resolu
18381839
Interpolation {#interpolation}
18391840
==============================
18401841

1841-
Note: No change from [[css3-images]].
1842+
This section describes how to interpolate between new value types defined in this specification,
1843+
for use with modules such as CSS Transitions and CSS Animations.
1844+
1845+
If an algorithm below simply states that two values should be "interpolated" or "transitioned" without further details,
1846+
then the value should be interpolated as described by the Transitions spec.
1847+
Otherwise, the algorithm may reference a variable <var>t</var>
1848+
in its detailed description of the interpolation.
1849+
This is a number which starts at 0% and goes to 100%,
1850+
and is set to a value that represents the progress through the transition,
1851+
based on the duration of the transition,
1852+
the elapsed time,
1853+
and the timing function in use.
1854+
For example, with a linear timing function and a 1s duration,
1855+
after .3s <var>t</var> is equal to 30%.
1856+
1857+
Interpolating <<image>> {#interpolating-images}
1858+
-----------------------------------------------
1859+
1860+
All images can be interpolated,
1861+
though some special types of images
1862+
(like some gradients)
1863+
have their own special interpolation rules.
1864+
In general terms,
1865+
images are interpolated by scaling them to the size of the start image
1866+
and cross-fading the two while they transition to the size of the end image.
1867+
1868+
In specific terms,
1869+
at each point in the interpolation
1870+
the image is equal to <code>cross-fade( (100% - <var>t</var>) <var>start image</var>, <var>end image</var>)</code>.
1871+
1872+
Issue: Special-case interpolating to/from no image,
1873+
like "background-image: url(foo);" to "background-image: none;".
1874+
1875+
1876+
Interpolating cross-fade() {#interpolating-image-combinations}
1877+
--------------------------------------------------------------
1878+
1879+
The three components of ''cross-fade()'' are interpolated independently.
1880+
Note this may result in nested ''cross-fade()'' notations.
1881+
1882+
Interpolating <<gradient>> {#interpolating-gradients}
1883+
-----------------------------------------------------
1884+
1885+
Issue: This section needs review and improvement.
1886+
In particular, I believe the handling of linear-gradient() is incomplete -
1887+
I think we want to specifically interpolate the "length" of the gradient line
1888+
(the distance between 0% and 100%)
1889+
between the starting and ending positions explicitly,
1890+
so it doesn't grow and then shrink over a single animation.
1891+
1892+
Gradient images can be interpolated directly in CSS transitions and animations,
1893+
smoothly animating from one gradient to another.
1894+
There are only a few restrictions on what gradients are allowed to be interpolated:
1895+
1896+
1. Both the starting and ending gradient must be expressed with the same function.
1897+
(For example, you can transition from a ''linear-gradient()'' to a ''linear-gradient()'',
1898+
but not from a ''linear-gradient()'' to a ''radial-gradient()'' or a ''repeating-linear-gradient()''.)
1899+
1900+
2. Both the starting and ending gradient must have the same number of <<color-stop>>s.
1901+
For this purpose, all repeating gradients are considered to have infinite color stops,
1902+
and thus all repeating gradients match in this respect.
1903+
1904+
3. Neither gradient uses a combination of <<length>> and <<percentage>> color stops.
1905+
1906+
If the two gradients satisfy all of those constraints,
1907+
they must be interpolated as described below.
1908+
If they fail the third one only,
1909+
they must be abruptly transitioned at 50%
1910+
(unless otherwise specified by a future specification).
1911+
If they fail either of the first two constraints,
1912+
they must be interpolated using ''cross-fade()''
1913+
as for generic images.
1914+
1915+
Note: The abrupt transition at 50% is so that content will not rely on cross-fading,
1916+
and smarter interpolation rules can be added for this case in the future.
1917+
1918+
1. Convert both the start and end gradients to their explicit forms:
1919+
1920+
: For linear gradients:
1921+
:: * If the direction is specified as an <<angle>>,
1922+
it is already in its explicit form.
1923+
1924+
* Otherwise,
1925+
change its direction to an <<angle>> in [''0deg'',''360deg'')
1926+
that would produce an equivalent rendering.
1927+
1928+
If both the start and end gradients had their direction specified with keywords,
1929+
and the absolute difference between the angles their directions mapped to is greater than 180deg,
1930+
add 360deg to the direction of the gradient with the smaller angle.
1931+
<span class='note'>This ensures that a transition from, for example,
1932+
"to left" (270deg) to "to top" (0deg)
1933+
rotates the gradient a quarter-turn clockwise,
1934+
as expected,
1935+
rather than rotating three-quarters of a turn counter-clockwise.</span>
1936+
1937+
: For radial gradients:
1938+
:: * If the size is specified as two <<length>>s or <<percentage>>s,
1939+
it is already in its explicit form.
1940+
1941+
* Otherwise, the size must be changed to a pair of <<length>>s
1942+
that would produce an equivalent ending-shape.
1943+
If the <<ending-shape>> was specified as ''circle'',
1944+
change it to ''ellipse''.
1945+
1946+
2. Interpolate each component and color-stop of the gradients independently.
1947+
For linear gradients,
1948+
the only component is the angle.
1949+
For radial gradients,
1950+
the components are the horizontal and vertical position of the center
1951+
and the horizontal and vertical axis lengths.
1952+
1953+
3. To interpolate a color-stop,
1954+
first match each color-stop in the start gradient
1955+
to the corresponding color-stop at the same index in the end gradient.
1956+
For repeating gradients,
1957+
the first specified color-stop in the start and end gradients
1958+
are considered to be at the same index,
1959+
and all other color-stops following and preceding are indexed appropriately,
1960+
repeating and shifting each gradient's list of color-stops as needed.
1961+
Then, for each pair of color-stops,
1962+
interpolate the position and color independently.
18421963

18431964
<!--
18441965
██████ ████████ ████████ ████ ███ ██ ████ ████████ ███ ████████ ████ ███████ ██ ██
@@ -1853,7 +1974,28 @@ Note: No change from [[css3-images]].
18531974
Serialization {#serialization}
18541975
==============================
18551976

1856-
Note: No change from [[css3-images]].
1977+
This section describes the serialization of all new properties and value types introduced in this specification,
1978+
for the purpose of interfacing with the CSS Object Model [[CSSOM]].
1979+
1980+
To serialize any function defined in this module,
1981+
serialize it per its individual grammar,
1982+
in the order its grammar is written in,
1983+
omitting components when possible without changing the meaning,
1984+
joining space-separated tokens with a single space,
1985+
and following each serialized comma with a single space.
1986+
1987+
For ''cross-fade()'',
1988+
always serialize the <<percentage>>.
1989+
1990+
<div class='example'>
1991+
For example, a gradient specified as:
1992+
1993+
<pre>Linear-Gradient( to bottom, red 0%,yellow,black 100px)</pre>
1994+
1995+
must serialize as:
1996+
1997+
<pre>linear-gradient(red, yellow, black 100px)</pre>
1998+
</div>
18571999

18582000
Privacy and Security Considerations {#privsec}
18592001
==============================================

0 commit comments

Comments
 (0)