Clock Top transition preset does not produce a linear (smooth) result

The relevant code is from line 164:

case 3:
	{
		int length;
		for ( j = -half_h; j < half_h; j ++ )
		{
			if ( j < 0 )
			{
				for ( k = - half_w; k < half_w; k ++ )
				{
					length = sqrti( k * k + j * j );
					*p ++ = ( max / 4 * k ) / ( length + 1 );
				}
			}
			else
			{
				for ( k = half_w; k > - half_w; k -- )
				{
					length = sqrti( k * k + j * j );
					*p ++ = ( max / 2 ) + ( max / 4 * k ) / ( length + 1 );
				}
			}
		}
	}
	break;

Line

					*p ++ = ( max / 4 * k ) / ( length + 1 );

can be rewritten as

					*p ++ = ( max / 4) * (k  / ( length + 1 ));

The term: k / ( length + 1 ) is effectively the Sine of the angle subtended from the pixel to the baseline (the + 1 is to prevent division by zero). This means that the conic gradient is based on the Sine function, which is non-linear.

You need to take the Arcsine that will give you the angle and base the gradient on that. However, the code seems to be designed for speed and taking the Arcsine at every pixel will slow it down considerably. So I think it best to leave it as it is and if someone wants a conic gradient with a linear speed of transition they need to provide the relevant PNG file, such as can be produced by my HTML code here: Greyscale Luminosity Masks.

2 Likes