CSS Transform Module Level 2

Editor’s Draft,

This version:
http://dev.w3.org/csswg/css-transforms-2/
Feedback:
www-style@w3.org with subject line “[css-transforms] … message topic …” (archives)
Test Suite:
http://test.csswg.org/suites/css-transforms-1_dev/nightly-unstable/
Issue Tracking:
GitHub
Inline In Spec
Editors:
Tab Atkins Jr. (Google Inc)
(Apple Inc)
(Apple Inc)
(Apple Inc)
(Adobe Systems Inc)

Abstract

CSS transforms allows elements styled with CSS to be transformed in two-dimensional or three-dimensional space.

This is a delta spec over CSS Transforms Level 1, while that spec is finishing standardization.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

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.

The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-transforms” in the subject, preferably like this: “[css-transforms] …summary of comment…

This document was produced by the CSS Working Group (part of the Style Activity).

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 1 August 2014 W3C Process Document.

Table of Contents

1. Introduction

Introduction here.

2. Individual Transform Properties: the translate, scale, and rotate properties

Fluff here.

Name: translate
Value: [ <length> | <percentage> ] [[ <length> | <percentage> ] <length>? ]?
Initial: 0
Applies to: all elements
Inherited: no
Percentages: relative to the width of the containing block (for the first value) or the height (for the second value)
Media: visual
Computed value: as specified
Animatable: as <length> or <percentage> list
Computed Value: as specified, with lengths made absolute
Name: rotate
Value: <angle> <number>{3}?
Initial: 0deg
Applies to: all elements
Inherited: no
Percentages: n/a
Media: visual
Computed value: as specified
Animatable: as SLERP
Name: scale
Value: <number>{1,3}
Initial: 1
Applies to: all elements
Inherited: no
Percentages: n/a
Media: visual
Computed value: as specified
Animatable: as <number> list

The translate, rotate, and scale properties allow authors to specify simple transforms independently, in a way that maps to typical user interface usage, rather than having to remember the order in transform that keeps the actions of transform(), rotate() and scale() independent and acting in screen coordinates.

The translate property accepts 1-3 values, each specifying a translation against one axis, in the order X, Y, then Z. Unspecified translations default to 0px.

The rotate property accepts an angle to rotate an element, and optionally an axis to rotate it around, specified as the X, Y, and Z lengths of an origin-anchored vector. If the axis is unspecified, it defaults to 0 0 1, causing a "2d rotation" in the plane of the screen.

The scale property accepts 1-3 values, each specifying a scale along one axis, in order X, Y, then Z. Unspecified scales default to 1.

3. Current Transformation Matrix

The transformation matrix computation is amended to the following:

The transformation matrix is computed from the transform, transform-origin, translate, rotate, scale, and motion properties as follows:

  1. Start with the identity matrix.

  2. Translate by the computed X, Y, and Z values of transform-origin.

  3. Translate by the computed X, Y, and Z values of translate.

  4. Rotate by the computed <angle> about the specified axis of rotate.

  5. Scale by the computed X, Y, and Z values of scale.

  6. Translate and rotate by the transform specified by motion.

  7. Multiply by each of the transform functions in transform from left to right.

  8. Translate by the negated computed X, Y and Z values of transform-origin.

4. SVG and 3D transform functions additions

Even if the vector-effect property has values extended by [SVG2] and an object is within a 3D rendering context the property has no affect on rendering the object.

5. Terminology additions

scale
A kind of values showing the ratio of enlarges or shrinks by transformation. There are values for each axis (sx, sy and sz, there are set up by scaleX(), scaleY() and scaleZ() respectively.) and values for the entire 3D or 2D coordinate system itself (scale2D and scale3D) in it. scale2D and scale3D are usually derived variables from decomposition of a transformation matrix, and chiefly it will be used in order to evaluate transformation such as svg's non scaling functions of vector-effect property.

6. Mathematical Description of Transform Functions additions

7. More Issues

Per https://lists.w3.org/Archives/Public/www-style/2015Mar/0371.html, the WG resolved to add a formula for decomposing a transform into a unified "scale" (the spec already defines how to decompose it into scaleX/Y/Z), for use by things like SVG’s non-scaling stroke spec. Formula is defined here.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words "for example" or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word "Note" and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Experimental implementations

To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.

Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-2D-TRANSFORMS-1]
CSS 2D Transforms Module Level 1 URL: http://www.w3.org/TR/css3-2d-transforms/
[CSS-VALUES-3]
CSS Values and Units Module Level 3 URL: http://www.w3.org/TR/css3-values/
[MOTION-1]
Dirk Schulze; Shane Stephens. Motion Path Module Level 1. 9 April 2015. WD. URL: http://www.w3.org/TR/motion-1/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[SVG2]
Erik Dahlström; et al. Scalable Vector Graphics (SVG) 2. 09 July 2015. Working Draft URL: http://www.w3.org/TR/SVG2/

Property Index

Name Value Initial Applies to Inh. %ages Media Animatable Computed value
translate [ <length> | <percentage> ] [[ <length> | <percentage> ] <length>? ]? 0 all elements no relative to the width of the containing block (for the first value) or the height (for the second value) visual as <length> or <percentage> list as specified, with lengths made absolute
rotate <angle> <number>{3}? 0deg all elements no n/a visual as SLERP as specified
scale <number>{1,3} 1 all elements no n/a visual as <number> list as specified

Issues Index

Per https://lists.w3.org/Archives/Public/www-style/2015Mar/0371.html, the WG resolved to add a formula for decomposing a transform into a unified "scale" (the spec already defines how to decompose it into scaleX/Y/Z), for use by things like SVG’s non-scaling stroke spec. Formula is defined here.