# Equation-driven smoothly shaded concentric shapes

## Background

Looking to create interesting video transitions (in grayscale).

## Problem

Given equations that represent a closed, symmetrical shape, plot the outline and concentrically shade the shape towards its centre.

## Example

Consider the following equations:

x = 16 * sin(t)^3
y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)
t = [0:2 * pi]


When plotted:

When shaded, it would resemble (not shown completely shaded, but sufficient to show the idea):

Notice that shading is darkest on the outside (e.g., #000000 RGB hex), then lightens as it fills to the centre. The centre would be a white (e.g., #FFFFFF) dot.

## Questions

1. What would be the most expedient way to produce high-resolution, concentrically shaded grayscale images, such as the shaded heart above?
2. What are such closed, symmetrical shapes formally called?

Thank you!

## Ideas

• Use GNUPlot
• Use R
-
I'm not sure how to implement it, but I am imagining defining a function on the plane that is 0 outside the region, and some sublinear function of the distance to the origin within the region, then doing a density plot of it in Mathematica (or its equivalent in another program). – Zev Chonoles Jul 1 '11 at 2:51
@Zev: I think ParametricPlot[ k {16 Sin[t]^3, 13 Cos[t] - 5 Cos[2 t] - 2 Cos[3 t] - Cos[4 t]}, {t, 0, 2 \[Pi]}, {k, 0, 1}, Axes -> None, Mesh -> False, ColorFunction -> Function[{x, y, t, k}, GrayLevel[ 1 - Norm[{x, y}]/ Norm[{16 Sin[t]^3, 13 Cos[t] - 5 Cos[2 t] - 2 Cos[3 t] - Cos[4 t]}]]], ColorFunctionScaling -> False, BoundaryStyle -> None, Frame -> None] does what you intended, more or less, and seems to look exactly like my first attempt. – Isaac Jul 1 '11 at 3:58

I suspect this is not quite what you're looking for*, but my first idea was to draw line segments from some central point, such as the origin, to various points on the curve, shading the line segment from white at the central end to black at the curve end. Here is the Mathematica code and the result for your heart-shaped curve, using the origin as the central point, and drawing line segments for $t$ from $0$ to $2\pi$ in steps of $\frac{\pi}{1200}$:

Graphics[Table[
Line[{{0, 0}, {16 Sin[t]^3,
13 Cos[t] - 5 Cos[2 t] - 2 Cos[3 t] - Cos[4 t]}},
VertexColors -> {White, Black}], {t, 0, 2 \[Pi], \[Pi]/1200}]]


* I don't think this is what you're looking for particularly because I don't think it's all that expedient; beyond that, I wouldn't call this concentrically-shaded, exactly, either; also, I have no idea what such shapes are formally called.

Here's a second thought, which is to graph your curve in $k\%$ black, scaled by a factor of $k\%$. Again, here's Mathematica code and the result with 400 steps from black to white (I don't know what's causing the diagonal line artifacts):

Show[Table[
ParametricPlot[(1 - k) {16 Sin[t]^3,
13 Cos[t] - 5 Cos[2 t] - 2 Cos[3 t] - Cos[4 t]}, {t, 0, 2 \[Pi]},
PlotStyle -> GrayLevel[k], Axes -> None], {k, 0, 1, 0.0025}]]


-
@Dave: The first method you could probably do in any system that will let you draw a set of line segments colored from white at one end to black at the other. The second method should work in any graphing application that can do parametric graphing with 2 parameters and set the coloring scheme. I'd think GNUplot might be able to do it, but I've never really used GNUplot. – Isaac Jul 1 '11 at 4:06