-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartyround.js
More file actions
59 lines (52 loc) · 1.18 KB
/
Copy pathpartyround.js
File metadata and controls
59 lines (52 loc) · 1.18 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const canvasSketch = require("canvas-sketch");
const createShader = require("canvas-sketch-util/shader");
const glsl = require("glslify");
// Setup our sketch
const settings = {
context: "webgl",
animate: true,
};
const colors = [
"#161516",
"#72AEDC",
"#B4558B",
"#BEDBD9",
"#80574B",
"#D08247",
"#3A619A",
"#BE3B45",
"#BF6B85",
"#CCCB5C",
"#426B40",
"#DA3A33",
];
// Your glsl code
const frag = glsl(`
precision highp float;
uniform float time;
varying vec2 vUv;
uniform sampler2D colors;
void main () {
vec3 color = 0.5 + 0.5 * cos(time + vUv.xyx + vec3(0.0, 2.0, 4.0));
gl_FragColor = texture2D(colors, vUv);
}
`);
// Your sketch, which simply returns the shader
const sketch = ({ gl }) => {
const image = new Image();
image.src = "./partyround-colors.png";
// Create the shader and return it
return createShader({
// Pass along WebGL context
gl,
// Specify fragment and/or vertex shader strings
frag,
// Specify additional uniforms to pass down to the shaders
uniforms: {
// Expose props from canvas-sketch
time: ({ time }) => time,
texture: image,
},
});
};
canvasSketch(sketch, settings);