twgljs实现webgl canvas文字圈圈闪烁动画效果代码
代码语言:html
所属分类:动画
代码描述:twgljs实现webgl canvas文字圈圈闪烁动画效果代码
代码标签: twgl webgl canvas 文字 圈圈 闪烁 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
html {
height: 100%;
}
body {
background: #333;
overflow: hidden;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
}
canvas {
height: 100%;
width: 100%;
margin: auto;
}
</style>
</head>
<body translate="no">
<canvas id="canvas"></canvas>
<!-- VertexShader code here -->
<script id="vertexShader" type="x-shader/x-vertex">#version 300 es
precision highp float;
in vec4 position;
void main() {
gl_Position = vec4( position );
}
</script>
<!-- FragmentShader code here -->
<script id="fragmentShader" type="x-shader/x-fragment">#version 300 es
precision highp float;
out vec4 fragColor;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec4 u_mouse;
#define R u_resolution
#define T u_time
#define M u_mouse
#define PI 3.141592653
#define PI2 6.283185307
#define MIN_DIST 1e-4
#define MAX_DIST 55.
// constants
const float sz = .425;
const float hf = sz/2.;
const vec4 bz = vec4(.075,.055,.035,.0);
const vec4 bo = vec4(.175,.15,.075,.025);
const vec2 oa = vec2(.15,.1);
vec3 hue(float t){ return .55 + .45*cos(PI2*t*(vec3(.95,.97,.98)+vec3(1,.5,.2))); }
float hash21(vec2 p){return fract(sin(dot(p,vec2(27.619,57.583)))*4358.5453);}
mat2 rot(float a){return mat2(cos(a),sin(a),-sin(a),cos(a)); }
float box( in vec2 p, in vec2 b ){
vec2 d = abs(p)-b;
return length(max(d,0.))+min(max(d.x,d.y),0.);
}
float rbox( in vec2 p, in vec2 b, in vec4 r ) {
r.xy = (p.x>0.)?r.xy : r.zw;
r.x = (p.y>0.)?r.x : r.y;
vec2 q = abs(p)-b+r.x;
return min(max(q.x,q.y),0.)+length(max(q,0.))-r.x;
}
// special
float getdp(vec2 p) {
float bt = length(p)-.075;
return bt;
}
// number
float get3(vec2 p) {
vec2 of = vec2(0,.075);
float bt = max(
rbox(p-of,oa,bz.xxww),
-rbox(p-of+vec2(.05,0),vec2(.15,.05),bz.z.........完整代码请登录后点击上方下载按钮下载查看
网友评论0