1const PLANE_WIDTH=50;const PLANE_HEIGHT=80;const COLORS_COUNT=5;class NeatGradient{constructor(config){const{ref,speed=4,horizontalPressure=3,verticalPressure=3,waveFrequencyX=5,waveFrequencyY=5,waveAmplitude=3,colors,highlights=4,shadows=4,colorSaturation=0,colorBrightness=1,colorBlending=5,grainScale=2,grainIntensity=0.55,grainSparsity=0.0,grainSpeed=0.1,wireframe=!1,backgroundColor="#FFF",backgroundAlpha=1.0,resolution=1,seed}=config;this._ref=ref;this._speed=-1;this._horizontalPressure=-1;this._verticalPressure=-1;this._waveFrequencyX=-1;this._waveFrequencyY=-1;this._waveAmplitude=-1;this._shadows=-1;this._highlights=-1;this._saturation=-1;this._brightness=-1;this._grainScale=-1;this._grainIntensity=-1;this._grainSparsity=-1;this._grainSpeed=-1;this._colorBlending=0;this._colors=[];this._wireframe=!1;this._backgroundColor="#FFFFFF";this._backgroundAlpha=1.0;this.clock=new THREE.Clock();this.requestRef=-1;this.destroy=this.destroy.bind(this);this._initScene=this._initScene.bind(this);this._buildMaterial=this._buildMaterial.bind(this);this.speed=speed;this.horizontalPressure=horizontalPressure;this.verticalPressure=verticalPressure;this.waveFrequencyX=waveFrequencyX;this.waveFrequencyY=waveFrequencyY;this.waveAmplitude=waveAmplitude;this.colorBlending=colorBlending;this.grainScale=grainScale;this.grainIntensity=grainIntensity;this.grainSparsity=grainSparsity;this.grainSpeed=grainSpeed;this.colors=colors;this.shadows=shadows;this.highlights=highlights;this.colorSaturation=colorSaturation;this.colorBrightness=colorBrightness;this.wireframe=wireframe;this.backgroundColor=backgroundColor;this.backgroundAlpha=backgroundAlpha;this.sceneState=this._initScene(resolution);let tick=seed!==undefined?seed:getElapsedSecondsInLastHour();const render=()=>{const{renderer,camera,scene,meshes}=this.sceneState;renderer.setClearColor(this._backgroundColor,this._backgroundAlpha);meshes.forEach((mesh)=>{const width=this._ref.width,height=this._ref.height;const colors=[...this._colors.map(color=>{let threeColor=new THREE.Color();threeColor.setStyle(color.color);return{is_active:color.enabled?1.0:0.0,color:threeColor,influence:color.influence}}),...Array.from({length:COLORS_COUNT-this._colors.length}).map(()=>({is_active:0.0,color:new THREE.Color(0x000000)}))];tick+=this.clock.getDelta()*this._speed;mesh.material.uniforms.u_time.value=tick;mesh.material.uniforms.u_resolution.value=new THREE.Vector2(width,height);mesh.material.uniforms.u_color_pressure.value=new THREE.Vector2(this._horizontalPressure,this._verticalPressure);mesh.material.uniforms.u_wave_frequency_x.value=this._waveFrequencyX;mesh.material.uniforms.u_wave_frequency_y.value=this._waveFrequencyY;mesh.material.uniforms.u_wave_amplitude.value=this._waveAmplitude;mesh.material.uniforms.u_plane_width.value=PLANE_WIDTH;mesh.material.uniforms.u_plane_height.value=PLANE_HEIGHT;mesh.material.uniforms.u_color_blending.value=this._colorBlending;mesh.material.uniforms.u_colors.value=colors;mesh.material.uniforms.u_colors_count.value=COLORS_COUNT;mesh.material.uniforms.u_shadows.value=this._shadows;mesh.material.uniforms.u_highlights.value=this._highlights;mesh.material.uniforms.u_saturation.value=this._saturation;mesh.material.uniforms.u_brightness.value=this._brightness;mesh.material.uniforms.u_grain_intensity.value=this._grainIntensity;mesh.material.uniforms.u_grain_sparsity.value=this._grainSparsity;mesh.material.uniforms.u_grain_speed.value=this._grainSpeed;mesh.material.uniforms.u_grain_scale.value=this._grainScale;mesh.material.wireframe=this._wireframe});renderer.render(scene,camera);this.requestRef=requestAnimationFrame(render)};const setSize=()=>{const{renderer}=this.sceneState;const canvas=renderer.domElement;const width=canvas.clientWidth;const height=canvas.clientHeight;this.sceneState.renderer.setSize(width,height,!1);updateCamera(this.sceneState.camera,width,height)};this.sizeObserver=new ResizeObserver(entries=>{setSize()});this.sizeObserver.observe(ref);render()} 2destroy(){if(this.requestRef!==-1){cancelAnimationFrame(this.requestRef);this.requestRef=-1} 3if(this.sizeObserver){this.sizeObserver.disconnect()}} 4set speed(speed){this._speed=speed/20} 5set horizontalPressure(horizontalPressure){this._horizontalPressure=horizontalPressure/4} 6set verticalPressure(verticalPressure){this._verticalPressure=verticalPressure/4} 7set waveFrequencyX(waveFrequencyX){this._waveFrequencyX=waveFrequencyX*0.04} 8set waveFrequencyY(waveFrequencyY){this._waveFrequencyY=waveFrequencyY*0.04} 9set waveAmplitude(waveAmplitude){this._waveAmplitude=waveAmplitude*.75} 10set colors(colors){this._colors=colors} 11set highlights(highlights){this._highlights=highlights/100} 12set shadows(shadows){this._shadows=shadows/100} 13set colorSaturation(colorSaturation){this._saturation=colorSaturation/10} 14set colorBrightness(colorBrightness){this._brightness=colorBrightness} 15set colorBlending(colorBlending){this._colorBlending=colorBlending?colorBlending/10:0.5} 16set grainScale(grainScale){this._grainScale=grainScale==0?1:grainScale} 17set grainIntensity(grainIntensity){this._grainIntensity=grainIntensity} 18set grainSparsity(grainSparsity){this._grainSparsity=grainSparsity} 19set grainSpeed(grainSpeed){this._grainSpeed=grainSpeed} 20set wireframe(wireframe){this._wireframe=wireframe} 21set resolution(resolution){this.sceneState=this._initScene(resolution)} 22set backgroundColor(backgroundColor){this._backgroundColor=backgroundColor} 23set backgroundAlpha(backgroundAlpha){this._backgroundAlpha=backgroundAlpha} 24_initScene(resolution){const width=this._ref.width,height=this._ref.height;const renderer=new THREE.WebGLRenderer({alpha:!0,canvas:this._ref});renderer.setClearColor(0xFF0000,.5);renderer.setSize(width,height,!1);const meshes=[];const scene=new THREE.Scene();const material=this._buildMaterial(width,height);const geo=new THREE.PlaneGeometry(PLANE_WIDTH,PLANE_HEIGHT,240*resolution,240*resolution);const plane=new THREE.Mesh(geo,material);plane.rotation.x=-Math.PI/3.5;plane.position.z=-1;meshes.push(plane);
24scene.add(plane);const camera=new THREE.OrthographicCamera(0.0,0.0,0.0,0.0,0.0,0.0);camera.position.z=5;updateCamera(camera,width,height);return{renderer,camera,scene,meshes,resolution}} 25_buildMaterial(width,height){const colors=[...this._colors.map(color=>({is_active:color.enabled?1.0:0.0,color:new THREE.Color(color.color),influence:color.influence})),...Array.from({length:COLORS_COUNT-this._colors.length}).map(()=>({is_active:0.0,color:new THREE.Color(0x000000)}))];const uniforms={u_time:{value:0},u_color_pressure:{value:new THREE.Vector2(this._horizontalPressure,this._verticalPressure)},u_wave_frequency_x:{value:this._waveFrequencyX},u_wave_frequency_y:{value:this._waveFrequencyY},u_wave_amplitude:{value:this._waveAmplitude},u_resolution:{value:new THREE.Vector2(width,height)},u_colors:{value:colors},u_colors_count:{value:COLORS_COUNT},u_plane_width:{value:PLANE_WIDTH},u_plane_height:{value:PLANE_HEIGHT},u_shadows:{value:this._shadows},u_highlights:{value:this._highlights},u_saturation:{value:this._saturation},u_brightness:{value:this._brightness},u_grain_intensity:{value:this._grainIntensity},u_grain_sparsity:{value:this._grainSparsity},u_grain_scale:{value:this._grainScale},u_grain_speed:{value:this._grainSpeed},u_color_blending:{value:this._colorBlending}};const material=new THREE.ShaderMaterial({uniforms:uniforms,vertexShader:buildUniforms()+buildNoise()+buildColorFunctions()+buildVertexShader(),fragmentShader:buildUniforms()+buildColorFunctions()+buildNoise()+buildFragmentShader()});material.wireframe=this._wireframe;return material}} 26function updateCamera(camera,width,height){const viewPortAreaRatio=1000000;const areaViewPort=width*height;const targetPlaneArea=areaViewPort/viewPortAreaRatio*PLANE_WIDTH*PLANE_HEIGHT/1.5;const ratio=width/height;const targetWidth=Math.sqrt(targetPlaneArea*ratio);const targetHeight=targetPlaneArea/targetWidth;const left=-PLANE_WIDTH/2;const right=Math.min((left+targetWidth)/1.5,PLANE_WIDTH/2);const top=PLANE_HEIGHT/4;const bottom=Math.max((top-targetHeight)/2,-PLANE_HEIGHT/4);const near=-100;const far=1000;if(camera instanceof THREE.OrthographicCamera){camera.left=left;camera.right=right;camera.top=top;camera.bottom=bottom;camera.near=near;camera.far=far;camera.updateProjectionMatrix()}else if(camera instanceof THREE.PerspectiveCamera){camera.aspect=width/height;camera.updateProjectionMatrix()}} 27function buildVertexShader(){return ` 28 void main() { 29 vUv = uv; 30 v_displacement_amount = cnoise(vec3( 31 u_wave_frequency_x * position.x + u_time, 32 u_wave_frequency_y * position.y + u_time, 33 u_time 34 )); 35 vec3 color = u_colors[0].color; 36 vec2 noise_cord = vUv * u_color_pressure; 37 const float minNoise = .0; 38 const float maxNoise = .9; 39 40 for (int i = 1; i < u_colors_count; i++) { 41 if(u_colors[i].is_active == 1.0){ 42 float noiseFlow = (1. + float(i)) / 30.; 43 float noiseSpeed = (1. + float(i)) * 0.11; 44 float noiseSeed = 13. + float(i) * 7.; 45 float noise = snoise( 46 vec3( 47 noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2., 48 noise_cord.y * u_color_pressure.y, 49 u_time * noiseSpeed 50 ) + noiseSeed 51 ) - (.1 * float(i)) + (.5 * u_color_blending); 52 noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise); 53 vec3 nextColor = u_colors[i].color; 54 color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise)); 55 } 56 } 57 v_color = color; 58 vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude; 59 gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 ); 60 v_new_position = gl_Position; 61 }`} 62function buildFragmentShader(){return ` 63 float random(vec2 p) { 64 return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453); 65 } 66 67 float fbm(vec3 x) { 68 float value = 0.0; 69 float amplitude = 0.5; 70 float frequency = 1.0; 71 for (int i = 0; i < 4; i++) { 72 value += amplitude * snoise(x * frequency);
73 frequency *= 2.0; 74 amplitude *= 0.5; 75 } 76 return value; 77 } 78 79 void main() { 80 vec3 color = v_color; 81 color += pow(v_displacement_amount, 1.0) * u_highlights; 82 color -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows; 83 color = saturation(color, 1.0 + u_saturation); 84 color = color * u_brightness; 85 86 vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale; 87 float grain = (u_grain_speed != 0.0) ? fbm(vec3(noiseCoords, u_time * u_grain_speed)) : fbm(vec3(noiseCoords, 0.0)); 88 89 grain = grain * 0.5 + 0.5; 90 grain -= 0.5; 91 grain = (grain > u_grain_sparsity) ? grain : 0.0; 92 grain *= u_grain_intensity; 93 color += vec3(grain); 94 95 gl_FragColor = vec4(color, 1.0); 96 }`} 97function buildUniforms(){return ` 98 precision highp float; 99 100 struct Color { 101 float is_active; 102 vec3 color; 103 float value; 104 }; 105 106 uniform float u_grain_intensity; 107 uniform float u_grain_sparsity; 108 uniform float u_grain_scale; 109 uniform float u_grain_speed; 110 uniform float u_time; 111 uniform float u_wave_amplitude; 112 uniform float u_wave_frequency_x; 113 uniform float u_wave_frequency_y; 114 uniform vec2 u_color_pressure; 115 uniform float u_plane_width; 116 uniform float u_plane_height; 117 uniform float u_shadows; 118 uniform float u_highlights; 119 uniform float u_saturation; 120 uniform float u_brightness; 121 uniform float u_color_blending; 122 uniform int u_colors_count; 123 uniform Color u_colors[5]; 124 uniform vec2 u_resolution; 125 126 varying vec2 vUv; 127 varying vec4 v_new_position; 128 varying vec3 v_color; 129 varying float v_displacement_amount;`} 130function buildNoise(){return ` 131 vec3 mod289(vec3 x) { 132 return x - floor(x * (1.0 / 289.0)) * 289.0; 133 } 134 135 vec4 mod289(vec4 x) { 136 return x - floor(x * (1.0 / 289.0)) * 289.0; 137 } 138 139 vec4 permute(vec4 x) { 140 return mod289(((x*34.0)+1.0)*x); 141 } 142 143 vec4 taylorInvSqrt(vec4 r) { 144 return 1.79284291400159 - 0.85373472095314 * r; 145 } 146 147 vec3 fade(vec3 t) { 148 return t*t*t*(t*(t*6.0-15.0)+10.0); 149 } 150 151 float snoise(vec3 v) { 152 const vec2 C = vec2(1.0/6.0, 1.0/3.0); 153 const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); 154 155 vec3 i = floor(v + dot(v, C.yyy)); 156 vec3 x0 = v - i + dot(i, C.xxx); 157 158 vec3 g = step(x0.yzx, x0.xyz); 159 vec3 l = 1.0 - g; 160 vec3 i1 = min(g.xyz, l.zxy); 161 vec3 i2 = max(g.xyz, l.zxy); 162 163 vec3 x1 = x0 - i1 + C.xxx; 164 vec3 x2 = x0 - i2 + C.yyy; 165 vec3 x3 = x0 - D.yyy; 166 167 i = mod289(i); 168 vec4 p = permute(permute(permute( 169 i.z + vec4(0.0, i1.z, i2.z, 1.0)) 170 + i.y + vec4(0.0, i1.y, i2.y, 1.0)) 171 + i.x + vec4(0.0, i1.x, i2.x, 1.0)); 172 173 float n_ = 0.142857142857; 174 vec3 ns = n_ * D.wyz - D.xzx; 175 176 vec4 j = p - 49.0 * floor(p * ns.z * ns.z); 177 178 vec4 x_ = floor(j * ns.z); 179 vec4 y_ = floor(j - 7.0 * x_); 180 181 vec4 x = x_ *ns.x + ns.yyyy; 182 vec4 y = y_ *ns.x + ns.yyyy; 183 vec4 h = 1.0 - abs(x) - abs(y); 184 185 vec4 b0 = vec4(x.xy, y.xy); 186 vec4 b1 = vec4(x.zw, y.zw); 187 188 vec4 s0 = floor(b0)*2.0 + 1.0; 189 vec4 s1 = floor(b1)*2.0 + 1.0; 190 vec4 sh = -step(h, vec4(0.0)); 191 192 vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy; 193 vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww; 194 195 vec3 p0 = vec3(a0.xy,h.x); 196 vec3 p1 = vec3(a0.zw,h.y); 197 vec3 p2 = vec3(a1.xy,h.z); 198 vec3 p3 = vec3(a1.zw,h.w); 199 200 vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); 201 p0 *= norm.x; 202 p1 *= norm.y; 203 p2 *= norm.z; 204 p3 *= norm.w; 205 206 vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); 207 m = m * m; 208 return 42.0 * dot(m*m, vec4(dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3))); 209 } 210 211 float cnoise(vec3 P) { 212 vec3 Pi0 = floor(P); 213 vec3 Pi1 = Pi0 + vec3(1.0); 214 Pi0 = mod289(Pi0);
215 Pi1 = mod289(Pi1); 216 vec3 Pf0 = fract(P); 217 vec3 Pf1 = Pf0 - vec3(1.0); 218 vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); 219 vec4 iy = vec4(Pi0.yy, Pi1.yy); 220 vec4 iz0 = Pi0.zzzz; 221 vec4 iz1 = Pi1.zzzz; 222 223 vec4 ixy = permute(permute(ix) + iy); 224 vec4 ixy0 = permute(ixy + iz0); 225 vec4 ixy1 = permute(ixy + iz1); 226 227 vec4 gx0 = ixy0 * (1.0 / 7.0); 228 vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5; 229 gx0 = fract(gx0); 230 vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); 231 vec4 sz0 = step(gz0, vec4(0.0)); 232 gx0 -= sz0 * (step(0.0, gx0) - 0.5); 233 gy0 -= sz0 * (step(0.0, gy0) - 0.5); 234 235 vec4 gx1 = ixy1 * (1.0 / 7.0); 236 vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5; 237 gx1 = fract(gx1); 238 vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); 239 vec4 sz1 = step(gz1, vec4(0.0)); 240 gx1 -= sz1 * (step(0.0, gx1) - 0.5); 241 gy1 -= sz1 * (step(0.0, gy1) - 0.5); 242 243 vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); 244 vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); 245 vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); 246 vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); 247 vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); 248 vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); 249 vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); 250 vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); 251 252 vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); 253 g000 *= norm0.x; 254 g010 *= norm0.y; 255 g100 *= norm0.z; 256 g110 *= norm0.w; 257 vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); 258 g001 *= norm1.x; 259 g011 *= norm1.y; 260 g101 *= norm1.z; 261 g111 *= norm1.w; 262 263 float n000 = dot(g000, Pf0); 264 float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); 265 float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); 266 float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); 267 float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); 268 float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); 269 float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); 270 float n111 = dot(g111, Pf1); 271 272 vec3 fade_xyz = fade(Pf0); 273 vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); 274 vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); 275 float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); 276 return 2.2 * n_xyz; 277 }`} 278function buildColorFunctions(){return ` 279 vec3 saturation(vec3 rgb, float adjustment) { 280 const vec3 W = vec3(0.2125, 0.7154, 0.0721); 281 vec3 intensity = vec3(dot(rgb, W));
282 return mix(intensity, rgb, adjustment); 283 }`} 284function getElapsedSecondsInLastHour(){const now=new Date();const minutes=now.getMinutes();const seconds=now.getSeconds();return(minutes*60)+seconds}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.