-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.tsx
42 lines (39 loc) · 1.07 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { ExpoWebGLRenderingContext, GLView, GLViewProps } from "expo-gl";
import React, { useState } from "react";
import { Gradient, GradientConfig } from "./gradient";
export { Gradient, GradientConfig } from "./gradient";
export {
MiniGl,
Material,
UniformTypes,
UniformOptions,
Uniform,
Orientation,
PlaneGeometry,
Mesh,
AttributeOptions,
Attribute
} from "./minigl";
export interface GLGradientProps
extends Omit<Partial<GLViewProps>, "onContextCreate" | "children"> {
config?: Partial<GradientConfig>;
getGradient?: (gradient: Gradient) => void;
}
export default function GLGradient({
config,
getGradient,
...props
}: GLGradientProps) {
const [gradient, setGradient] = useState<Gradient | null>(null);
return (
<GLView
{...props}
onContextCreate={(gl: ExpoWebGLRenderingContext) => {
let g = new Gradient(gl, config);
gl.clearColor(1, 1, 1, 1);
setGradient(g);
getGradient?.(g);
}}
/>
);
}