How can I draw a gradient rectangle?

How can I draw a gradient rectangle of a given size and color? I can’t find any way to do it in cocos2d-x, and I’m not sure how to do it with OpenGL ES 2.0

I think you should look at CCLayerGradient class.

The problem with using CCLayerGradient is that I can’t control the size or position of the gradient.

Nevermind, I can with >setContentSize and>setPosition