Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top