Skip to content

Commit 37be8ea

Browse files
docs: Add matrix transform documentation and example
Fixes #1899 Added comprehensive documentation for the matrix transform property which was previously undocumented despite being supported in React Native. Changes: - Added matrix transform example in the interactive demo - Documented the 4x4 matrix structure and column-major order - Provided practical examples of matrix usage - Added note about when to use matrix vs individual transforms - Clarified that matrix is useful for UI editors and pre-calculated transforms This addresses the confusion around the deprecated transformMatrix property and provides clear guidance on using the modern matrix syntax.
1 parent 1990be8 commit 37be8ea

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

docs/transforms.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ const App = () => (
129129
]}>
130130
<Text style={styles.text}>TranslateY by 50 </Text>
131131
</View>
132+
133+
<View
134+
style={[
135+
styles.box,
136+
{
137+
transform: [
138+
{
139+
matrix: [1, 0.5, 0, 0, 0.5, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
140+
},
141+
],
142+
},
143+
]}>
144+
<Text style={styles.text}>Matrix Transform</Text>
145+
</View>
132146
</ScrollView>
133147
</SafeAreaView>
134148
</SafeAreaProvider>
@@ -195,6 +209,43 @@ The skew transformations require a string so that the transform may be expressed
195209
}
196210
```
197211

212+
### Matrix Transform
213+
214+
The `matrix` transform accepts a 4x4 transformation matrix as an array of 16 numbers. This allows you to apply complex transformations that combine translation, rotation, scaling, and skewing in a single operation.
215+
216+
The matrix is specified in column-major order:
217+
218+
```js
219+
{
220+
transform: [
221+
{
222+
matrix: [
223+
scaleX, skewY, 0, 0,
224+
skewX, scaleY, 0, 0,
225+
0, 0, 1, 0,
226+
translateX, translateY, 0, 1
227+
]
228+
}
229+
]
230+
}
231+
```
232+
233+
For example, to apply a combination of scale and skew:
234+
235+
```js
236+
{
237+
transform: [
238+
{
239+
matrix: [1, 0.5, 0, 0, 0.5, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
240+
}
241+
]
242+
}
243+
```
244+
245+
:::note
246+
Matrix transforms are useful when you need to apply pre-calculated transformation matrices, such as those from animation libraries or when building UI editor applications. For simple transformations, it's recommended to use the individual transform properties (scale, rotate, translate, etc.) as they are more readable.
247+
:::
248+
198249
| Type | Required |
199250
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
200251
| array of objects: `{matrix: number[]}`, `{perspective: number}`, `{rotate: string}`, `{rotateX: string}`, `{rotateY: string}`, `{rotateZ: string}`, `{scale: number}`, `{scaleX: number}`, `{scaleY: number}`, `{translateX: number}`, `{translateY: number}`, `{skewX: string}`, `{skewY: string}` or string | No |

0 commit comments

Comments
 (0)