Skip to content

Commit 7b3e271

Browse files
authored
Improve readme (#653)
1 parent 154bcd6 commit 7b3e271

File tree

2 files changed

+9
-121
lines changed

2 files changed

+9
-121
lines changed

README.md

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -14,132 +14,13 @@ React Native Skia brings the Skia Graphics Library to React Native. Skia serves
1414

1515
_This is an alpha release. Use with caution._
1616

17-
## Installation
18-
19-
React Native Skia brings the [Skia Graphics Library](https://skia.org/) to React Native.
20-
Skia serves as the graphics engine for Google Chrome and Chrome OS, Android, Flutter, Mozilla Firefox and Firefox OS, and many other products.
21-
22-
```sh
23-
yarn add @shopify/react-native-skia
24-
```
25-
26-
Or using npm:
17+
## Getting Started
2718

2819
```sh
2920
npm install @shopify/react-native-skia
3021
```
3122

32-
### iOS
33-
34-
Run `pod install` on the `ios/` directory.
35-
36-
### Android
37-
38-
> **Version compatibility**: `react-native@>=0.66` is required.
39-
40-
Currently, you will need Android NDK to be installed.
41-
If you have Android Studio installed, make sure `$ANDROID_NDK` is available.
42-
`ANDROID_NDK=/Users/username/Library/Android/sdk/ndk-bundle` for instance.
43-
44-
If the NDK is not installed, you can install it via Android Studio by going to the menu _File > Project Structure_
45-
46-
And then the _SDK Location_ section. It will show you the NDK path, or the option to Download it if you don't have it installed.
47-
48-
And them the _Modules_ section. click on `shopify_react-native-skia` and select _NDK version_ with dropdown, and click on apply.
49-
50-
#### Proguard
51-
52-
If you're using Proguard, make sure to add the following rule:
53-
54-
```
55-
-keep class com.shopify.reactnative.skia.** { *; }
56-
```
57-
58-
#### TroubleShooting
59-
60-
For error **_CMake 'X.X.X' was not found in SDK, PATH, or by cmake.dir property._**
61-
62-
open _Tools > SDK Manager_, switch to the _SDK Tools_ tab.
63-
Find `CMake` and click _Show Package Details_ and download compatiable version **'X.X.X'**, and apply to install.
64-
65-
### Playground
66-
67-
We have an example project you can play with [here](https://github.com/Shopify/react-native-skia/tree/main/example).
68-
69-
```sh
70-
$ yarn
71-
$ cd package && yarn && cd ..
72-
$ cd example && yarn && yarn start
73-
```
74-
75-
To run the example project on iOS, you will need to run `pod install` and on Android you will also need Android NDK to be installed ([see here](#android)).
76-
77-
## Hello World
78-
79-
React Native Skia has two APIs: a declarative API available as a React Native Renderer and an imperative API backed by JSI.
80-
The recommended way to use this library is via the declarative API.
81-
Library developers may take advantage of the imperative API to provide custom features.
82-
83-
## Declarative API
84-
85-
### Example
86-
87-
```tsx twoslash
88-
import { Canvas, Circle, Group } from "@shopify/react-native-skia";
89-
90-
export const HelloWorld = () => {
91-
const width = 256;
92-
const height = 256;
93-
const r = 215;
94-
return (
95-
<Canvas style={{ flex: 1 }}>
96-
<Group blendMode="multiply">
97-
<Circle cx={r} cy={r} r={r} color="cyan" />
98-
<Circle cx={width - r} cy={r} r={r} color="magenta" />
99-
<Circle cx={width / 2} cy={height - r} r={r} color="yellow" />
100-
</Group>
101-
</Canvas>
102-
);
103-
};
104-
```
105-
106-
## Imperative API
107-
108-
### Example
109-
110-
```tsx twoslash
111-
import {
112-
Skia,
113-
BlendMode,
114-
SkiaView,
115-
useDrawCallback,
116-
} from "@shopify/react-native-skia";
117-
118-
const paint = Skia.Paint();
119-
paint.setAntiAlias(true);
120-
paint.setBlendMode(BlendMode.Multiply);
121-
122-
export const HelloWorld = () => {
123-
const width = 256;
124-
const height = 256;
125-
const r = 215;
126-
const onDraw = useDrawCallback((canvas) => {
127-
// Cyan Circle
128-
const cyan = paint.copy();
129-
cyan.setColor(Skia.Color("cyan"));
130-
canvas.drawCircle(r, r, r, cyan);
131-
// Magenta Circle
132-
const magenta = paint.copy();
133-
magenta.setColor(Skia.Color("magenta"));
134-
canvas.drawCircle(width - r, r, r, magenta);
135-
// Yellow Circle
136-
const yellow = paint.copy();
137-
yellow.setColor(Skia.Color("yellow"));
138-
canvas.drawCircle(width / 2, height - r, r, yellow);
139-
});
140-
return <SkiaView style={{ flex: 1 }} onDraw={onDraw} />;
141-
};
142-
```
23+
Documentation is available at [https://shopify.github.io/react-native-skia](https://shopify.github.io/react-native-skia/docs/getting-started/installation/).
14324

14425
## Library Development
14526

docs/docs/getting-started/installation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ If you're using Proguard, make sure to add the following rule:
4343
-keep class com.shopify.reactnative.skia.** { *; }
4444
```
4545

46+
### TroubleShooting
47+
48+
For error **_CMake 'X.X.X' was not found in SDK, PATH, or by cmake.dir property._**
49+
50+
open _Tools > SDK Manager_, switch to the _SDK Tools_ tab.
51+
Find `CMake` and click _Show Package Details_ and download compatiable version **'X.X.X'**, and apply to install.
52+
4653
## Playground
4754

4855
We have an example project you can play with [here](https://github.com/Shopify/react-native-skia/tree/main/example).

0 commit comments

Comments
 (0)