/** * Warps a circular region of the image in a swirl. */ export type SwirlProps = { /** [x, y] coordinates of the center of the circle of effect. default: [0.5, 0.5] */ center?: [number, number]; /** The radius of the circular region. */ radius?: number; /** The angle in radians that the pixels in the center of the circular region will be rotated by. */ angle?: number; }; export type SwirlUniforms = SwirlProps; /** * Warps a circular region of the image in a swirl. */ export declare const swirl: { readonly name: "swirl"; readonly dependencies: [{ readonly name: "warp"; readonly source: "fn warp_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n coord: vec2f\n) -> vec4f {\n var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);\n let clampedCoord = clamp(coord, vec2f(0.0), texSize);\n if (any(coord != clampedCoord)) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n"; readonly fs: "vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {\n vec4 color = texture(source, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n"; readonly passes: []; }]; readonly source: "struct swirlUniforms {\n center: vec2f,\n radius: f32,\n angle: f32,\n};\n\n@group(0) @binding(auto) var swirl: swirlUniforms;\n\nfn swirl_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {\n var coord = coordIn - texCenter;\n let distance = length(coord);\n if (distance < swirl.radius) {\n let percent = (swirl.radius - distance) / swirl.radius;\n let theta = percent * percent * swirl.angle;\n let s = sin(theta);\n let c = cos(theta);\n coord = vec2f(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nfn swirl_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n var coord = texCoord * texSize;\n coord = swirl_warp(coord, swirl.center * texSize);\n return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);\n}\n"; readonly fs: "layout(std140) uniform swirlUniforms {\n vec2 center;\n float radius;\n float angle;\n} swirl;\n\nvec2 swirl_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < swirl.radius) {\n float percent = (swirl.radius - distance) / swirl.radius;\n float theta = percent * percent * swirl.angle;\n float s = sin(theta);\n float c = cos(theta);\n coord = vec2(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, swirl.center * texSize);\n\n return warp_sampleColor(source, texSize, coord);\n}\n"; readonly props: SwirlProps; readonly uniforms: SwirlProps; readonly uniformTypes: { readonly center: "vec2"; readonly radius: "f32"; readonly angle: "f32"; }; readonly propTypes: { readonly center: { readonly value: readonly [0.5, 0.5]; }; readonly radius: { readonly value: 200; readonly min: 1; readonly softMax: 600; }; readonly angle: { readonly value: 3; readonly softMin: -25; readonly softMax: 25; }; }; readonly passes: [{ readonly sampler: true; }]; }; //# sourceMappingURL=swirl.d.ts.map