Question

I'm trying to draw a rectangle with text on it, but all I see is the rectangle, there is no text. Am I doing something wrong? This is the part of the code that does the drawing:

CanvasImage image = PlayN.graphics().createImage(100, 50);
Canvas canvas = image.canvas();

canvas.setFillColor(color);
canvas.fillRect(0, 0, 100, 50);

canvas.setFillColor(textColor);
canvas.setStrokeColor(textColor);
canvas.drawText("test", 0, 0);

layer.surface().drawImage(image, 0, 0);

Thanks

btw, I'm running the HTML version.

Was it helpful?

Solution

The problem was that the text is drawen up from the y coordinate and I was setting y to 0 so the text wasn't shown.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top