kernel RoundedRect < namespace : ""; vendor : "Creative Workflow Hacks: Dale Bradshaw, http://creative-workflow-hacks.com"; version : 1; description : "Generates a Rounded Rect given an Upper Left coordinate, a Bottom Right coordinate, a Corner radius, and a Color or Sampled Footage"; displayname: "Rounded Rect"; > { input image4 image; output pixel4 result; parameter float4 color ; parameter bool transfer; parameter float radius; parameter float2 upperLeft; parameter float2 bottomRight; /* Non AE params follow parameter float4 color < defaultValue : float4( 1, 1, 1, 1 ); minValue : float4( 0.0, 0.0, 0.0, 1 ); maxValue : float4(1.0, 1.0, 1.0, 1 ); >; parameter float2 bottomLeft; parameter float2 topRight; */ void evaluatePixel() { float2 p = outCoord(); float dist = 0.0; dist += (p.x < upperLeft.x + radius) ? pow((upperLeft.x + radius) - p.x, 2.0) : 0.0; dist += (p.y < upperLeft.y + radius) ? pow((upperLeft.y + radius) - p.y, 2.0) : 0.0; dist += (p.x > bottomRight.x -radius) ? pow((bottomRight.x -radius) - p.x, 2.0) : 0.0; dist += (p.y > bottomRight.y - radius) ? pow((bottomRight.y -radius) - p.y, 2.0) : 0.0; dist = sqrt(dist); dist = clamp(radius - dist, 0.0, 1.0); if(transfer) result = sampleNearest(image,p) * dist; else result = color * dist; } }