Skip to content

Commit 8a5a105

Browse files
authored
chore: cleanup docs (#83)
* chore: fix repo link * chore: fix repo link * chore: rename root monorepo * chore: replace README.md
1 parent 5471c2a commit 8a5a105

File tree

4 files changed

+23
-113
lines changed

4 files changed

+23
-113
lines changed

README.md

+17-105
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,42 @@
11
<div align="center">
2-
<img alt="REACT-VFX" src="https://user-images.githubusercontent.com/1403842/71323457-c69e6900-2516-11ea-958c-b96b2121387b.png" width="100%"/>
3-
<h1>REACT-VFX: WebGL effects for React elements!!</h1>
2+
<a href="https://amagi.dev/vfx-js/" target="_blank"><img alt="VFX-JS" src="packages/docs/public/og_image.jpg" width="100%"/></a>
3+
<h1>VFX-JS: Visual Effects Framework for Web</h1>
44
<br/>
55
<br/>
66
</div>
77

8-
## Install
8+
VFX-JS is a JavaScript library to add WebGL-powered effects to your website.
9+
You can easily attach it to normal `<img>`, `<video>` elements etc.
910

10-
```
11-
npm i react-vfx
12-
```
13-
14-
## Usage
15-
16-
REACT-VFX exports `VFXImg`, `VFXVideo`, `VFXSpan` and `VFXDiv`.
17-
These components works just like `<img>`, `<video>`, `<span>` and `<div>` - accepts all properties they have, but they are rendered in WebGL world with shader effects!
1811

19-
```ts
20-
import * as VFX from 'react-vfx';
12+
This is the core implementation of [REACT-VFX](https://amagi.dev/react-vfx).
2113

22-
export default () => (
23-
<VFX.VFXProvider>
24-
{/* Render image with shader */}
25-
<VFX.VFXImg src="cat.png" alt="image" shader="rgbShift"/>
26-
27-
{/* It also supports animated GIFs! */}
28-
<VFX.VFXImg src="doge.gif" shader="pixelate"/>
29-
30-
{/* and videos! */}
31-
<VFX.VFXVideo src="mind_blown.mp4"
32-
autoplay playsinline loop muted
33-
shader="halftone"/>
34-
35-
{/* Render text as image, then apply the shader effect! */}
36-
<VFX.VFXSpan shader="rainbow">Hi there!</VFX.VFXSpan>
37-
38-
{/* Or even inputs! */}
39-
<VFX.VFXDiv shader="rainbow">
40-
<input type="text" value="hello" />
41-
</VFX.VFXDiv>
42-
</VFX.VFXProvider>
43-
);
44-
```
4514

46-
NOTE: `VFXSpan` doesn't work if the content includes child nodes.
15+
## Usage
4716

48-
```ts
49-
// OK
50-
<a href="https://example.com"><VFXSpan>Yo</VFXSpan></a>
17+
Install via npm:
5118

52-
// NG: link styles are not rendered correctly
53-
<VFXSpan><a href="https://example.com">Yo</a></VFXSpan>
5419
```
55-
56-
### Custom Shader
57-
58-
```ts
59-
import { VFXSpan } from 'react-vfx';
60-
61-
const blink = `
62-
uniform vec2 resolution;
63-
uniform vec2 offset;
64-
uniform float time;
65-
uniform sampler2D src;
66-
67-
void main() {
68-
vec2 uv = (gl_FragCoord.xy - offset) / resolution;
69-
gl_FragColor = texture2D(src, uv) * step(.5, fract(time));
70-
}
71-
`;
72-
73-
export default = () => (
74-
<VFXSpan shader={blink}></VFXSpan>
75-
);
20+
npm i @vfx-js/core
7621
```
7722

78-
<!-- #### Passing Uniforms
79-
80-
```ts
81-
type Uniform = THREE.IUniform | number | number[];
23+
Then create `VFX` object in your script:
8224

83-
type UniformObject = {
84-
[name: string]: THREE.IUniform;
85-
}
25+
```js
26+
import { VFX } from '@vfx-js/core';
8627

87-
type Uniforms = UniformObject | () => UniformObject;
88-
```
28+
const img = document.querySelector('#img');
8929

90-
```ts
91-
import React, { useState } from 'react';
92-
93-
export default () => {
94-
const [count, setCount] = useState(0);
95-
96-
return (
97-
<VFXImg src="main_texture.png"
98-
uniforms={{
99-
foo: [1, 2, 3], // vec3
100-
foo: [1, 2, 3], // vec3
101-
foo: [1, 2, 3] // vec3
102-
}}/>
103-
104-
<button type="button" onClick={() => setCount(count + 1)}>
105-
<VFXImg src="main_texture.png"
106-
shader={animated}
107-
uniforms={{ count }}/>
108-
);
109-
};
30+
const vfx = new VFX();
31+
vfx.add(img, { shader: "glitch", overflow: 100 });
11032
```
11133

112-
### Textures
113-
114-
```ts
115-
<VFXImg src="main_texture.png" textures={["tex1.png", "tex2.png"]}/>
116-
```
34+
## Examples
11735

118-
```glsl
119-
uniform sampler2D input;
120-
uniform sampler2D texture1;
121-
uniform sampler2D texture2;
122-
``` -->
36+
TBD: See VFX-JS website for now.
12337

124-
## Future work
38+
https://amagi.dev/vfx-js/
12539

126-
- Passing custom uniforms
127-
- Passing custom textures
12840

12941
## Author
13042

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-vfx-monorepo",
2+
"name": "vfx-js-monorepo",
33
"private": true,
44
"packageManager": "[email protected]",
55
"workspaces": [
@@ -23,13 +23,13 @@
2323
"turbo": "^2.0.3"
2424
},
2525
"author": "AMAGI <[email protected]> (https://amagi.dev/)",
26-
"homepage": "https://github.com/fand/react-vfx#readme",
26+
"homepage": "https://github.com/fand/vfx-js#readme",
2727
"repository": {
2828
"type": "git",
29-
"url": "git+https://github.com/fand/react-vfx.git"
29+
"url": "git+https://github.com/fand/vfx-js.git"
3030
},
3131
"bugs": {
32-
"url": "https://github.com/fand/react-vfx/issues"
32+
"url": "https://github.com/fand/vfx-js/issues"
3333
},
3434
"keywords": [],
3535
"license": "MIT"

packages/docs-react-vfx/src/dom/UsageSection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const UsageSection: React.VFC = () => (
6363
<p>
6464
See{" "}
6565
<a
66-
href="https://github.com/fand/react-vfx"
66+
href="https://github.com/fand/vfx-js/tree/main/packages/react-vfx"
6767
target="_blank"
6868
rel="noopener noreferrer"
6969
>

packages/docs/index.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060

6161
<header>
6262
<div class="HeaderTop GitHub">
63-
<a
64-
href="https://github.com/fand/react-vfx/tree/main/packages/vfx-js"
65-
target="_blank"
63+
<a href="https://github.com/fand/vfx-js" target="_blank"
6664
>GITHUB</a
6765
>
6866
</div>

0 commit comments

Comments
 (0)