react-native-skia README

项目的 README,来自 github.com/wcandillon/react-native-skia。合并为一个 markdown 文件:README.md。

React Native Skia

CI npm version

React Native Skia Logo

React Native Skia bring Skia, the rendering engine behind Google Chrome to React Native to React Native.

We use Graphite, Skia’s new GPU backend built on WebGPU (Dawn). It plugs directly into React Native WebGPU, so 2D drawings, 3D scenes, and machine learning models share the same GPU device and the same canvas, at zero cost. The result is a unified GPU runtime for React Native. See Documentation.

React Native Skia has been downloaded more than 60 millions times on npm. And today, it powers the user-experiences of some of the top apps on the App Store and Google Play, including several that have won awards from Apple, Google, and Expo.

Platinum Sponsors

Expo

Gold Sponsors

Hark

Getting Started

yarn add react-native-skia

Installation instructions

v3 and v2

React Native Skia v3 renders with Graphite, Skia's new GPU backend. It runs on Metal on Apple platforms and on Vulkan on Android.

v3 v2
npm react-native-skia react-native-skia@2
Skia backend Graphite (Vulkan/Metal) Ganesh (OpenGL/Metal)
Architecture multi-threaded single-threaded
Platforms iOS, Android, macOS, Mac Catalyst, tvOS, Web iOS, Android, macOS, Mac Catalyst, tvOS, Android TV, Web
Branch main 2.x
Documentation wcandillon.github.io/react-native-skia wcandillon.github.io/react-native-skia/v2

v2 is still maintained. To upgrade from v2 or from @shopify/react-native-skia, follow the migration guide.

WebGPU

Graphite runs on Dawn, Google's WebGPU implementation. With React Native WebGPU installed alongside it, Skia and WebGPU share the same GPU device and can exchange textures without any copy. This also works with three.js. See the WebGPU documentation.

Contributing

For detailed information on library development, building, testing, and contributing guidelines, please see CONTRIBUTING.md.

react-native-skia (wcandillon/react-native-skia)

正在搜索数据库…

这是什么?React Native Skia 把 Google 的 Skia 图形引擎(Chrome 和 Android 所用的渲染器)带到 React Native,让你可以用 React 组件 API 编写高性能的 2D 图形、着色器和动画。
它是 UI 库还是底层图形引擎?它是一个把 Skia 的绘图原语(路径、着色器、图像、文本)暴露为声明式 React 组件的库,因此你通过组合组件来构建图形,而不是直接调用命令式的 canvas API。
怎么把它加进项目?用你的包管理器把它安装到现有的 React Native 项目中(例如 yarn add @shopify/react-native-skia),然后从该包导入 Canvas、Path、Skia 等组件即可开始绘图。
它兼容 Expo 和新架构(New Architecture)吗?它同时支持 Expo(托管和裸工作流)与普通 React Native 项目,并兼容新架构(Fabric/TurboModules)。
它在网页端表现一样吗?Web 支持是通过 CanvasKit/WASM 提供的,而非原生 Skia,因此在 Web 上的行为和性能可能与 iOS/Android 原生实现有所不同。
它能运行在哪些平台上?它以 iOS 和 Android 作为原生 React Native 平台,并通过 WebAssembly 提供实验性的 Web 支持。
它开箱即用能绘制哪些图形?它支持路径、形状、图像、文本、渐变、着色器(SKSL)、混合模式、滤镜和复杂动画,全部由 Reanimated 风格的共享值驱动,可实现流畅的 60fps 以上的更新。
为什么用它而不是 react-native 内置的 View 或 SVG?Skia 提供直接的 GPU 加速渲染,其绘图 API(自定义着色器、复杂路径、滤镜、模糊效果)远比标准 RN View 或 react-native-svg 丰富,能缩小与原生图形性能之间的差距。
我能用 Reanimated 制作图形动画吗?可以,这个库在设计上与 react-native-reanimated 紧密集成,让你可以用共享值和 worklet 驱动 Skia 绘图,实现原生的流畅动画。
大小
343.7 MB
星标
8.8K
时长
5年
提交 · 90 天