vertical gradient in tessellated closed curve?

I’m drawing a filled rounded box with a color using tessellation. There are 68 vertices and that works great. Now I’d like to be able to replace the fill color with a vertical color gradient. I’ve tried finding the min and may y values of the vertices and then set the color of the vertex in the callback function for GLU_TESS_VERTEX. Eg, if I wanted the min y
to be 0,0,0 (black) and the max y to be blue (0, 0, 255) I set the vertex color to (0, 0, blue) depending on its y value. But this doesn’t seem to work and I get some weird blue color distributions.

Will this basic method work for generating a color gradient? Or is there a better way? I was wondering if a 1D texture could be applied to this closed, convex tessellated path.