forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.html
More file actions
3098 lines (2497 loc) · 128 KB
/
Overview.html
File metadata and controls
3098 lines (2497 loc) · 128 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang=en>
<head profile="http://www.w3.org/2006/03/hcard"><meta
content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Transforms</title>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<script defer
src="http://test.csswg.org/harness/annotate.js#CSS3-TRANSFORMS_DEV"
type="text/javascript"></script>
<style type="text/css">
.term {
font-style: italic;
}
.todo {
font-weight: bold;
border-left: 0.5em solid #f44;
padding-left: 1em;
margin-top: 0.5em;
color: #a0a0a0;
}
.todo:before {
content: "TO DO : ";
color: #f44;
}
</style>
<body>
<div class=head id=div-head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Transforms</h1>
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 8 May 2012</h2>
<dl>
<dt>This version:
<dd> <a
href="http://www.w3.org/TR/2012/ED-css3-transforms-20120508/">http://dev.w3.org/csswg/css3-transforms/</a>
<!--http://www.w3.org/TR/2012/WD-css3-transforms-20120508/-->
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-transforms/">http://www.w3.org/TR/css3-transforms/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-transforms/">http://dev.w3.org/csswg/css3-transforms/</a>
<dt>Previous versions:
<dd><a
href="http://www.w3.org/TR/2012/WD-css3-transforms-20120228/">http://www.w3.org/TR/2012/WD-css3-transforms-20120228/</a>
<dt id=editors-list>Editors:
<dd>Simon Fraser (<a href="http://www.apple.com/">Apple Inc</a>)
<simon.fraser @apple.com>
<dd>Dean Jackson (<a href="http://www.apple.com/">Apple Inc</a>) <dino
@apple.com>
<dd>David Hyatt (<a href="http://www.apple.com/">Apple Inc</a>) <hyatt
@apple.com>
<dd>Chris Marrin (<a href="http://www.apple.com/">Apple Inc</a>)
<cmarrin @apple.com>
<dd>Edward O'Connor (<a href="http://www.apple.com/">Apple Inc</a>)
<eoconnor @apple.com>
<dd>Dirk Schulze (<a href="http://www.adobe.com/">Adobe Systems, Inc</a>)
<dschulze @adobe.com>
<dd>Aryeh Gregor (<a href="http://www.mozilla.org/">Mozilla</a>) <ayg
@aryeh.name>
<dt>Issues list:
<dd><a
href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transforms&resolution=---&cmdtype=doit">in
Bugzilla</a>
<dt>Test suite:
<dd>none yet
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2012 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>CSS transforms allows elements styled with CSS to be transformed in
two-dimensional or three-dimensional space. This specification is the
convergence of the <a href="http://www.w3.org/TR/css3-2d-transforms/">CSS
2D transforms</a>, <a href="http://www.w3.org/TR/css3-3d-transforms/">CSS
3D transforms</a> and <a
href="http://www.w3.org/TR/2009/WD-SVG-Transforms-20090320/">SVG
transforms</a> specifications.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/public-fx/">archived</a>) public
mailing list <a href="mailto:public-fx@w3.org">public-fx@w3.org</a> (see
<a href="http://www.w3.org/Mail/Request">instructions</a>) is preferred
for discussion of this specification. When sending e-mail, please put the
text “css3-transforms” in the subject, preferably like this:
“[<!---->css3-transforms<!---->] <em>…summary of
comment…</em>”
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>) and the <a
href="http://www.w3.org/Graphics/SVG/">SVG Working Group</a> (part of the
<a href="http://www.w3.org/Graphics/">Graphics Activity</a>).
<p>This document was produced by groups operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures (CSS)</a> and a <a
href="http://www.w3.org/2004/01/pp-impl/19480/status"
rel=disclosure>public list of any patent disclosures (SVG)</a> made in
connection with the deliverables of each group; these pages also include
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<!--end-status-->
<p> This specification replaces the former <a
href="http://www.w3.org/TR/css3-2d-transforms/"
title="CSS 2D Transforms">CSS 2D Transforms</a> and <a
href="http://www.w3.org/TR/css3-3d-transforms/"
title="CSS 3D Transforms Module Level 3">CSS 3D Transforms</a>
specifications, as well as <a href="http://www.w3.org/TR/SVG-Transforms/"
title="SVG Transforms 1.0">SVG Transforms</a>.
<!-- Does it actually this SVG spec? -->
<p> The <a href=ChangeLog>list of changes made to this specification</a> is
available.
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
<li><a href="#module-interactions"><span class=secno>2. </span>Module
Interactions</a>
<li><a href="#css-values"><span class=secno>3. </span>CSS Values</a>
<li><a href="#definitions"><span class=secno>4. </span>Definitions</a>
<li><a href="##two-dimensional-subset"><span class=secno>5. </span> Two
Dimensional Subset </a>
<li><a href="#transform-rendering"><span class=secno>6. </span>The
Transform Rendering Model</a>
<ul class=toc>
<li><a href="#transform-3d-rendering"><span class=secno>6.1. </span>3D
Transform Rendering</a>
</ul>
<li><a href="#transform-property"><span class=secno>7. </span> The
‘<code class=css><code
class=property>transform</code></code>’ Property </a>
<li><a href="#transform-origin-property"><span class=secno>8. </span> The
‘<code class=css><code
class=property>transform-origin</code></code>’ Property </a>
<li><a href="#transform-style-property"><span class=secno>9. </span> The
‘<code class=css><code
class=property>transform-style</code></code>’ Property </a>
<li><a href="#perspective-property"><span class=secno>10. </span> The
‘<code class=css><code
class=property>perspective</code></code>’ Property </a>
<li><a href="#perspective-origin-property"><span class=secno>11. </span>
The ‘<code class=css><code
class=property>perspective-origin</code></code>’ Property </a>
<li><a href="#backface-visibility-property"><span class=secno>12. </span>
The ‘<code class=css><code
class=property>backface-visibility</code></code>’ Property </a>
<li><a href="#svg-transform"><span class=secno>13. </span> The SVG
‘<code class=css><code
class=property>transform</code></code>’ Attribute </a>
<ul class=toc>
<li><a href="#transform-attribute-specificity"><span class=secno>13.1.
</span>SVG ‘<code class=css><code
class=property>transform</code></code>’ attribute specificity</a>
<li><a href="#svg-syntax"><span class=secno>13.2. </span>Syntax of the
SVG ‘<code class=property>transform</code>’ attribute</a>
<ul class=toc>
<li><a href="#svg-transform-list"><span class=secno>13.2.1.
</span>Transform List</a>
<li><a href="#svg-functional-notation"><span class=secno>13.2.2.
</span>Functional Notation</a>
<li><a href="#svg-data-types"><span class=secno>13.2.3. </span>SVG
Data Types</a>
<ul class=toc>
<li><a href="#svg-transform-value"><span class=secno>13.2.3.1.
</span>The <var><translation-value></var> and
<var><length></var> type</a>
<li><a href="#svg-angle"><span class=secno>13.2.3.2. </span>The
<var><angle></var> type</a>
<li><a href="#svg-number"><span class=secno>13.2.3.3. </span>The
<var><number></var> type</a>
</ul>
</ul>
<li><a href="#svg-gradient-transform-pattern-transform"><span
class=secno>13.3. </span>The SVG ‘<code
class=property>gradientTransform</code>’ and ‘<code
class=property>patternTransform</code>’ attributes</a>
<li><a href="#svg-transform-functions"><span class=secno>13.4. </span>
SVG transform functions </a>
<li><a href="#svg-three-dimensional-functions"><span class=secno>13.5.
</span>SVG and 3D transform functions</a>
<li><a href="#svg-object-bounding-box"><span class=secno>13.6.
</span>Object bounding box units</a>
<li><a href="#transform-attribute-dom"><span class=secno>13.7.
</span>SVG DOM interface for the ‘<code class=css><code
class=property>transform</code></code>’ attribute</a>
<li><a href="#svg-animation"><span class=secno>13.8. </span>SVG
Animation</a>
<ul class=toc>
<li><a href="#svg-animate-element"><span class=secno>13.8.1.
</span>The SVG ‘<code class=property>animate</code>’ and
‘<code class=property>set</code>’ element</a>
<li><a href="#svg-attribute-name"><span class=secno>13.8.2. </span>The
SVG ‘<code class=property>attributeName</code>’
attribute</a>
<li><a href="#svg-animateTransform-extension"><span
class=secno>13.8.3. </span>The SVG ‘<code
class=property>animateTransform</code>’ element</a>
</ul>
</ul>
<li><a href="#transform-functions"><span class=secno>14. </span> The
Transform Functions </a>
<ul class=toc>
<li><a href="#two-d-transform-functions"><span class=secno>14.1.
</span>2D Transform Functions</a>
<li><a href="#three-d-transform-functions"><span class=secno>14.2.
</span>3D Transform Functions</a>
</ul>
<li><a href="#transform-function-lists"><span class=secno>15. </span> The
Transform Function Lists </a>
<li><a href="#animation"><span class=secno>16. </span> Interpolation of
Transforms </a>
<ul class=toc>
<li><a href="#transform-primitives"><span class=secno>16.1. </span>
Transform function primitives and derivatives </a>
<li><a href="#interpolation-of-transform-functions"><span
class=secno>16.2. </span> Interpolation of primitives and derived
transform functions </a>
</ul>
<li><a href="#matrix-decomposition"><span class=secno>17. </span> Matrix
Decomposition for Animation </a>
<ul class=toc>
<li><a href="#unmatrix"><span class=secno>17.1. </span>Unmatrix</a>
<li><a href="#animating-the-components"><span class=secno>17.2.
</span>Animating the components</a>
<li><a href="#recomposing-the-matrix"><span class=secno>17.3.
</span>Recomposing the matrix</a>
</ul>
<li><a href="#mathematical-description"><span class=secno>18. </span>
Mathematical Description of Transform Functions </a>
<li><a href="#references"><span class=secno>19. </span>References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references">Normative
references</a>
<li class=no-num><a href="#other-references">Other references</a>
</ul>
<li class=no-num><a href="#property-index">Property index</a>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<h2 id=introduction><span class=secno>1. </span>Introduction</h2>
<p><em>This section is not normative.</em>
<p> The CSS <a href="http://www.w3.org/TR/REC-CSS2/visuren.html">visual
formatting model</a> describes a coordinate system within each element is
positioned. Positions and sizes in this coordinate space can be thought of
as being expressed in pixels, starting in the origin of point with
positive values proceeding to the right and down.
<p> This coordinate space can be modified with the ‘<a
href="#effects"><code class=css><code
class=property>transform</code></code></a>’ property. Using
transform, elements can be translated, rotated and scaled in two or three
dimensional space.
<p> Additional properties make working with transforms easier, and allow
the author to control how nested three-dimensional transforms interact.
<ul>
<li> The ‘<a href="#transform-origin"><code class=css><code
class=property>transform-origin</code></code></a>’ property
provides a convenient way to control the origin about which transforms on
an element are applied.
<li> The ‘<a href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’ property allows the
author to make child elements with three-dimensional transforms appear as
if they live in a common three-dimensional space. The ‘<a
href="#perspective-origin"><code class=css><code
class=property>perspective-origin</code></code></a>’ property
provides control over the origin at which perspective is applied,
effectively changing the location of the "vanishing point".
<li> The ‘<a href="#transform-style"><code class=css><code
class=property>transform-style</code></code></a>’ property allows
3D-transformed elements and their 3D-transformed descendants to share a
common three-dimensional space, allowing the construction of hierarchies
of three-dimensional objects.
<li> The ‘<a href="#backface-visibility"><code class=css><code
class=property>backface-visibility</code></code></a>’ property
comes into play when an element is flipped around via three-dimensional
transforms such that its reverse side is visible to the viewer. In some
situations it is desirable to hide the element in this situation, which
is possible using the value of ‘<code
class=property>hidden</code>’ for this property.
</ul>
<p> Note that while some values of the ‘<a href="#effects"><code
class=css><code class=property>transform</code></code></a>’ property
allow an element to be transformed in a three-dimensional coordinate
system, the elements themselves are not three-dimensional objects.
Instead, they exist on a two-dimensional plane (a flat surface) and have
no depth.</p>
<!-- ======================================================================================================= -->
<h2 id=module-interactions><span class=secno>2. </span>Module Interactions</h2>
<p>This module defines a set of CSS properties that affect the visual
rendering of elements to which those properties are applied; these effects
are applied after elements have been sized and positioned according to the
<a href="http://www.w3.org/TR/CSS2/visuren.html"
title="Visual formatting model">Visual formatting model</a> from <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Some values of
these properties result in the creation of a <a
href="http://www.w3.org/TR/CSS2/visuren.html#containing-block"
title="Visual formatting model">containing block</a>, and/or the creation
of a <a href="http://www.w3.org/TR/CSS2/visuren.html#z-index"
title="Visual formatting model">stacking context</a>.
<p> Three-dimensional transforms can also affect the visual layering of
elements, and thus override the back-to-front painting order described in
<a href="http://www.w3.org/TR/CSS2/zindex.html"
title="Elaborate description of Stacking Contexts">Appendix E</a> of <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>.</p>
<!-- Probably need more here. -->
<h2 id=css-values><span class=secno>3. </span>CSS Values</h2>
<p>This specification follows the <a
href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>.
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the <a
href="http://www.w3.org/TR/CSS21/cascade.html#valu
364A
e-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h2 id=definitions><span class=secno>4. </span>Definitions</h2>
<p> When used in this specification, terms have the meanings assigned in
this section.
<dl>
<dt id=TermBoundingBox><dfn id=bounding-box>bounding box</dfn>
<dd>
<p> A bounding box is the object bounding box for all SVG elements
without an associated CSS layout box and the border box for all other
elements. The bounding box of a table is the border box of its <a
href="http://www.w3.org/TR/CSS21/tables.html#model">table wrapper
box</a>, not its table box.</p>
<dt id=TermTransformableElement><dfn
id=transformable-element>transformable element</dfn>
<dd>
<p> A transformable element is an element in the HTML namespace which is
either a <a
href="http://www.w3.org/TR/CSS2/visuren.html#block-level">block-level</a>
or <a href="http://www.w3.org/TR/CSS2/visuren.html#x13">atomic
inline-level element</a>, or whose ‘<code class=css><code
class=property>display</code></code>’ property computes to
‘<code class=css><code class=css>table-row</code></code>’,
‘<code class=css><code
class=css>table-row-group</code></code>’, ‘<code
class=css><code class=css>table-header-group</code></code>’,
‘<code class=css><code
class=css>table-footer-group</code></code>’, ‘<code
class=css><code class=css>table-cell</code></code>’, or
‘<code class=css><code
class=css>table-caption</code></code>’; or an element in the SVG
namespace (see <a href="#SVG11"
rel=biblioentry>[SVG11]<!--{{SVG11}}--></a>) which has the attributes
‘<a href="#effects"><code class=css><code
class=property>transform</code></code></a>’, ‘<code
class=property>patternTransform</code>’ or ‘<code
class=property>gradientTransform</code>’.</p>
<dt id=TermPerspectiveMatrix><dfn id=perspective-matrix>perspective
matrix</dfn>
<dd>
<p> A matrix computed from the values of the ‘<a
D576
href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’ and ‘<a
href="#perspective-origin"><code class=css><code
class=property>perspective-origin</code></code></a>’ properties as
described <a href="#perspective-matrix-computation">below</a>.</p>
<dt id=TermTransformationMatrix><dfn
id=transformation-matrix>transformation matrix</dfn>
<dd>
<p> A matrix computed from the values of the ‘<a
href="#effects"><code class=css><code
class=property>transform</code></code></a>’ and ‘<a
href="#transform-origin"><code class=css><code
class=property>transform-origin</code></code></a>’ properties as
described <a href="#transformation-matrix-computation">below</a>.</p>
<dt id=TermAccumulated3DTransformationMatrix> <dfn
id=accumulated-3d-transformation-matrix>accumulated 3D transformation
matrix</dfn>
<dd>
<p> A matrix computed for elements in a <a href="#d-rendering-context">3D
rendering context</a>, as described <a
href="#accumulated-3d-transformation-matrix-computation">below</a>.</p>
<dt id=TermIdentityTransformFunction> <dfn
id=identity-transform-function>Identity transform function</dfn>
<dd>
<p> A <a href="#transform-functions">transform function</a> that is
equivalent to a identity 4x4 matrix (see <a
href="#mathematical-description">Mathematical Description of Transform
Functions</a>). Examples for identity transform functions are
‘<code class=css><code
class=css>translate(0)</code></code>’, ‘<code
class=css><code class=css>translate3d(0, 0, 0)</code></code>’,
‘<code class=css><code
class=css>translateX(0)</code></code>’, ‘<code
class=css><code class=css>translateY(0)</code></code>’,
‘<code class=css><code
class=css>translateZ(0)</code></code>’, ‘<code
class=css><code class=css>scale(1)</code></code>’, ‘<code
class=css><code class=css>scaleX(1)</code></code>’, ‘<code
class=css><code class=css>scaleY(1)</code></code>’, ‘<code
class=css><code class=css>scaleZ(1)</code></code>’, ‘<code
class=css><code class=css>rotate(0)</code></code>’, ‘<code
class=css><code class=css>rotate3d(1, 1, 1, 0)</code></code>’,
‘<code class=css><code class=css>rotateX(0)</code></code>’,
‘<code class=css><code class=css>rotateY(0)</code></code>’,
‘<code class=css><code class=css>rotateZ(0)</code></code>’,
‘<code class=css><code class=css>skewX(0)</code></code>’,
‘<code class=css><code class=css>skewY(0)</code></code>’,
‘<code class=css><code class=css>matrix(1, 0, 0, 1, 0,
0)</code></code>’ and ‘<code class=css><code
class=css>matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1)</code></code>’. A special case is perspective: ‘<code
class=css><code class=css>perspective(infinity)</code></code>’.
The value of m<small>34</small> becomes infinitesimal small and the
transform function is therefore assumed to be equal to the identity
matrix.</p>
<dt id=Term3DRenderingContext><dfn id=d-rendering-context>3D rendering
context</dfn>
<dd>
<p> A containing block hierarchy of one or more levels, instantiated by
elements with a computed value for the ‘<a
href="#transform-style"><code class=css><code
class=property>transform-style</code></code></a>’ property of
‘<code class=css><code class=css>preserve-3d</code></code>’,
whose elements share a common three-dimensional coordinate system.</p>
</dd>
<!-- Define "three-dimensional transform" ? -->
</dl>
<!-- ======================================================================================================= -->
<h2 id="#two-dimensional-subset"><span class=secno>5. </span> Two
Dimensional Subset</h2>
<p> UAs may not always be able to render three-dimensional transforms and
then just support a two-dimensional subset of this specification. In this
case <a href="#three-d-transform-functions">three-dimensional
transforms</a> and the properties ‘<a href="#transform-style"><code
class=property>transform-style</code></a>’, ‘<a
href="#perspective"><code class=property>perspective</code></a>’,
‘<a href="#perspective-origin"><code
class=property>perspective-origin</code></a>’ and ‘<a
href="#backface-visibility"><code
class=property>backface-visibility</code></a>’ must not be
supported.Section <a href="#transform-3d-rendering">3D Transform
Rendering</a> does not apply. Matrix decomposing uses the technique taken
from the "unmatrix" method in "Graphics Gems II, edited by Jim Arvo",
simplified for the 2D case. Section <a
href="#mathematical-description">Mathematical Description of Transform
Functions</a> is still effective but can be reduced by using a 3x3
transformation matrix where <em>a</em> equals <em>m11</em>, <em>b</em>
equals <em>m12</em>, <em>c</em> equals <em>m21</em>, <em>d</em> equals
<em>m22</em>, <em>e</em> equals <em>m41</em> and <em>f</em> equals
<em>m42</em> (see <a href="#MatrixDefined">A 2D 3x2 matrix with six
parameter</a>).
<div class=figure> <img alt="3x3 matrix" height=79 src=3x3matrix.png
title="\begin{bmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{bmatrix}"
width=82>
<p class=caption> 3x3 matrix for two-dimensional transformations.</p>
</div>
<div class=example>
<p> Authors can easily provide a fallback if UAs do not provide support
for three-dimensional transforms. The following example has two property
definitions for ‘<a href="#effects"><code
class=property>transform</code></a>’. The first one consists of two
two-dimensional transform functions. The second one has a two-dimensional
and a three-dimensional transform function.</p>
<pre>div {
transform: scale(2) rotate(45deg);
transform: scale(2) rotate3d(0, 0, 1, 45deg);
}</pre>
<p> With 3D support, the second definition will override the first one.
Without 3D support, the second definition is invalid and a UA falls back
to the first definition.</p>
</div>
<!-- ======================================================================================================= -->
<h2 id=transform-rendering><span class=secno>6. </span>The Transform
Rendering Model</h2>
<!-- This section is normative -->
<p> Specifying a value other than ‘<code class=css><code
class=css>none</code></code>’ for the ‘<a
href="#effects"><code class=css><code
class=property>transform</code></code></a>’ property establishes a
new <em>local coordinate system</em> at the element that it is applied to.
The mapping from where the element would have rendered into that local
coordinate system is given by the element's <a
href="#TermTransformationMatrix"><i>transformation matrix</i></a>.
Transformations are cumulative. That is, elements establish their local
coordinate system within the coordinate system of their parent. From the
perspective of the user, an element effectively accumulates all the
‘<a href="#effects"><code class=css><code
class=property>transform</code></code></a>’ properties of its
ancestors as well as any local transform applied to it. The accumulation
of these transforms defines a <em>current transformation matrix (CTM)</em>
for the element.
<p> The coordinate space behaves as described in the <a
href="http://www.w3.org/TR/SVG/coords.html#EstablishingANewUserSpace">coordinate
system transformations</a> section of the SVG 1.1 specification. This is a
coordinate system with two axes: the X axis increases horizontally to the
right; the Y axis increases vertically downwards. Three-dimensional
transform functions extent this coordinate space into three dimensions,
adding a Z axis perpendicular to the plane of the screen, that increases
towards the viewer.
<p id=transformation-matrix-computation> The <a
href="#TermTransformationMatrix"><i>transformation matrix</i></a> is
computed from the ‘<a href="#effects"><code class=css><code
class=property>transform</code></code></a>’ and ‘<a
href="#transform-origin"><code class=css><code
class=property>transform-origin</code></code></a>’ properties as
follows:
<ol>
<li>Start with the identity matrix.
<li>Translate by the computed X, Y and Z values of ‘<a
href="#transform-origin"><code class=css><code
class=property>transform-origin</code></code></a>’
<li>Multiply by each of the transform functions in ‘<a
href="#effects"><code class=css><code
class=property>transform</code></code></a>’ property in turn
<li>Translate by the negated computed X, Y and Z values of ‘<a
href="#transform-origin"><code class=css><code
class=property>transform-origin</code></code></a>’
</ol>
<p> Transforms apply to <a class=term
href="#transformable-element">transformable elements</a>.
<div class=example>
<pre>
div {
transform: translate(100px, 100px);
}
</pre>
<p>This transform moves the element by 100 pixels in both the X and Y
directions.</p>
<div class=figure> <img alt="The 100px translation in X and Y" height=250
src="examples/translate1.svg" width=470></div>
</div>
<div class=example>
<pre>div {
height: 100px; width: 100px;
transform-origin: 50px 50px;
transform: rotate(45deg);
}
</pre>
<p>The ‘<a href="#transform-origin"><code
class=property>transform-origin</code></a>’ property moves the
point of origin by 50 pixels in both the X and Y directions. The
transform rotates the element clockwise by 45° about the point of
origin. After all transform functions were applied, the translation of
the origin gets translated back by -50 pixels in both the X and Y
directions.</p>
<div class=figure><img alt="The point of origin gets translated temporary"
height=250 src="examples/origin1.svg" width=735></div>
</div>
<div class=example>
<pre>
div {
height: 100px; width: 100px;
transform: translate(80px, 80px) scale(1.5, 1.5) rotate(45deg);
}
</pre>
<p>This transform moves the element by 80 pixels in both the X and Y
directions, then scales the element by 150%, then rotates it 45°
clockwise about the Z axis. Note that the scale and rotation operate
about the center of the element, since the element has the default
transform-origin of ‘<code class=css><code class=css>50%
50%</code></code>’.</p>
<div class=figure> <img alt="The transform specified above" height=270
src="examples/compound_transform.svg" width=270></div>
<p>Note that an identical rendering can be obtained by nesting elements
with the equivalent transforms:
<pre>
<div style="transform: translate(80px, 80px)">
<div style="transform: scale(1.5, 1.5)">
<div style="transform: rotate(45deg)"></div>
</div>
</div>
</pre>
</div>
<!-- This "in the HTML namespace" is awkward. Is there a better way? -->
<p> In the HTML namespace, the transform property does not affect the flow
of the content surrounding the transformed element. However, the extent of
the overflow area takes into account transformed elements. This behavior
is similar to what happens when elements are offset via relative
positioning. Therefore, if the value of the ‘<code class=css><code
class=property>overflow</code></code>’ property is ‘<code
class=css><code class=css>scroll</code></code>’ or ‘<code
class=css><code class=css>auto</code></code>’, scrollbars will
appear as needed to see content that is transformed outside the visible
area.
<p> In the HTML namespace, any value other than ‘<code
class=css><code class=css>none</code></code>’ for the transform
results in the creation of both a stacking context and a containing block.
The object acts as a containing block for fixed positioned descendants.
<p class=issue> Is this effect on position:fixed necessary? If so, need to
go into more detail here about why fixed positioned objects should do
this, i.e., that it's much harder to implement otherwise.
<p> <a href="http://dev.w3.org/csswg/css3-background/#fixed0">Fixed
backgrounds</a> are affected by any transform specified for the root
element, and not by any other transforms.
<p class=note> Thus an element with a fixed background still acts like a
"porthole" into an image that's fixed to the viewport, and transforms on
the element affect the porthole, not the background behind it. On the
other hand, transforming the root element will still transform everything
on the page, rather than everything except for fixed backgrounds.
<p> If the root element is transformed, the transformation applies to the
entire canvas, including any background specified for the root element.
Since <a
href="http://dev.w3.org/csswg/css3-background/#special-backgrounds">the
background painting area for the root element</a> is the entire canvas,
which is infinite, the transformation might cause parts of the background
that were originally off-screen to appear. For example, if the root
element's background were repeating dots, and a transformation of
‘<code class=css><code class=css>scale(0.5)</code></code>’
were specified on the root element, the dots would shrink to half their
size, but there will be twice as many, so they still cover the whole
viewport.
<h3 id=transform-3d-rendering><span class=secno>6.1. </span>3D Transform
Rendering</h3>
<!-- Maybe define "tranform container" in the definitions, and use it everywhere
in place of "containing block"? I'm not sure if "containing block" is exactly right. -->
<p> Normally, elements render as flat planes, and are rendered into the
same plane as their containing block. Often this is the plane shared by
the rest of the page. Two-dimensional transform functions can alter the
appearance of an element, but that element is still rendered into the same
plane as its containing block.
<p> Three-dimensional transforms can result in transformation matrices with
a non-zero Z component<!-- clarify -->, potentially lifting them off the
plane of their containing block. Because of this, elements with
three-dimensional transformations could potentially render in an
front-to-back order that different from the normal CSS rendering order,
and intersect with each other. Whether they do so depends on whether the
element is a member of a <a class=term href="#d-rendering-context">3D
rendering context</a>, as described below.
<div class=issue>
<p class=desc>This description does not exactly match what WebKit
implements. Perhaps it should be changed to match current
implementations?</p>
</div>
<div class=example>
<p>This example shows the effect of three-dimensional transform applied to
an element.</p>
<pre>
<style>
div {
height: 150px;
width: 150px;
}
.container {
border: 1px solid black;
}
.transformed {
transform: rotateY(50deg);
}
</style>
<div class="container">
<div class="transformed"></div>
</div>
</pre>
<div class=figure> <img alt="Div with a rotateY transform." height=190
src="examples/simple-3d-example.png" width=210></div>
<p>The transform is a 50° rotation about the vertical, Y axis. Note
how this makes the blue box appear narrower, but not three-dimensional.</p>
</div>
<p> The ‘<a href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’ and ‘<a
href="#perspective-origin"><code class=css><code
class=property>perspective-origin</code></code></a>’ properties can
be used to add a feeling of depth to a scene by making elements higher on
the Z axis (closer to the viewer) appear larger, and those further away to
appear smaller. The scaling is proportional to <var>d</var>/(<var>d</var>
− <var>Z</var>) where <var>d</var>, the value of ‘<a
href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’, is the distance from
the drawing plane to the the assumed position of the viewer's eye.
<div class=figure> <img alt="Diagram of scale vs. Z position"
src="perspective_distance.png">
<p class=caption> Diagrams showing how scaling depends on the ‘<a
href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’ property and Z
position. In the top diagram, <var>Z</var> is half of <var>d</var>. In
order to make it appear that the original circle (solid outline) appears
at <var>Z</var> (dashed circle), the circle is scaled up by a factor of
two, resulting in the light blue circle. In the bottom diagram, the
circle is scaled down by a factor of one-third to make it appear behind
the original position.</p>
</div>
<p> Normally the assumed position of the viewer's eye is centered on a
drawing. This position can be moved if desired – for example, if a
web page contains multiple drawings that should share a common perspective
– by setting ‘<a href="#perspective-origin"><code
class=css><code
class=property>perspective-origin</code></code></a>’.
<div class=figure> <img alt="Diagram of different perspective-origin"
src="perspective_origin.png">
<p class=caption> Diagram showing the effect of moving the perspective
origin upward.</p>
</div>
<p id=perspective-matrix-computation> The <a
href="#TermPerspectiveMatrix"><i>perspective matrix</i></a> is computed as
follows: <!-- Make this more mathy, with matrices? -->
<ol>
<li>Start with the identity matrix.
<li>Translate by the computed X and Y values of ‘<a
href="#perspective-origin"><code class=css><code
class=property>perspective-origin</code></code></a>’
<li>Multiply by the matrix that would be obtained from the ‘<code
class=css><a href="#perspective-function"><code
class=css>perspective(<length>)</code></a></code>’ transform
function, where the length is provided by the value of the ‘<a
href="#perspective"><code class=css><code
class=property>perspective</code></code></a>’ property
<li>Translate by the negated computed X and Y values of ‘<a
href="#perspective-origin"><code class=css><code
class=property>perspective-origin</code></code></a>’
</ol>
<div class=example>
<p>This example shows how perspective can be used to cause
three-dimensional transforms to appear more realistic.</p>
<pre>
<style>
div {
height: 150px;
width: 150px;
}
.container {
perspective: 500px;
border: 1px solid black;
}
.transformed {
transform: rotateY(50deg);
}
</style>
<div class="container">
<div class="transformed"></div>
</div>
</pre>
<div class=figure> <img
alt="Div with a rotateY transform, and perspective on its container"
height=190 src="examples/simple-perspective-example.png" width=210></div>
<p>The inner element has the same transform as in the previous example,
but its rendering is now influenced by the perspective property on its
parent element. Perspective causes vertices that have positive Z
coordinates (closer to the viewer) to be scaled up in X and Y, and those
further away (negative Z coordinates) to be scaled down, giving an
appearance of depth.</p>
</div>
<p> An element with a three-dimensional transform that is not contained in
a <a class=term href="#d-rendering-context">3D rendering context</a>
renders with the appropriate transform applied, but does not intersect
with any other elements. The three-dimensional transform in this case can
be considered just as a painting effect, like two-dimensional transforms.
Similarly, the transform does not affect painting order. For example, a
transform with a positive Z translation may make an element look larger,
but does not cause that element to render in front of elements with no
translation in Z.
<p> An element with a three-dimensional transform that is contained in a <a
class=term href="#d-rendering-context">3D rendering context</a> can
visibly interact with other elements in that same 3D rendering context;
the set of elements participating in the same <a class=term
href="#d-rendering-context">3D rendering context</a> may obscure each
other or intersect, based on their computed transforms. They are rendered
as if they are all siblings, positioned in a common 3D coordinate space.
The position of each element in that three-dimensional space is determined
by accumulating the transformation matrices up from the element that
establishes the <a class=term href="#d-rendering-context">3D rendering
context</a> through each element that is a containing block for the given
element, as described below.
<!-- More detail required, probably with matrices -->
<div class=example>
<pre>
<style>
div {
height: 150px;
width: 150px;
}
.container {
perspective: 500px;
border: 1px solid black;
}
.transformed {
transform: rotateY(50deg);
background-color: blue;
}
.child {
transform-origin: top left;
transform: rotateX(40deg);
background-color: lime;
}
</style>
<div class="container">
<div class="transformed">
<div class="child"></div>
</div>
</div>
</pre>
<p>This example shows how nested 3D transforms are rendered in the absence
of ‘<code class=css><code class=css>transform-style:
preserve-3d</code></code>’. The blue div is transformed as in the
previous example, with its rendering influenced by the perspective on its
parent element. The lime element also has a 3D transform, which is a
rotation about the X axis (anchored at the top, by virtue of the
transform-origin). However, the lime element is being rendered into the
plane of its parent because it is not a member of a 3D rendering context;
the parent is "flattening".</p>
<div class=figure> <img alt="Nested 3D transforms, with flattening"
height=200 src="examples/3d-rendering-context-flat.png" width=240></div>
</div>