1 2/* 3 * When calling makeShader, pass 4 * radius_scale 0.5 5 * center x, y 6 * color0 r, g, b, a 7 * color1 r, g, b, a 8 */ 9function MakeSpiralShaderEffect(CanvasKit) { 10 const _spiralSkSL = ` 11 uniform float rad_scale; 12 uniform float2 in_center; 13 uniform float4 in_colors0; 14 uniform float4 in_colors1; 15 16 half4 main(float2 p) { 17 float2 pp = p - in_center; 18 float radius = sqrt(dot(pp, pp)); 19 radius = sqrt(radius); 20 float angle = atan(pp.y / pp.x); 21 float t = (angle + 3.1415926/2) / (3.1415926); 22 t += radius * rad_scale; 23 t = fract(t); 24 return half4(mix(in_colors0, in_colors1, t)); 25 }`; 26 27 return CanvasKit.RuntimeEffect.Make(_spiralSkSL); 28} 29