satori 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -293,14 +293,40 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
293
293
  <tr><td><code>backgroundClip</code></td><td><code>border-box</code>, <code>text</code></td><td></td></tr>
294
294
  <tr><td><code>backgroundRepeat</code></td><td><code>repeat</code>, <code>repeat-x</code>, <code>repeat-y</code>, <code>no-repeat</code>, defaults to <code>repeat</code></td><td></td></tr>
295
295
 
296
- <tr><td rowspan="5"><code>transform</code></td></tr>
297
- <tr><td>Translate (<code>translate</code>, <code>translateX</code>, <code>translateY</code>)</td><td>Supported</td><td></td></tr>
298
- <tr><td>Rotate</td><td>Supported</td><td></td></tr>
299
- <tr><td>Scale (<code>scale</code>, <code>scaleX</code>, <code>scaleY</code>)</td><td>Supported</td><td></td></tr>
296
+ <tr><td rowspan="7"><code>transform</code></td></tr>
297
+ <tr><td>Translate (<code>translate</code>, <code>translateX</code>, <code>translateY</code>, <code>translateZ</code>, <code>translate3d</code>)</td><td>Supported, with <code>px</code>, <code>em</code>, <code>rem</code>, <code>vw</code> and <code>vh</code> lengths, and percentages of the element's size along X and Y</td><td></td></tr>
298
+ <tr><td>Rotate (<code>rotate</code>, <code>rotateX</code>, <code>rotateY</code>, <code>rotateZ</code>, <code>rotate3d</code>)</td><td>Supported, with <code>deg</code>, <code>rad</code>, <code>grad</code> and <code>turn</code> angles</td><td></td></tr>
299
+ <tr><td>Scale (<code>scale</code>, <code>scaleX</code>, <code>scaleY</code>, <code>scaleZ</code>, <code>scale3d</code>)</td><td>Supported, including percentages</td><td></td></tr>
300
300
  <tr><td>Skew (<code>skew</code>, <code>skewX</code>, <code>skewY</code>)</td><td>Supported</td><td></td></tr>
301
+ <tr><td>Matrix (<code>matrix</code>, <code>matrix3d</code>)</td><td>Supported</td><td></td></tr>
302
+ <tr><td>Perspective (<code>perspective</code>)</td><td>Approximated, see the notes below</td><td></td></tr>
301
303
 
302
304
  <tr>
303
305
  <td colspan="2"><code>transformOrigin</code></td>
306
+ <td>Support one-value, two-value and three-value syntax (both relative and absolute values, the third value is a depth)</td>
307
+ <td></td>
308
+ </tr>
309
+
310
+ <tr>
311
+ <td colspan="2"><code>transformStyle</code></td>
312
+ <td><code>flat</code>, <code>preserve-3d</code>, defaults to <code>flat</code></td>
313
+ <td></td>
314
+ </tr>
315
+
316
+ <tr>
317
+ <td colspan="2"><code>backfaceVisibility</code></td>
318
+ <td><code>visible</code>, <code>hidden</code>, defaults to <code>visible</code></td>
319
+ <td></td>
320
+ </tr>
321
+
322
+ <tr>
323
+ <td colspan="2"><code>perspective</code></td>
324
+ <td>Length or <code>none</code>. Approximated, see the notes below</td>
325
+ <td></td>
326
+ </tr>
327
+
328
+ <tr>
329
+ <td colspan="2"><code>perspectiveOrigin</code></td>
304
330
  <td>Support one-value and two-value syntax (both relative and absolute values)</td>
305
331
  <td></td>
306
332
  </tr>
@@ -388,12 +414,31 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
388
414
 
389
415
  Note:
390
416
 
391
- 1. Three-dimensional transforms are not supported.
417
+ 1. 3D transforms are drawn like in browsers, with two differences. Elements in a `preserve-3d` context are drawn back to front by the depth of their centers, and elements that intersect aren't cut where they cross. Perspective is approximated: each element is drawn with the affine transform closest to it around its center, which is exact for elements facing the viewer, such as `translateZ()`. `satori/experimental` [draws perspective exactly](#perspective-experimental).
392
418
  2. There is no `z-index` support in SVG. Elements that come later in the document will be painted on top.
393
419
  3. `calc` isn't supported.
394
420
  4. `currentColor` support is only available for the `color` property.
395
421
  5. CSS variables (custom properties) are supported, including inheritance, fallback values, and nested variables.
396
422
 
423
+ #### Perspective (experimental)
424
+
425
+ > **Note:** This is experimental and may change or be removed in any release. It's only available from `satori/experimental`, so it doesn't add to the size of the `satori` import.
426
+
427
+ With `satori/experimental`, perspective from the `perspective` property and the `perspective()` function is drawn exactly:
428
+
429
+ ```jsx
430
+ import satori from 'satori/experimental'
431
+
432
+ await satori(
433
+ <div style={{ display: 'flex', perspective: 600 }}>
434
+ <div style={{ display: 'flex', transform: 'rotateY(35deg)' }}>Hello</div>
435
+ </div>,
436
+ options
437
+ )
438
+ ```
439
+
440
+ SVG has no perspective transforms, so each element with perspective is split into triangles that are each drawn with an affine transform, within 0.5px of the exact position. This makes the SVG larger and slower to render: depending on the angle, an element is drawn up to a few hundred times.
441
+
397
442
  ### Language and Typography
398
443
 
399
444
  **OpenType Features**: Satori supports advanced typography features via HarfBuzz text shaping. Use the `font-feature-settings` CSS property to enable OpenType features such as: