Skip to content

Commit 64cbe41

Browse files
added initial version
0 parents  commit 64cbe41

File tree

15 files changed

+4138
-0
lines changed

15 files changed

+4138
-0
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
lib/
4+
5+
.expo/
6+
.vscode/

.eslintrc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
ecmaVersion: 2020,
5+
sourceType: 'module',
6+
ecmaFeatures: {
7+
jsx: true
8+
}
9+
},
10+
settings: {
11+
react: {
12+
version: 'detect'
13+
},
14+
'import/parsers': {
15+
'@typescript-eslint/parser': ['.ts', '.tsx']
16+
},
17+
'import/resolver': {
18+
typescript: {
19+
alwaysTryTypes: true
20+
}
21+
}
22+
},
23+
extends: [
24+
'plugin:react/recommended',
25+
'plugin:@typescript-eslint/recommended',
26+
'prettier/@typescript-eslint',
27+
'plugin:import/errors',
28+
'plugin:import/warnings',
29+
'plugin:import/typescript',
30+
'plugin:prettier/recommended'
31+
],
32+
rules: {
33+
'@typescript-eslint/explicit-function-return-type': 'off',
34+
'import/order': ['error']
35+
}
36+
};

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vscode
2+
node_modules/
3+
/lib/
4+
.expo
5+
6+
yarn-error.log

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package.json

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: "none",
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 4,
7+
};

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2020 Manuel Schiller
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
this software and associated documentation files (the "Software"), to deal in
6+
the Software without restriction, including without limitation the rights to
7+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
of the Software, and to permit persons to whom the Software is furnished to do
9+
so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# gl-react-blurhash ![](https://img.shields.io/npm/v/gl-react-blurhash.svg)
2+
3+
Universal [`gl-react`](https://github.com/gre/gl-react) module that implements [BlurHash](https://github.com/woltapp/blurhash) in OpenGL.
4+
5+
## Installation
6+
7+
### Expo
8+
9+
Add the following dependencies:
10+
11+
```sh
12+
expo add gl-react gl-react-expo expo-gl buffer gl-react-blurhash
13+
```
14+
15+
### React Native
16+
17+
First setup [`react-native-unimodules`](https://github.com/unimodules/react-native-unimodules), then add the following dependencies:
18+
19+
```sh
20+
yarn add gl-react gl-react-native buffer gl-react-blurhash
21+
```
22+
23+
### Example
24+
25+
```js
26+
import React from 'react';
27+
import { Surface } from 'gl-react-expo'; // 'gl-react-native' for React Native
28+
import { Blurhash } from 'gl-react-blurhash';
29+
30+
export default function App {
31+
return (
32+
<Surface style={{ width: 300, height: 200 }}>
33+
<Blurhash hash="LPKA$w{H_c05b{Nqwbx^grotMnNf" />
34+
</Surface>
35+
);
36+
}
37+
```

package.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "gl-react-blurhash",
3+
"version": "1.0.0",
4+
"description": "Universal gl-react module that implements BlurHash in OpenGL",
5+
"license": "MIT",
6+
"author": "Manuel Schiller",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+ssh://git@github.com/schiller-manuel/gl-react-blurhash.git"
10+
},
11+
"homepage": "https://github.com/schiller-manuel/gl-react-blurhash#readme",
12+
"bugs": {
13+
"url": "https://github.com/schiller-manuel/gl-react-blurhash/issues"
14+
},
15+
"keywords": [
16+
"blurhash",
17+
"gl-react"
18+
],
19+
"main": "lib/commonjs/index.js",
20+
"react-native": "src/index.tsx",
21+
"module": "lib/module/index.js",
22+
"types": "lib/typescript/src/index.d.ts",
23+
"files": [
24+
"src",
25+
"lib"
26+
],
27+
"@react-native-community/bob": {
28+
"source": "src",
29+
"output": "lib",
30+
"targets": [
31+
"commonjs",
32+
"module",
33+
"typescript"
34+
]
35+
},
36+
"eslintIgnore": [
37+
"node_modules/",
38+
"lib/"
39+
],
40+
"scripts": {
41+
"lint": "eslint --ext '.js,.ts,.tsx' .",
42+
"build": "bob build",
43+
"clean": "del lib"
44+
},
45+
"dependencies": {
46+
"blurhash": "^1.1.3"
47+
},
48+
"peerDependencies": {
49+
"gl-react": "^4.0.1"
50+
},
51+
"devDependencies": {
52+
"@react-native-community/bob": "^0.14.3",
53+
"@types/gl-react": "^3.15.2",
54+
"@types/react": "^16.9.34",
55+
"@typescript-eslint/eslint-plugin": "^2.30.0",
56+
"@typescript-eslint/parser": "^2.30.0",
57+
"del-cli": "^3.0.1",
58+
"eslint": "^6.8.0",
59+
"eslint-config-prettier": "^6.11.0",
60+
"eslint-import-resolver-typescript": "^2.0.0",
61+
"eslint-plugin-import": "^2.20.2",
62+
"eslint-plugin-prettier": "^3.1.3",
63+
"eslint-plugin-react": "^7.19.0",
64+
"prettier": "^2.0.5",
65+
"react": "^16.13.1",
66+
"typescript": "^3.9.2"
67+
}
68+
}

src/Blurhash.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// eslint-disable-next-line import/default
2+
import React from 'react';
3+
import { Node } from 'gl-react';
4+
import { BlurhashProps } from './BlurhashProps';
5+
import { decode } from './decode';
6+
import { getShader } from './getShader';
7+
8+
export const Blurhash = (props: BlurhashProps) => {
9+
const decoded = decode(props.hash, props.punch);
10+
return (
11+
<Node
12+
shader={{
13+
frag: getShader(decoded.numX, decoded.numY)
14+
}}
15+
uniforms={{
16+
colors: decoded.colors
17+
}}
18+
/>
19+
);
20+
};

src/BlurhashProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface BlurhashProps {
2+
hash: string;
3+
punch?: number;
4+
}

0 commit comments

Comments
 (0)