If you have ever consumed liquid from a shallow cup in sunlight, you may have noticed a shape like the following at the bottom:
You might notice a nephroid shaped bright outline, a brighter area on the outside of the nephroid, and a diffuse bright spot extending from the cusp of the nephroid.
Your task is to draw this shape.
A clearer rendered example:
You can create this shape by bounding parallel horizontal rays off the inside of a circle and counting how many intersect near a point.
Example code (GLSL):
#define PI 3.1415926538
#define STEPS 3200.0
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.y * 2.0 - vec2(1.0, 1.0);
if (length(uv) < 1.0) {
float col = 0.0;
for (float i = 0.0; i<STEPS; i+=1.0) {
float y = i/(STEPS / 2.0) - 1.0;
float x = sqrt(1.0 - y * y);
float angle = asin(y) * 2.0;
float slope = tan(angle);
float dist = abs(slope * (uv.x - x) - (uv.y - y)) / sqrt(slope * slope + 1.0);
if (dist < 0.005) {
col+=0.005 - dist;
}
}
fragColor = vec4(col,col*0.5,col*0.25,1.0);
} else {
fragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
}
Rules:
- Minimum resolution is 512x512
- Use at least 16 distinct colors. You are free to pick the color scheme.
- All three aspects must be clearly visible: Nephroid rim, bright area on the outside, diffuse bright area near the cusp.
- If you use the ray-based approximation, you must use at least 400 rays. You are welcome to use an alternative approach than drawing discrete rays.
- Area outside the circle is undefined behavior, it can be any color or pattern
As is standard with graphical-output, you can save the image to a file using any reasonable image format, display it on the screen, or print a representation to the terminal using ANSII escape codes to set the color.






\left(x^{2}+y^{2}-4\right)^{3}=108y^{2}draws a nephroid, but as far as i can tell there's no way to meet the challenge specs because desmos can't even draw gradients. @Lucenaposition \$\endgroup\$