fmw42 wrote:-sparse-color Barycentric with two points creates a gradient, but has the advantage of the points coming from calculations, %[fx:h-1], in this case, which is just the bottom row of the image
Warning those points are the very top edge, and the top edge of the last row.
The mathematics is perfect and in image coordinates.
It means the top
pixel will not be white. and the only reason the bottom pixel is black
is because color limit was reached at the edge of the pixel.
I have updated the IM examples section
Generating the Perfect Gradient to better detail the slight differences in the different gradients you can generate.
For this image You probably what the first pixel in the gradient to be very slightly transparent and that last pixel to be almost but not perfectly transparent, so as to get the best use of the gradient range.
So I would suggest using...
Code: Select all
-sparse-color Barycentric '0,-0.5 white 0,%[fx:h+0.5] black'
With this the first pixel will be slightly off-white and the last pixel slightly-off black
but all color differences from one pixel to the next at the edges the same.
That is opaque to first pixel, and last pixel to transparent (off the image) is the same as the rest of the gradent over the full range of the gradient.
however really this minor point will probably not really be noticeable. Just depends how 'perfect' you need it
But a little thought can be useful.