kernel spindala_for_flash < namespace : "omino"; category : "omino"; aeDisplayName : "omino spindala 32"; vendor : "omino"; version : 1; description : "repeat image wedges"; > { input image4 src; output pixel4 dst; parameter float wedges < minValue:1.0; maxValue:16.0; defaultValue:6.0; >; parameter float reflections < kind:"checkbox"; >; parameter float sourceAngle < aeUIControl:"aeAngle"; minValue:0.0; maxValue:360.0; >; parameter float sourceSpread < minValue:0.0; maxValue:10.0; defaultValue:0.0; >; parameter float sourceSpiral < aeUIControl:"aeAngle"; minValue:-90.0; maxValue:90.0; defaultValue:0.0; >; parameter float drawAngle < aeUIControl:"aeAngle"; minValue:0.0; maxValue:360.0; >; parameter float drawSpiral < aeUIControl:"aeAngle"; minValue:-90.0; maxValue:90.0; defaultValue:0.0; >; parameter float2 dstsize < minValue:float2(0,0); maxValue:float2(1000,1000); defaultValue:float2(512,512); kind:"dstsize"; >; void evaluatePixel() { float2 sourceCenter = dstsize / 2.0; float2 drawCenter = dstsize / 2.0; float pi = 3.14159265358979; float2 co = outCoord(); pixel4 imgPixel = sampleLinear(src,co); // which pie-slice are we in? we consider the wedges to be centered on // 0-degrees. The zeroth slice spans -theta/2 to theta/2. float wedgesL = wedges; if(reflections > 0.0) wedgesL = wedgesL / 2.0; float theta = radians(360.0 / wedgesL); co -= drawCenter; float r = length(co); float omega = atan(co.y,co.x) + theta / 2.0; omega += r * radians(drawSpiral / 200.0); omega += radians(drawAngle); omega = mod(omega + pi - theta / 2.0,pi + pi) - pi + theta / 2.0; // omega = omega - floor(omega / theta) * theta; omega = mod(omega, theta); omega -= theta / 2.0; if(reflections > 0.0) { // omega now positive, from 0 to theta / 2 omega = abs(omega); //omega = pinch(omega,theta / 2.0,sourcePinch);//theta / 2.0 * (pow(omega / (theta / 2.0),sourceDistortion)); } // sourcespread positive: range from 0 "normal" to max10 "totally circular" if(sourceSpread >= 0.0) omega *= (10.0 - sourceSpread) / 10.0; else omega *= -sourceSpread + 1.0; omega -= r * radians(sourceSpiral / 200.0); omega -= radians(sourceAngle); float2 srcCoord = sourceCenter + r * float2(cos(omega),sin(omega)); pixel4 dstPixel = sampleLinear(src,srcCoord); float opacity = 1.0; dst = opacity * dstPixel + (1.0 - opacity) * imgPixel; //dst = mix(imgPixel,sampleLinear(src,srcCoord),opacity); } }