@@ -250,6 +250,13 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
250250
251251 < li > < a href ="#transform-functions "> < span class =secno > 12. </ span > The
252252 Transformation Functions </ a >
253+ < ul class =toc >
254+ < li > < a href ="#two-d-transform-functions "> < span class =secno > 12.1.
255+ </ span > 2D Transformation Functions</ a >
256+
257+ < li > < a href ="#three-d-transform-functions "> < span class =secno > 12.2.
258+ </ span > 3D Transformation Functions</ a >
259+ </ ul >
253260
254261 < li > < a href ="#transform-values "> < span class =secno > 13. </ span > Transform
255262 Values and Lists </ a >
@@ -434,7 +441,49 @@ <h2 id=transform-rendering><span class=secno>5. </span>The Transform
434441 towards the viewer.
435442
436443 < p > Transforms apply to < a href ="#TermTransformableElement "> transformable
437- elements</ a > .</ p >
444+ elements</ a > .
445+
446+ < div class =example >
447+ < pre >
448+ div {
449+ transform: translate(100px, 100px);
450+ }
451+ </ pre >
452+
453+ < p > This transform moves the element by 100 pixels in both the X and Y
454+ directions.</ p >
455+
456+ < div class =figure > < img alt ="The 100px translation in X and Y "
457+ src =transform1.png > </ div >
458+ </ div >
459+
460+ < div class =example >
461+ < pre >
462+ div {
463+ height: 100px; width: 100px;
464+ transform: translate(80px, 80px) scale(1.5, 1.5) rotate(45deg);
465+ }
466+ </ pre >
467+
468+ < p > Move the element by 80 pixels in both the X and Y directions, then
469+ scale the element by 150%, then rotate it 45 degrees clockwise about the
470+ Z axis. Note that the scale and rotate operate about the center of the
471+ element, since the element has the default transform-origin of 50% 50%.</ p >
472+
473+ < div class =figure > < img alt ="The transform specified above "
474+ src ="compound_transform.png "> </ div >
475+
476+ < p > Note that an identical rendering can be obtained by nesting elements
477+ with the equivalent transforms:
478+
479+ < pre >
480+ <div style="transform: translate(80px, 80px)">
481+ <div style="transform: scale(1.5, 1.5)">
482+ <div style="transform: rotate(45deg)"></div>
483+ </div>
484+ </div>
485+ </ pre >
486+ </ div >
438487 <!-- This "in the HTML namespace" is awkward. Is there a better way? -->
439488
440489 < p > In the HTML namespace, the transform property does not affect the flow
@@ -509,11 +558,11 @@ <h3 id=transform-3d-rendering><span class=secno>5.1. </span>3D Transform
509558</div>
510559</ pre >
511560
512- < p > The transform is a 50° rotation about the vertical Y axis. Note how
513- this makes the gray box appear narrower, but not three-dimensional.</ p >
514-
515561 < div class =figure > < img alt ="Div with a rotateY transform. " height =190
516562 src ="examples/simple-3d-example.png " width =210 > </ div >
563+
564+ < p > The transform is a 50° rotation about the vertical, Y axis. Note
565+ how this makes the blue box appear narrower, but not three-dimensional.</ p >
517566 </ div >
518567
519568 < div class =example >
@@ -532,15 +581,16 @@ <h3 id=transform-3d-rendering><span class=secno>5.1. </span>3D Transform
532581</div>
533582</ pre >
534583
535- < p > The inner element has the same transform as before, but its rendering
536- is now influenced by the perspective property on its parent element.
537- Perspective causes vertices that have positive Z coordinates (closer to
538- the viewer) to be scaled up in X and Y, and those futher away (negative Z
539- coordinates) to be scaled down.</ p >
540-
541584 < div class =figure > < img
542- alt ="Div with a rotateY transform, and perspective on its container "
585+ alt ="Div with a rotateY transform, and perspective on its container "
543586 height =190 src ="examples/simple-perspective-example.png " width =210 > </ div >
587+
588+ < p > The inner element has the same transform as in Example 1, but its
589+ rendering is now influenced by the perspective property on its parent
590+ element. Perspective causes vertices that have positive Z coordinates
591+ (closer to the viewer) to be scaled up in X and Y, and those futher away
592+ (negative Z coordinates) to be scaled down, giving an appearance of
593+ depth.</ p >
544594 </ div >
545595
546596 < p > An element with a three-dimensional transform that is contained in a
@@ -1219,6 +1269,9 @@ <h2 id=transform-functions><span class=secno>12. </span> The Transformation
12191269 that is equal to zero is also allowed, which is treated the same as an
12201270 angle of zero degrees.
12211271
1272+ < h3 id =two-d-transform-functions > < span class =secno > 12.1. </ span > 2D
1273+ Transformation Functions</ h3 >
1274+
12221275 < dl >
12231276 < dt > < span class =prop-value > matrix(<number>, <number>,
12241277 <number>, <number>, <number>, <number>)</ span >
@@ -1295,6 +1348,101 @@ <h2 id=transform-functions><span class=secno>12. </span> The Transformation
12951348 transformation along the Y axis</ a > by the given angle.
12961349 </ dl >
12971350
1351+ < h3 id =three-d-transform-functions > < span class =secno > 12.2. </ span > 3D
1352+ Transformation Functions</ h3 >
1353+
1354+ < dl >
1355+ < dt > < span class =prop-value > matrix3d(<number>, <number>,
1356+ <number>, <number>, <number>, <number>,
1357+ <number>, <number>, <number>, <number>,
1358+ <number>, <number>, <number>, <number>,
1359+ <number>, <number>)</ span >
1360+
1361+ < dd > specifies a 3D transformation as a 4x4 homogeneous matrix of 16
1362+ values in column-major order.
1363+
1364+ < dt > < span class =prop-value > translate3d(<translation-value>,
1365+ <translation-value>, <translation-value>)</ span >
1366+
1367+ < dd > specifies a 3D translation by the vector [tx,ty,tz], with tx, ty and
1368+ tz being the first, second and third translation-value parameters
1369+ respectively. <Percentage> values are not allowed in the tz
1370+ translation-value, and if present will cause the propery value to be
1371+ invalid.
1372+
1373+ < dt > < span class =prop-value > translateZ(<translation-value>)</ span >
1374+
1375+ < dd > specifies a < a
1376+ href ="http://www.w3.org/TR/SVG/coords.html#TranslationDefined "> translation</ a >
1377+ by the given amount in the Z direction. <Percentage> values are not
1378+ allowed in the translateZ translation-value, and if present will cause
1379+ the propery value to be invalid.
1380+
1381+ < dt > < span class =prop-value > scale3d(<number>, <number>,
1382+ <number>)</ span >
1383+
1384+ < dd > specifies a 3D scale operation by the [sx,sy,sz] scaling vector
1385+ described by the 3 parameters.
1386+
1387+ < dt > < span class =prop-value > scaleZ(<number>)</ span >
1388+
1389+ < dd > specifies a scale operation using the [1,1,sz] scaling vector, where
1390+ sz is given as the parameter.
1391+
1392+ < dt > < span class =prop-value > rotate3d(<number>, <number>,
1393+ <number>, <angle>)</ span >
1394+ </ dl >
1395+
1396+ < div class =todo > Clarify "clockwise". Describe in terms of right-hand rule?</ div >
1397+
1398+ < dl >
1399+ < dd > specifies a clockwise 3D rotation by the angle specified in last
1400+ parameter about the [x,y,z] direction vector described by the first 3
1401+ parameters. If the direction vector is not of unit length, it will be
1402+ normalized. A direction vector that cannot be normalized, such as [0, 0,
1403+ 0], will cause the rotation to not be applied. This function is
1404+ equivalent to < code > matrix3d(1 + (1-cos(angle))*(x*x-1),
1405+ -z*sin(angle)+(1-cos(angle))*x*y, y*sin(angle)+(1-cos(angle))*x*z, 0,
1406+ z*sin(angle)+(1-cos(angle))*x*y, 1 + (1-cos(angle))*(y*y-1),
1407+ -x*sin(angle)+(1-cos(angle))*y*z, 0, -y*sin(angle)+(1-cos(angle))*x*z,
1408+ x*sin(angle)+(1-cos(angle))*y*z, 1 + (1-cos(angle))*(z*z-1), 0, 0, 0, 0,
1409+ 1)</ code > .
1410+
1411+ < dt > < span class =prop-value > rotateX(<angle>)</ span >
1412+
1413+ < dd > specifies a clockwise rotation by the given angle about the X axis.
1414+
1415+ < dt > < span class =prop-value > rotateY(<angle>)</ span >
1416+
1417+ < dd > specifies a clockwise rotation by the given angle about the Y axis.
1418+
1419+ < dt > < span class =prop-value > rotateZ(<angle>)</ span >
1420+
1421+ < dd > specifies a clockwise rotation by the given angle about the Z axis.
1422+ This is a synonym for < span
1423+ class =prop-value > rotate(<angle>)</ span > .
1424+
1425+ < dt > < span class =prop-value > perspective(<length>)</ span >
1426+
1427+ < dd > specifies a perspective projection matrix. This matrix maps a
1428+ < em > viewing cube</ em > onto a pyramid whose base is infinitely far away
1429+ from the viewer and whose peak represents the viewer's position. The
1430+ viewable area is the region bounded by the four edges of the viewport
1431+ (the portion of the browser window used for rendering the webpage between
1432+ the viewer's position and a point at a distance of infinity from the
1433+ viewer). The < em > depth</ em > , given as the parameter to the function,
1434+ represents the distance of the z=0 plane from the viewer. Lower values
1435+ give a more flattened pyramid and therefore a more pronounced perspective
1436+ effect. For example, a value of 1000px gives a moderate amount of
1437+ foreshortening and a value of 200px gives an extreme amount. The matrix
1438+ is computed by starting with an identity matrix and replacing the value
1439+ at row 3, column 4 with the value -1/depth. The value for depth must be
1440+ greater than zero, otherwise the function is invalid.
1441+ < div class =issue > I think "viewport" is wrong here. It's the border box of
1442+ the element with perspective.</ div >
1443+ </ dl >
1444+ <!-- ======================================================================================================= -->
1445+
12981446 < h2 id =transform-values > < span class =secno > 13. </ span > Transform Values and
12991447 Lists</ h2 >
13001448
@@ -1306,52 +1454,26 @@ <h2 id=transform-values><span class=secno>13. </span> Transform Values and
13061454 example,
13071455
13081456 < pre >
1309- <div style="transform:translate(-10px,-20px) scale(2) rotate(45deg) translate(5px,10px)"/>
1310- </ pre >
1457+ <div style="transform:translate(-10px,-20px) scale(2) rotate(45deg) translate(5px,10px)"/>
1458+ </ pre >
13111459
13121460 < p > is functionally equivalent to:
13131461
13141462 < pre >
1315- <div style="transform:translate(-10px,-20px)">
1316- <div style="transform:scale(2)">
1317- <div style="transform:rotate(45deg)">
1318- <div style="transform:translate(5px,10px)">
1319- </div>
1320- </div>
1321- </div>
1322- </div>
1323- </ pre >
1463+ <div style="transform:translate(-10px,-20px)">
1464+ <div style="transform:scale(2)">
1465+ <div style="transform:rotate(45deg)">
1466+ <div style="transform:translate(5px,10px)">
1467+ </div>
1468+ </div>
1469+ </div>
1470+ </div>
1471+ </ pre >
13241472
13251473 < p > That is, in the absence of other styling that affects position and
13261474 dimensions, a nested set of transforms is equivalent to a single list of
13271475 transform functions, applied from the outside in. The resulting transform
1328- is the matrix multiplication of the list of transforms.
1329-
1330- < div class =example >
1331- < pre >
1332- div {
1333- transform: translate(100px, 100px);
1334- }
1335- </ pre >
1336- Move the element by 100 pixels in both the X and Y directions.
1337- < div class =figure > < img alt ="The 100px translation in X and Y "
1338- src =transform1.png > </ div >
1339- </ div >
1340-
1341- < div class =example >
1342- < pre >
1343- div {
1344- height: 100px; width: 100px;
1345- transform: translate(80px, 80px) scale(1.5, 1.5) rotate(45deg);
1346- }
1347- </ pre >
1348- Move the element by 80 pixels in both the X and Y directions, then scale
1349- the element by 150%, then rotate it 45 degrees clockwise about the Z axis.
1350- Note that the scale and rotate operate about the center of the element,
1351- since the element has the default transform-origin of 50% 50%.
1352- < div class =figure > < img alt ="The transform specified above "
1353- src ="compound_transform.png "> </ div >
1354- </ div >
1476+ is the matrix multiplication of the list of transforms.</ p >
13551477 <!-- ======================================================================================================= -->
13561478
13571479 < h2 id =animation > < span class =secno > 14. </ span > Transitions and animations
0 commit comments