/** * 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: "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 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: "uniform swirlUniforms {\n radius: f32,\n angle: f32,\n center: vec2f,\n};\n\n@group(0) @binding(1) swirl: swirlUniforms;\n\nfn swirl_warp(vec2 coord, vec2 texCenter) -> vec2f {\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\nfn swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, swirl.center * texSize);\n return warp_sampleColor(source, texSize, coord);\n}\n"; readonly fs: "uniform swirlUniforms {\n float radius;\n float angle;\n vec2 center;\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