ProjectionTransform
A 3x3 matrix that transforms points in a plane.
Declaration
type ProjectionTransform =
| { m11?: number; m12?: number; m13?: number; m21?: number; m22?: number; m23?: number; m31?: number; m32?: number; m33?: number; }
| CGAffineTransform
| ProjectionTransformChain;@frozen struct ProjectionTransformOverview
A projection transform covers everything CGAffineTransform does -
translation, rotation, scale, and skew - and adds perspective, which an
affine transform cannot express. SwiftUI uses it to describe the geometry a
view effect applies.
Return a value of this type from GeometryEffect.effectValue(size:) to
write a custom effect. The following effect leans a view to one side by
shearing it, and animates as amount changes:
struct ShearEffect: GeometryEffect {
var amount: CGFloat
var animatableData: CGFloat {
get { amount }
set { amount = newValue }
}
func effectValue(size: CGSize) -> ProjectionTransform {
ProjectionTransform(
CGAffineTransform(
a: 1, b: 0, c: amount, d: 1, tx: 0, ty: 0))
}
}Create a transform from a CGAffineTransform or a CATransform3D when you
already have one, or set the nine elements directly. The elements are named
for their row and column, so ProjectionTransform.m11 is the first row
and first column.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Drawing and shapes.
- AngleA geometric angle whose value you access in either radians or degrees.
- AngularGradientAn angular gradient.
- AnyGradientA color gradient.
- BlendModeModes for compositing a view with overlapping content.
- ButtonBorderShapeA shape used to draw a button's border.
- ColorMatrixA matrix to use in an RGBA color transformation.
- ConcentricRectangleAnimatableDataThe type defining the data to animate.
- ContainerRelativeShapeA shape that is replaced by an inset version of the current container shape. If no container shape was defined, is replaced by a rectangle.
- ContentShapeKindsA kind for the content shape of a view.
- CoordinateSpaceProtocolA frame of reference within the layout system.
- DefaultGlassEffectShapeThe default shape applied by glass effects, a capsule.
- EllipticalGradientA radial gradient that draws an ellipse.