@firecms/neat 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NeatGradient.js +6 -1
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +3 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/NeatGradient.ts +6 -1
package/dist/index.umd.js
CHANGED
|
@@ -479,5 +479,5 @@ https://neat.firecms.co`,"font-weight: bold; font-size: 14px; color: #FF5772;","
|
|
|
479
479
|
`+te()+`
|
|
480
480
|
`+me,w=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(w,x),t.compileShader(w),t.getShaderParameter(w,t.COMPILE_STATUS)||(console.log("FRAGMENT_SHADER_ERROR_START"),console.log("Fragment shader error: ",t.getShaderInfoLog(w)),console.log("GL Error Code:",t.getError()),console.log("Fragment Shader Source Dump:"),console.log(x.split(`
|
|
481
481
|
`).map((S,U)=>`${U+1}: ${S}`).join(`
|
|
482
|
-
`)),console.log("FRAGMENT_SHADER_ERROR_END"));const u=t.createProgram();t.attachShader(u,g),t.attachShader(u,w),t.linkProgram(u),t.getProgramParameter(u,t.LINK_STATUS)||(console.log("PROGRAM_LINK_ERROR_START"),console.log("Program linking error: ",t.getProgramInfoLog(u)),console.log("GL Error Code:",t.getError()),console.log("PROGRAM_LINK_ERROR_END")),t.useProgram(u);const T=new ye(0,0,0,0,0,1e3);T.position=[0,0,5],H(T,i,r,N,X,this._shapeType,this._cameraZoom);const A=t.getAttribLocation(u,"position"),D=t.getAttribLocation(u,"normal"),m=t.getAttribLocation(u,"uv");t.enableVertexAttribArray(A),t.bindBuffer(t.ARRAY_BUFFER,a),t.vertexAttribPointer(A,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(D),t.bindBuffer(t.ARRAY_BUFFER,h),t.vertexAttribPointer(D,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(m),t.bindBuffer(t.ARRAY_BUFFER,p),t.vertexAttribPointer(m,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,c);const F=t.getUniformLocation(u,"projectionMatrix");t.uniformMatrix4fv(F,!1,T.projectionMatrix.elements);const C=t.getUniformLocation(u,"u_plane_width");t.uniform1f(C,N);const z=t.getUniformLocation(u,"u_plane_height");t.uniform1f(z,X);const M=t.getUniformLocation(u,"u_colors_count");t.uniform1i(M,j);const P=["projectionMatrix","modelViewMatrix","u_time","u_resolution","u_color_pressure","u_wave_frequency_x","u_wave_frequency_y","u_wave_amplitude","u_colors_count","u_plane_width","u_plane_height","u_shadows","u_highlights","u_grain_intensity","u_grain_sparsity","u_grain_scale","u_grain_speed","u_flow_distortion_a","u_flow_distortion_b","u_flow_scale","u_flow_ease","u_flow_enabled","u_y_offset","u_y_offset_wave_multiplier","u_y_offset_color_multiplier","u_y_offset_flow_multiplier","u_procedural_texture","u_enable_procedural_texture","u_texture_ease","u_transparent_texture_void","u_saturation","u_brightness","u_color_blending","u_domain_warp_enabled","u_domain_warp_intensity","u_domain_warp_scale","u_vignette_intensity","u_vignette_radius","u_fresnel_enabled","u_fresnel_power","u_fresnel_intensity","u_fresnel_color","u_iridescence_enabled","u_iridescence_intensity","u_iridescence_speed","u_bloom_intensity","u_bloom_threshold","u_chromatic_aberration","u_shape_type","u_silhouette_fade","u_cylinder_fade","u_ribbon_fade","u_flat_shading"],E={attributes:{position:A,normal:D,uv:m},uniforms:{}};P.forEach(S=>{E.uniforms[S]=t.getUniformLocation(u,S)});for(let S=0;S<j;S++)E.uniforms[`u_colors[${S}].is_active`]=t.getUniformLocation(u,`u_colors[${S}].is_active`),E.uniforms[`u_colors[${S}].color`]=t.getUniformLocation(u,`u_colors[${S}].color`),E.uniforms[`u_colors[${S}].influence`]=t.getUniformLocation(u,`u_colors[${S}].influence`);return this._initialized=!0,this._uniformsDirty=!0,this._colorsChanged=!0,this._textureDirty=!0,t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.enable(t.DEPTH_TEST),{gl:t,program:u,buffers:{position:a,normal:h,uv:p,index:c,wireframeIndex:d},locations:E,camera:T,indexCount:_.length,wireframeIndexCount:b.length,indexType:_ instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT}}_createProceduralTexture(e){this._sourceCanvas||(this._sourceCanvas=document.createElement("canvas"),this._sourceCanvas.width=1024,this._sourceCanvas.height=1024,this._sourceCtx=this._sourceCanvas.getContext("2d"));const r=this._sourceCanvas,t=this._sourceCtx;if(!t)return null;let y=this._textureSeed;const v=this._textureSeed;function s(){const m=Math.sin(y++)*1e4;return m-Math.floor(m)}const l=m=>{y=v+m},_=this._colors.filter(m=>m.enabled).map(m=>m.color);if(_.length===0)return null;const b=this._shapeType!=="plane",a=b?[-1,0,1]:[0],h=b?[-1,0,1]:[0];function p(m){const F=parseInt(m.replace("#",""),16);return{r:F>>16&255,g:F>>8&255,b:F&255}}function c(m,F,C){return"#"+((1<<24)+(Math.round(m)<<16)+(Math.round(F)<<8)+Math.round(C)).toString(16).slice(1).padStart(6,"0")}const d=()=>{const m=_[Math.floor(s()*_.length)],F=_[Math.floor(s()*_.length)],C=s()*this._textureColorBlending,z=p(m),M=p(F),P=z.r+(M.r-z.r)*C,E=z.g+(M.g-z.g)*C,S=z.b+(M.b-z.b)*C;return c(P,E,S)},R=this._proceduralBackgroundColor||"#000000";t.fillStyle=R,t.fillRect(0,0,1024,1024);const g=t.createLinearGradient(0,0,0,1024);g.addColorStop(0,d()),g.addColorStop(1,d()),t.fillStyle=g,t.fillRect(0,0,1024,1024);for(let m=0;m<this._textureShapeTriangles;m++){const F=d(),C=s()*1024,z=s()*1024,M=100+s()*300,P=(s()-.5)*M,E=(s()-.5)*M,S=(s()-.5)*M,U=(s()-.5)*M;for(const B of a)for(const O of h){t.fillStyle=F,t.beginPath();const I=C+B*1024,Y=z+O*1024;t.moveTo(I,Y),t.lineTo(I+P,Y+E),t.lineTo(I+S,Y+U),t.fill()}}for(let m=0;m<this._textureShapeCircles;m++){const F=d(),C=10+s()*50,z=s()*1024,M=s()*1024,P=50+s()*150;for(const E of a)for(const S of h)t.strokeStyle=F,t.lineWidth=C,t.beginPath(),t.arc(z+E*1024,M+S*1024,P,0,Math.PI*2),t.stroke()}for(let m=0;m<this._textureShapeBars;m++){const F=d(),C=s()*1024,z=s()*1024,M=s()*Math.PI;for(const P of a)for(const E of h)t.fillStyle=F,t.save(),t.translate(C+P*1024,z+E*1024),t.rotate(M),t.fillRect(-150,-25,300,50),t.restore()}t.lineWidth=15,t.lineCap="round";for(let m=0;m<this._textureShapeSquiggles;m++){const F=d(),C=s()*1024,z=s()*1024,M=[];let P=0,E=0;for(let S=0;S<4;S++){const U=P+(s()-.5)*300,B=E+(s()-.5)*300;M.push({cx1:P+(s()-.5)*300,cy1:E+(s()-.5)*300,cx2:P+(s()-.5)*300,cy2:E+(s()-.5)*300,ex:U,ey:B}),P=U,E=B}for(const S of a)for(const U of h){t.strokeStyle=F,t.beginPath();const B=C+S*1024,O=z+U*1024;t.moveTo(B,O);for(const I of M)t.bezierCurveTo(B+I.cx1,O+I.cy1,B+I.cx2,O+I.cy2,B+I.ex,O+I.ey);t.stroke()}}l(5e4),this._maskedCanvas||(this._maskedCanvas=document.createElement("canvas"),this._maskedCanvas.width=1024,this._maskedCanvas.height=1024,this._maskedCtx=this._maskedCanvas.getContext("2d"));const x=this._maskedCanvas,w=this._maskedCtx;if(!w)return null;this._transparentTextureVoid?w.clearRect(0,0,1024,1024):(w.fillStyle=R,w.fillRect(0,0,1024,1024));let u=0;const T=[];for(;u<1024;)if(s()<this._textureVoidLikelihood){const F=this._textureVoidWidthMin+s()*(this._textureVoidWidthMax-this._textureVoidWidthMin);T.push({type:"void",x:u,width:F}),u+=F}else{const F=50+s()*200;T.push({type:"matter",x:u,width:F}),u+=F}for(const m of T)if(m.type==="matter"){const F=m.x,C=Math.min(m.x+m.width,1024);let z=F;for(;z<C;){const M=(2+s()*20)/this._textureBandDensity,P=Math.floor(s()*1024);w.drawImage(r,P,0,M,1024,z,0,M,1024),z+=M}}const A=e.createTexture();e.bindTexture(e.TEXTURE_2D,A),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,x),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D);const D=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");if(D){const m=e.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT);e.texParameterf(e.TEXTURE_2D,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(16,m))}return A}get silhouetteFade(){return this._silhouetteFade}set silhouetteFade(e){this._silhouetteFade!==e&&(this._silhouetteFade=e,this._uniformsDirty=!0)}get cylinderFade(){return this._cylinderFade}set cylinderFade(e){this._cylinderFade!==e&&(this._cylinderFade=e,this._uniformsDirty=!0)}get ribbonFade(){return this._ribbonFade}set ribbonFade(e){this._ribbonFade!==e&&(this._ribbonFade=e,this._uniformsDirty=!0)}get flatShading(){return this._flatShading}set flatShading(e){this._flatShading!==e&&(this._flatShading=e,this._uniformsDirty=!0)}get domainWarpEnabled(){return this._domainWarpEnabled}set domainWarpEnabled(e){this._domainWarpEnabled!==e&&(this._domainWarpEnabled=e,this._uniformsDirty=!0)}get domainWarpIntensity(){return this._domainWarpIntensity}set domainWarpIntensity(e){this._domainWarpIntensity!==e&&(this._domainWarpIntensity=e,this._uniformsDirty=!0)}get domainWarpScale(){return this._domainWarpScale}set domainWarpScale(e){this._domainWarpScale!==e&&(this._domainWarpScale=e,this._uniformsDirty=!0)}get vignetteIntensity(){return this._vignetteIntensity}set vignetteIntensity(e){this._vignetteIntensity!==e&&(this._vignetteIntensity=e,this._uniformsDirty=!0)}get vignetteRadius(){return this._vignetteRadius}set vignetteRadius(e){this._vignetteRadius!==e&&(this._vignetteRadius=e,this._uniformsDirty=!0)}get fresnelEnabled(){return this._fresnelEnabled}set fresnelEnabled(e){this._fresnelEnabled!==e&&(this._fresnelEnabled=e,this._uniformsDirty=!0)}get fresnelPower(){return this._fresnelPower}set fresnelPower(e){this._fresnelPower!==e&&(this._fresnelPower=e,this._uniformsDirty=!0)}get fresnelIntensity(){return this._fresnelIntensity}set fresnelIntensity(e){this._fresnelIntensity!==e&&(this._fresnelIntensity=e,this._uniformsDirty=!0)}get fresnelColor(){return this._fresnelColor}set fresnelColor(e){this._fresnelColor!==e&&(this._fresnelColor=e,this._fresnelColorRgb=this._hexToRgb(e),this._uniformsDirty=!0)}get iridescenceEnabled(){return this._iridescenceEnabled}set iridescenceEnabled(e){this._iridescenceEnabled!==e&&(this._iridescenceEnabled=e,this._uniformsDirty=!0)}get iridescenceIntensity(){return this._iridescenceIntensity}set iridescenceIntensity(e){this._iridescenceIntensity!==e&&(this._iridescenceIntensity=e,this._uniformsDirty=!0)}get iridescenceSpeed(){return this._iridescenceSpeed}set iridescenceSpeed(e){this._iridescenceSpeed!==e&&(this._iridescenceSpeed=e,this._uniformsDirty=!0)}get bloomIntensity(){return this._bloomIntensity}set bloomIntensity(e){this._bloomIntensity!==e&&(this._bloomIntensity=e,this._uniformsDirty=!0)}get bloomThreshold(){return this._bloomThreshold}set bloomThreshold(e){this._bloomThreshold!==e&&(this._bloomThreshold=e,this._uniformsDirty=!0)}get chromaticAberration(){return this._chromaticAberration}set chromaticAberration(e){this._chromaticAberration!==e&&(this._chromaticAberration=e,this._uniformsDirty=!0)}get shapeType(){return this._shapeType}set shapeType(e){this._shapeType!==e&&(this._shapeType=e,this._updateGeometry())}get shapeRotationX(){return this._shapeRotationX}set shapeRotationX(e){this._shapeRotationX=e,this._uniformsDirty=!0}get shapeRotationY(){return this._shapeRotationY}set shapeRotationY(e){this._shapeRotationY=e,this._uniformsDirty=!0}get shapeRotationZ(){return this._shapeRotationZ}set shapeRotationZ(e){this._shapeRotationZ=e,this._uniformsDirty=!0}get shapeAutoRotateSpeedX(){return this._shapeAutoRotateSpeedX}set shapeAutoRotateSpeedX(e){this._shapeAutoRotateSpeedX=e,this._uniformsDirty=!0}get shapeAutoRotateSpeedY(){return this._shapeAutoRotateSpeedY}set shapeAutoRotateSpeedY(e){this._shapeAutoRotateSpeedY=e,this._uniformsDirty=!0}get sphereRadius(){return this._sphereRadius}set sphereRadius(e){this._sphereRadius!==e&&(this._sphereRadius=e,this._updateGeometry())}get torusRadius(){return this._torusRadius}set torusRadius(e){this._torusRadius!==e&&(this._torusRadius=e,this._updateGeometry())}get torusTube(){return this._torusTube}set torusTube(e){this._torusTube!==e&&(this._torusTube=e,this._updateGeometry())}get cylinderRadius(){return this._cylinderRadius}set cylinderRadius(e){this._cylinderRadius!==e&&(this._cylinderRadius=e,this._updateGeometry())}get cylinderHeight(){return this._cylinderHeight}set cylinderHeight(e){this._cylinderHeight!==e&&(this._cylinderHeight=e,this._updateGeometry())}get planeBend(){return this._planeBend}set planeBend(e){this._planeBend!==e&&(this._planeBend=e,this._updateGeometry())}get planeTwist(){return this._planeTwist}set planeTwist(e){this._planeTwist!==e&&(this._planeTwist=e,this._updateGeometry())}get cameraLock(){return this._cameraLock}set cameraLock(e){this._cameraLock=e}get cameraX(){return this._cameraX}set cameraX(e){this._cameraX=e,this._uniformsDirty=!0}get cameraY(){return this._cameraY}set cameraY(e){this._cameraY=e,this._uniformsDirty=!0}get cameraZ(){return this._cameraZ}set cameraZ(e){this._cameraZ=e,this._uniformsDirty=!0}get cameraRotationX(){return this._cameraRotationX}set cameraRotationX(e){this._cameraRotationX=e,this._uniformsDirty=!0}get cameraRotationY(){return this._cameraRotationY}set cameraRotationY(e){this._cameraRotationY=e,this._uniformsDirty=!0}get cameraRotationZ(){return this._cameraRotationZ}set cameraRotationZ(e){this._cameraRotationZ=e,this._uniformsDirty=!0}get cameraZoom(){return this._cameraZoom}set cameraZoom(e){this._cameraZoom!==e&&(this._cameraZoom=e,this._updateCameraFrustum())}_updateCameraFrustum(){if(!this.glState)return;const e=this.glState.gl,i=this._ref.clientWidth,r=this._ref.clientHeight;H(this.glState.camera,i,r,N,X,this._shapeType,this._cameraZoom);const t=this.glState.locations.uniforms.projectionMatrix;e.useProgram(this.glState.program),t&&e.uniformMatrix4fv(t,!1,this.glState.camera.projectionMatrix.elements),this._uniformsDirty=!0}}const ue=n=>{n.id=ve,n.href="https://neat.firecms.co",n.target="_blank",n.style.position="absolute",n.style.display="block",n.style.bottom="0",n.style.right="0",n.style.padding="10px",n.style.color="#dcdcdc",n.style.opacity="0.8",n.style.fontFamily="sans-serif",n.style.fontSize="16px",n.style.fontWeight="bold",n.style.textDecoration="none",n.style.zIndex="10000",n.style.pointerEvents="auto",n.setAttribute("data-n","1"),n.innerHTML="NEAT"},be=n=>{const e=n.parentElement;if(e&&getComputedStyle(e).position==="static"&&(e.style.position="relative"),e){const r=e.querySelector("a[data-n]");if(r)return ue(r),r}const i=document.createElement("a");return ue(i),e?.appendChild(i),i};function we(){const n=new Date,e=n.getMinutes(),i=n.getSeconds();return e*60+i}function Se(n=6){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let r=0;r<n;r++){const t=Math.floor(Math.random()*e.length);i+=e.charAt(t)}return i}function _e(n,e){const i=document.createElement("a");i.download=e,i.href=n,document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Re(){if(document.getElementById("neat-seo-schema"))return;const n=document.createElement("script");n.id="neat-seo-schema",n.type="application/ld+json",n.text=JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"NEAT Gradient",url:"https://neat.firecms.co",author:{"@type":"Organization",name:"FireCMS",url:"https://firecms.co"},description:"Beautiful, fast, heavily customizable, WebGL based gradients."}),document.head.appendChild(n);const e=document.createElement("div");e.style.position="absolute",e.style.width="1px",e.style.height="1px",e.style.padding="0",e.style.margin="-1px",e.style.overflow="hidden",e.style.clip="rect(0, 0, 0, 0)",e.style.whiteSpace="nowrap",e.style.borderWidth="0";try{const i=e.attachShadow({mode:"closed"}),r=document.createElement("a");r.href="https://firecms.co",r.textContent="FireCMS",i.appendChild(r)}catch{const r=document.createElement("a");r.href="https://firecms.co",r.textContent="FireCMS",e.appendChild(r)}document.body.appendChild(e)}k.NeatGradient=xe,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
482
|
+
`)),console.log("FRAGMENT_SHADER_ERROR_END"));const u=t.createProgram();t.attachShader(u,g),t.attachShader(u,w),t.linkProgram(u),t.getProgramParameter(u,t.LINK_STATUS)||(console.log("PROGRAM_LINK_ERROR_START"),console.log("Program linking error: ",t.getProgramInfoLog(u)),console.log("GL Error Code:",t.getError()),console.log("PROGRAM_LINK_ERROR_END")),t.useProgram(u);const T=new ye(0,0,0,0,0,1e3);T.position=[0,0,5],H(T,i,r,N,X,this._shapeType,this._cameraZoom);const A=t.getAttribLocation(u,"position"),D=t.getAttribLocation(u,"normal"),m=t.getAttribLocation(u,"uv");t.enableVertexAttribArray(A),t.bindBuffer(t.ARRAY_BUFFER,a),t.vertexAttribPointer(A,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(D),t.bindBuffer(t.ARRAY_BUFFER,h),t.vertexAttribPointer(D,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(m),t.bindBuffer(t.ARRAY_BUFFER,p),t.vertexAttribPointer(m,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,c);const F=t.getUniformLocation(u,"projectionMatrix");t.uniformMatrix4fv(F,!1,T.projectionMatrix.elements);const C=t.getUniformLocation(u,"u_plane_width");t.uniform1f(C,N);const z=t.getUniformLocation(u,"u_plane_height");t.uniform1f(z,X);const M=t.getUniformLocation(u,"u_colors_count");t.uniform1i(M,j);const P=["projectionMatrix","modelViewMatrix","u_time","u_resolution","u_color_pressure","u_wave_frequency_x","u_wave_frequency_y","u_wave_amplitude","u_colors_count","u_plane_width","u_plane_height","u_shadows","u_highlights","u_grain_intensity","u_grain_sparsity","u_grain_scale","u_grain_speed","u_flow_distortion_a","u_flow_distortion_b","u_flow_scale","u_flow_ease","u_flow_enabled","u_y_offset","u_y_offset_wave_multiplier","u_y_offset_color_multiplier","u_y_offset_flow_multiplier","u_procedural_texture","u_enable_procedural_texture","u_texture_ease","u_transparent_texture_void","u_saturation","u_brightness","u_color_blending","u_domain_warp_enabled","u_domain_warp_intensity","u_domain_warp_scale","u_vignette_intensity","u_vignette_radius","u_fresnel_enabled","u_fresnel_power","u_fresnel_intensity","u_fresnel_color","u_iridescence_enabled","u_iridescence_intensity","u_iridescence_speed","u_bloom_intensity","u_bloom_threshold","u_chromatic_aberration","u_shape_type","u_silhouette_fade","u_cylinder_fade","u_ribbon_fade","u_flat_shading"],E={attributes:{position:A,normal:D,uv:m},uniforms:{}};P.forEach(S=>{E.uniforms[S]=t.getUniformLocation(u,S)});for(let S=0;S<j;S++)E.uniforms[`u_colors[${S}].is_active`]=t.getUniformLocation(u,`u_colors[${S}].is_active`),E.uniforms[`u_colors[${S}].color`]=t.getUniformLocation(u,`u_colors[${S}].color`),E.uniforms[`u_colors[${S}].influence`]=t.getUniformLocation(u,`u_colors[${S}].influence`);return this._initialized=!0,this._uniformsDirty=!0,this._colorsChanged=!0,this._textureDirty=!0,t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.enable(t.DEPTH_TEST),{gl:t,program:u,buffers:{position:a,normal:h,uv:p,index:c,wireframeIndex:d},locations:E,camera:T,indexCount:_.length,wireframeIndexCount:b.length,indexType:_ instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT}}_createProceduralTexture(e){this._sourceCanvas||(this._sourceCanvas=document.createElement("canvas"),this._sourceCanvas.width=1024,this._sourceCanvas.height=1024,this._sourceCtx=this._sourceCanvas.getContext("2d"));const r=this._sourceCanvas,t=this._sourceCtx;if(!t)return null;let y=this._textureSeed;const v=this._textureSeed;function s(){const m=Math.sin(y++)*1e4;return m-Math.floor(m)}const l=m=>{y=v+m},_=this._colors.filter(m=>m.enabled).map(m=>m.color);if(_.length===0)return null;const b=this._shapeType!=="plane",a=b?[-1,0,1]:[0],h=b?[-1,0,1]:[0];function p(m){const F=parseInt(m.replace("#",""),16);return{r:F>>16&255,g:F>>8&255,b:F&255}}function c(m,F,C){return"#"+((1<<24)+(Math.round(m)<<16)+(Math.round(F)<<8)+Math.round(C)).toString(16).slice(1).padStart(6,"0")}const d=()=>{const m=_[Math.floor(s()*_.length)],F=_[Math.floor(s()*_.length)],C=s()*this._textureColorBlending,z=p(m),M=p(F),P=z.r+(M.r-z.r)*C,E=z.g+(M.g-z.g)*C,S=z.b+(M.b-z.b)*C;return c(P,E,S)},R=this._proceduralBackgroundColor||"#000000";t.fillStyle=R,t.fillRect(0,0,1024,1024);const g=t.createLinearGradient(0,0,0,1024);g.addColorStop(0,d()),g.addColorStop(1,d()),t.fillStyle=g,t.fillRect(0,0,1024,1024);for(let m=0;m<this._textureShapeTriangles;m++){const F=d(),C=s()*1024,z=s()*1024,M=100+s()*300,P=(s()-.5)*M,E=(s()-.5)*M,S=(s()-.5)*M,U=(s()-.5)*M;for(const B of a)for(const O of h){t.fillStyle=F,t.beginPath();const I=C+B*1024,Y=z+O*1024;t.moveTo(I,Y),t.lineTo(I+P,Y+E),t.lineTo(I+S,Y+U),t.fill()}}for(let m=0;m<this._textureShapeCircles;m++){const F=d(),C=10+s()*50,z=s()*1024,M=s()*1024,P=50+s()*150;for(const E of a)for(const S of h)t.strokeStyle=F,t.lineWidth=C,t.beginPath(),t.arc(z+E*1024,M+S*1024,P,0,Math.PI*2),t.stroke()}for(let m=0;m<this._textureShapeBars;m++){const F=d(),C=s()*1024,z=s()*1024,M=s()*Math.PI;for(const P of a)for(const E of h)t.fillStyle=F,t.save(),t.translate(C+P*1024,z+E*1024),t.rotate(M),t.fillRect(-150,-25,300,50),t.restore()}t.lineWidth=15,t.lineCap="round";for(let m=0;m<this._textureShapeSquiggles;m++){const F=d(),C=s()*1024,z=s()*1024,M=[];let P=0,E=0;for(let S=0;S<4;S++){const U=P+(s()-.5)*300,B=E+(s()-.5)*300;M.push({cx1:P+(s()-.5)*300,cy1:E+(s()-.5)*300,cx2:P+(s()-.5)*300,cy2:E+(s()-.5)*300,ex:U,ey:B}),P=U,E=B}for(const S of a)for(const U of h){t.strokeStyle=F,t.beginPath();const B=C+S*1024,O=z+U*1024;t.moveTo(B,O);for(const I of M)t.bezierCurveTo(B+I.cx1,O+I.cy1,B+I.cx2,O+I.cy2,B+I.ex,O+I.ey);t.stroke()}}l(5e4),this._maskedCanvas||(this._maskedCanvas=document.createElement("canvas"),this._maskedCanvas.width=1024,this._maskedCanvas.height=1024,this._maskedCtx=this._maskedCanvas.getContext("2d"));const x=this._maskedCanvas,w=this._maskedCtx;if(!w)return null;this._transparentTextureVoid?w.clearRect(0,0,1024,1024):(w.fillStyle=R,w.fillRect(0,0,1024,1024));let u=0;const T=[];for(;u<1024;)if(s()<this._textureVoidLikelihood){const F=this._textureVoidWidthMin+s()*(this._textureVoidWidthMax-this._textureVoidWidthMin);T.push({type:"void",x:u,width:F}),u+=F}else{const F=50+s()*200;T.push({type:"matter",x:u,width:F}),u+=F}for(const m of T)if(m.type==="matter"){const F=m.x,C=Math.min(m.x+m.width,1024);let z=F;for(;z<C;){const M=(2+s()*20)/this._textureBandDensity,P=Math.floor(s()*1024);w.drawImage(r,P,0,M,1024,z,0,M,1024),z+=M}}const A=e.createTexture();e.bindTexture(e.TEXTURE_2D,A),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,x),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D);const D=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");if(D){const m=e.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT);e.texParameterf(e.TEXTURE_2D,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(16,m))}return A}get silhouetteFade(){return this._silhouetteFade}set silhouetteFade(e){this._silhouetteFade!==e&&(this._silhouetteFade=e,this._uniformsDirty=!0)}get cylinderFade(){return this._cylinderFade}set cylinderFade(e){this._cylinderFade!==e&&(this._cylinderFade=e,this._uniformsDirty=!0)}get ribbonFade(){return this._ribbonFade}set ribbonFade(e){this._ribbonFade!==e&&(this._ribbonFade=e,this._uniformsDirty=!0)}get flatShading(){return this._flatShading}set flatShading(e){this._flatShading!==e&&(this._flatShading=e,this._uniformsDirty=!0)}get domainWarpEnabled(){return this._domainWarpEnabled}set domainWarpEnabled(e){this._domainWarpEnabled!==e&&(this._domainWarpEnabled=e,this._uniformsDirty=!0)}get domainWarpIntensity(){return this._domainWarpIntensity}set domainWarpIntensity(e){this._domainWarpIntensity!==e&&(this._domainWarpIntensity=e,this._uniformsDirty=!0)}get domainWarpScale(){return this._domainWarpScale}set domainWarpScale(e){this._domainWarpScale!==e&&(this._domainWarpScale=e,this._uniformsDirty=!0)}get vignetteIntensity(){return this._vignetteIntensity}set vignetteIntensity(e){this._vignetteIntensity!==e&&(this._vignetteIntensity=e,this._uniformsDirty=!0)}get vignetteRadius(){return this._vignetteRadius}set vignetteRadius(e){this._vignetteRadius!==e&&(this._vignetteRadius=e,this._uniformsDirty=!0)}get fresnelEnabled(){return this._fresnelEnabled}set fresnelEnabled(e){this._fresnelEnabled!==e&&(this._fresnelEnabled=e,this._uniformsDirty=!0)}get fresnelPower(){return this._fresnelPower}set fresnelPower(e){this._fresnelPower!==e&&(this._fresnelPower=e,this._uniformsDirty=!0)}get fresnelIntensity(){return this._fresnelIntensity}set fresnelIntensity(e){this._fresnelIntensity!==e&&(this._fresnelIntensity=e,this._uniformsDirty=!0)}get fresnelColor(){return this._fresnelColor}set fresnelColor(e){this._fresnelColor!==e&&(this._fresnelColor=e,this._fresnelColorRgb=this._hexToRgb(e),this._uniformsDirty=!0)}get iridescenceEnabled(){return this._iridescenceEnabled}set iridescenceEnabled(e){this._iridescenceEnabled!==e&&(this._iridescenceEnabled=e,this._uniformsDirty=!0)}get iridescenceIntensity(){return this._iridescenceIntensity}set iridescenceIntensity(e){this._iridescenceIntensity!==e&&(this._iridescenceIntensity=e,this._uniformsDirty=!0)}get iridescenceSpeed(){return this._iridescenceSpeed}set iridescenceSpeed(e){this._iridescenceSpeed!==e&&(this._iridescenceSpeed=e,this._uniformsDirty=!0)}get bloomIntensity(){return this._bloomIntensity}set bloomIntensity(e){this._bloomIntensity!==e&&(this._bloomIntensity=e,this._uniformsDirty=!0)}get bloomThreshold(){return this._bloomThreshold}set bloomThreshold(e){this._bloomThreshold!==e&&(this._bloomThreshold=e,this._uniformsDirty=!0)}get chromaticAberration(){return this._chromaticAberration}set chromaticAberration(e){this._chromaticAberration!==e&&(this._chromaticAberration=e,this._uniformsDirty=!0)}get shapeType(){return this._shapeType}set shapeType(e){this._shapeType!==e&&(this._shapeType=e,this._updateGeometry())}get shapeRotationX(){return this._shapeRotationX}set shapeRotationX(e){this._shapeRotationX=e,this._uniformsDirty=!0}get shapeRotationY(){return this._shapeRotationY}set shapeRotationY(e){this._shapeRotationY=e,this._uniformsDirty=!0}get shapeRotationZ(){return this._shapeRotationZ}set shapeRotationZ(e){this._shapeRotationZ=e,this._uniformsDirty=!0}get shapeAutoRotateSpeedX(){return this._shapeAutoRotateSpeedX}set shapeAutoRotateSpeedX(e){this._shapeAutoRotateSpeedX=e,this._uniformsDirty=!0}get shapeAutoRotateSpeedY(){return this._shapeAutoRotateSpeedY}set shapeAutoRotateSpeedY(e){this._shapeAutoRotateSpeedY=e,this._uniformsDirty=!0}get sphereRadius(){return this._sphereRadius}set sphereRadius(e){this._sphereRadius!==e&&(this._sphereRadius=e,this._updateGeometry())}get torusRadius(){return this._torusRadius}set torusRadius(e){this._torusRadius!==e&&(this._torusRadius=e,this._updateGeometry())}get torusTube(){return this._torusTube}set torusTube(e){this._torusTube!==e&&(this._torusTube=e,this._updateGeometry())}get cylinderRadius(){return this._cylinderRadius}set cylinderRadius(e){this._cylinderRadius!==e&&(this._cylinderRadius=e,this._updateGeometry())}get cylinderHeight(){return this._cylinderHeight}set cylinderHeight(e){this._cylinderHeight!==e&&(this._cylinderHeight=e,this._updateGeometry())}get planeBend(){return this._planeBend}set planeBend(e){this._planeBend!==e&&(this._planeBend=e,this._updateGeometry())}get planeTwist(){return this._planeTwist}set planeTwist(e){this._planeTwist!==e&&(this._planeTwist=e,this._updateGeometry())}get cameraLock(){return this._cameraLock}set cameraLock(e){this._cameraLock=e}get cameraX(){return this._cameraX}set cameraX(e){this._cameraX=e,this._uniformsDirty=!0}get cameraY(){return this._cameraY}set cameraY(e){this._cameraY=e,this._uniformsDirty=!0}get cameraZ(){return this._cameraZ}set cameraZ(e){this._cameraZ=e,this._uniformsDirty=!0}get cameraRotationX(){return this._cameraRotationX}set cameraRotationX(e){this._cameraRotationX=e,this._uniformsDirty=!0}get cameraRotationY(){return this._cameraRotationY}set cameraRotationY(e){this._cameraRotationY=e,this._uniformsDirty=!0}get cameraRotationZ(){return this._cameraRotationZ}set cameraRotationZ(e){this._cameraRotationZ=e,this._uniformsDirty=!0}get cameraZoom(){return this._cameraZoom}set cameraZoom(e){this._cameraZoom!==e&&(this._cameraZoom=e,this._updateCameraFrustum())}_updateCameraFrustum(){if(!this.glState)return;const e=this.glState.gl,i=this._ref.clientWidth,r=this._ref.clientHeight;H(this.glState.camera,i,r,N,X,this._shapeType,this._cameraZoom);const t=this.glState.locations.uniforms.projectionMatrix;e.useProgram(this.glState.program),t&&e.uniformMatrix4fv(t,!1,this.glState.camera.projectionMatrix.elements),this._uniformsDirty=!0}}const ue=n=>{n.id=ve,n.href="https://neat.firecms.co",n.target="_blank",n.style.position="absolute",n.style.display="block",n.style.bottom="0",n.style.right="0",n.style.padding="10px",n.style.color="#dcdcdc",n.style.opacity="0.8",n.style.fontFamily="sans-serif",n.style.fontSize="16px",n.style.fontWeight="bold",n.style.textDecoration="none",n.style.zIndex="10000",n.style.pointerEvents="auto",n.setAttribute("data-n","1"),n.innerHTML="NEAT"},be=n=>{let e=n.parentElement;for(;e&&getComputedStyle(e).display==="contents";)e=e.parentElement;if(e&&getComputedStyle(e).position==="static"&&(e.style.position="relative"),e){const r=e.querySelector("a[data-n]");if(r)return ue(r),r}const i=document.createElement("a");return ue(i),e?.appendChild(i),i};function we(){const n=new Date,e=n.getMinutes(),i=n.getSeconds();return e*60+i}function Se(n=6){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let r=0;r<n;r++){const t=Math.floor(Math.random()*e.length);i+=e.charAt(t)}return i}function _e(n,e){const i=document.createElement("a");i.download=e,i.href=n,document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Re(){if(document.getElementById("neat-seo-schema"))return;const n=document.createElement("script");n.id="neat-seo-schema",n.type="application/ld+json",n.text=JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"NEAT Gradient",url:"https://neat.firecms.co",author:{"@type":"Organization",name:"FireCMS",url:"https://firecms.co"},description:"Beautiful, fast, heavily customizable, WebGL based gradients."}),document.head.appendChild(n);const e=document.createElement("div");e.style.position="absolute",e.style.width="1px",e.style.height="1px",e.style.padding="0",e.style.margin="-1px",e.style.overflow="hidden",e.style.clip="rect(0, 0, 0, 0)",e.style.whiteSpace="nowrap",e.style.borderWidth="0";try{const i=e.attachShadow({mode:"closed"}),r=document.createElement("a");r.href="https://firecms.co",r.textContent="FireCMS",i.appendChild(r)}catch{const r=document.createElement("a");r.href="https://firecms.co",r.textContent="FireCMS",e.appendChild(r)}document.body.appendChild(e)}k.NeatGradient=xe,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
483
483
|
//# sourceMappingURL=index.umd.js.map
|