Skip to content

Commit 8a85c20

Browse files
authored
docs: add npm package badge to README (#1)
1 parent 5a4e4a8 commit 8a85c20

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 🌖 react-native-fast-shadow
22

3+
[![npm package](https://img.shields.io/npm/v/react-native-fast-shadow?color=brightgreen&label=npm%20package)](https://www.npmjs.com/package/react-native-fast-shadow)
4+
35
**Fast and high quality** Android shadows for React Native
46

57
## Why
@@ -59,14 +61,14 @@ import { ShadowedView, shadowStyle } from 'react-native-fast-shadow';
5961
<Image source={require('./kitten.png')} style={{ borderRadius: 30 }} />
6062
</ShadowedView>
6163
```
62-
64+
6365
## How it works under the hood
6466

6567
On Android, shadow drawables are generated with the following process (see [ShadowFactory.java](https://github.com/alan-eu/react-native-fast-shadow/blob/main/android/src/main/java/com/reactnativefastshadow/ShadowFactory.java) for more details):
6668
1. The shape of the view (rectangle with rounded corners) is painted in black on a canvas
6769
2. A gaussian blur is applied to the canvas with the given `shadowRadius` using the Renderscript API
6870
3. The drawable is then converted to a [NinePatchDrawable](https://developer.android.com/reference/android/graphics/drawable/NinePatchDrawable) to ensure that corners of the shadow won't be distorted when the view is resized. This way, we can generate only a small shadow drawable and **reuse it** for all views with the same border and blur radii.
69-
4. Finally, the drawable is rendered behind the view content: it is tinted with `shadowColor`/`shadowOpacity` and offseted according to `shadowOffset`
71+
4. Finally, the drawable is rendered behind the view content: it is tinted with `shadowColor`/`shadowOpacity` and offseted according to `shadowOffset`
7072

7173
**How NinePatchDrawable works** (notice how the corners are not streched when the drawable is resized):
7274

0 commit comments

Comments
 (0)