|
Post by kosthala on Nov 12, 2014 4:10:56 GMT -8
Hi,
Is it possible to draw a round rectangle with gradient fill? I have scratch my head for hours but i can't find how to do it.
Thanks.
|
|
|
Post by Tommino on Jan 15, 2015 13:09:38 GMT -8
Yes, it's possible. Thanks to code, published by James in another post, it will like (here with circle):
// Draw a circle into the stencil GD.SaveContext(); GD.ColorMask(0, 0, 0, 0); // Don't touch color GD.StencilOp(INCR, INCR); // incrementing stencil GD.PointSize(80 * 16); GD.Begin(POINTS); GD.Vertex2ii(240, 136); GD.RestoreContext();
// Set the stencil test, to only inside the circle GD.StencilFunc(EQUAL, 1, 255);
// Things drawn 'B' here are stenciled to inside the circle GD.cmd_gradient(240 - 80, 136 - 80, 0xff0000, 240 + 50, 136 + 50, 0x00ff00);
|
|
|
Post by Tommino on Jan 15, 2015 13:13:26 GMT -8
... I forgot to mention, that such operation(s) are quite time expensive. The code above takes about 8ms.
|
|