Skip to content

Commit

Permalink
feat: exploring skia setup
Browse files Browse the repository at this point in the history
  • Loading branch information
enzomanuelmangano committed May 21, 2023
1 parent 74888fe commit 4d31269
Show file tree
Hide file tree
Showing 28 changed files with 7,042 additions and 10 deletions.
Binary file removed .assets/skia-grid.png
Binary file not shown.
Binary file added .assets/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<h1 align="center">
Grid Magnification effect in React Native Skia 🦄
Exploring Skia 🦄
</h1>

<a href="https://youtu.be/zV0SGIlrtug" target="_blank">
<img src="https://github.com/enzomanuelmangano/skia-grid-magnification/blob/main/.assets/skia-grid.png" title="skia-grid-magnification">
<img src="https://github.com/enzomanuelmangano/exploring-skia/blob/main/.assets/thumbnail.png" title="exploring-skia">
</a>

[Check out the video tutorial!](https://youtu.be/zV0SGIlrtug)
What's up mobile devs?
This is a repository where I explore the (React Native Skia)[https://github.com/Shopify/react-native-skia] package, by creating some interesting animations and UIs.
If you find this repo useful, feel free to support me on [Patreon](https://www.patreon.com/reactiive).

## Inspiration
# Tutorials

- [Philip Davis' Tweet](https://twitter.com/philipcdavis/status/1549409119131488256?s=20&t=PmMsvQBgsruGVeAtooeLcA)
Every source code is fully explained in the following tutorials:

## Does this sound interesting?

Then I suggest you check out my [YouTube](https://www.youtube.com/c/Reactiive) channel. I create React Native contents and continually update a series on Reanimated called ["Animate with Reanimated"](https://github.com/enzomanuelmangano/animate-with-reanimated).

Do you want to support me? [Buymeacoffee](https://www.buymeacoffee.com/reactiive)
- [Skia Grid Magnification](https://youtu.be/zV0SGIlrtug)
- [Metaball Animation](https://youtu.be/HOxZegqnDC4)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions metaball/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules/
.expo/
dist/
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/

# macOS
.DS_Store

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*
82 changes: 82 additions & 0 deletions metaball/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { StatusBar, Text, View, useWindowDimensions } from 'react-native';
import React, { useMemo } from 'react';
import {
Blur,
Canvas,
Circle,
ColorMatrix,
Group,
Paint,
SweepGradient,
runSpring,
useValue,
vec,
} from '@shopify/react-native-skia';
import Touchable, { useGestureHandler } from 'react-native-skia-gesture';

const RADIUS = 80;

export default function App() {
const { width: windowWidth, height: windowHeight } = useWindowDimensions();

const cx = useValue(windowWidth / 2);
const cy = useValue(windowHeight / 2);

const gestureHandler = useGestureHandler<{
x: number;
y: number;
}>({
onStart: (_, context) => {
context.x = cx.current;
context.y = cy.current;
},
onActive: ({ translationX, translationY }, context) => {
cx.current = translationX + context.x;
cy.current = translationY + context.y;
},
onEnd: () => {
runSpring(cx, windowWidth / 2);
runSpring(cy, windowHeight / 2);
},
});

const layer = useMemo(() => {
return (
<Paint>
{/* pixelOpacity > blurredOpacity * 60 - 30 */}
<Blur blur={30} />
<ColorMatrix
matrix={[
// R, G, B, A, Bias (Offset)
// prettier-ignore
1, 0, 0, 0, 0,
// prettier-ignore
0, 1, 0, 0, 0,
// prettier-ignore
0, 0, 1, 0, 0,
// prettier-ignore
0, 0, 0, 60, -30,
]}
/>
</Paint>
);
}, []);

return (
<>
<StatusBar barStyle={'light-content'} />
<Touchable.Canvas
style={{
flex: 1,
backgroundColor: '#111',
}}
>
<Group layer={layer}>
<Touchable.Circle {...gestureHandler} cx={cx} cy={cy} r={RADIUS} />
<Circle cx={windowWidth / 2} cy={windowHeight / 2} r={RADIUS} />
<SweepGradient c={vec(0, 0)} colors={['cyan', 'magenta', 'cyan']} />
</Group>
</Touchable.Canvas>
</>
);
}
30 changes: 30 additions & 0 deletions metaball/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"expo": {
"name": "metaball",
"slug": "metaball",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Binary file added metaball/assets/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added metaball/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added metaball/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added metaball/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions metaball/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
25 changes: 25 additions & 0 deletions metaball/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "metaball",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@shopify/react-native-skia": "0.1.172",
"expo": "~48.0.15",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-skia-gesture": "^0.1.7"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.0.14",
"typescript": "^4.9.4"
},
"private": true
}
6 changes: 6 additions & 0 deletions metaball/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
}
}
Loading

0 comments on commit 4d31269

Please sign in to comment.