Open samspot opened 5 years ago
Well, this is kind of intentional. The drawText
is basically a bunch of individual draw
calls (for individual text letters). If you are unable to do draw("H")
, you will be unable to do drawText("Hello")
.
Ok, it’s not surprising that it’s not supported (though it would be nice to have). Maybe a check and better error message in case of tiles mode? I could add that if you would accept a pull request.
On Tue, Mar 19, 2019 at 2:26 AM Ondřej Žára notifications@github.com wrote:
Well, this is kind of intentional. The drawText is basically a bunch of individual draw calls (for individual text letters). If you are unable to do draw("H"), you will be unable to do drawText("Hello").
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ondras/rot.js/issues/160#issuecomment-474227418, or mute the thread https://github.com/notifications/unsubscribe-auth/AA1-LCfYhICFdDiVE7Qk0F3-nFDRzdcHks5vYJEPgaJpZM4b6JS- .
Ok, it’s not surprising that it’s not supported (though it would be nice to have). Maybe a check and better error message in case of tiles mode? I could add that if you would accept a pull request.
I am really not sure what would the proper behavior be, as I always considered drawing text with Tiles as undefined. Feel free to send a PR with better wording/handling, if you have a strong opinion on this.
Hello @ondras, would it be possible to just display the letter like in the "forceSquareRatio:true"-mode with the fontSize set to tileHeight if the letter is not included in the tileMap? This would be very handy for me since I have to display a ranking-table with grand-prix-points in my "racing-game". Since the game is still in ASCII, this is no problem because the opponents are "Runner A", "Runner B", "Runner C" and so on. So the names of the opponents just tell you exactly how they look like since I use the letters "A", "B", "C" to display them in the game. But this changes when I switch to tiles. Then I would like to display the graphical representation of the runners in the table and need to mix this with text to display score and ranking.
Hi @Gerhard-Wonner ,
I am afraid that a regular tile size is far too large to be a suitable drawing canvas for one letter. For a typical tile size of 32, the letter spacing would be too much for convenient reading.
The recent webgl-related development is complicating this approach even further, because there is no straightforward way to render text into a webgl canvas.
A suggestion (not tried, shall work): create your own tile atlas that includes both images and letters! Typically, you use a HTML <img>
element as a tileSet
, but a <canvas>
shall work as well. So you might create your own canvas, fill it with image tiles, create letter tiles and use that as a tileSet
. It might sound like a lot of work, but it is pretty simple. (Unless you run into issues using <canvas>
as a tileSet
, because noone has tried that before :smile:)
@ondras Thank you for the detailed answer! :-) I probably try that in the future. Maybe I just draw the alphabet with "forceSquareRatio:true" and take a screenshot of it and include this into my tileset.
When working with tiles, drawText no longer functions:
yields:
Uncaught Error: Char "H" not found in tileMap