ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Rectangle drawing/clearing #113

Closed mingos777 closed 7 years ago

mingos777 commented 7 years ago

I can't seem to find a way to clear a rectangular portion of the canvas without clearing the rest. Is it at all possible with ROT.js, without using the canvas JS API directly or writing a loop to print a space over all the cleared cells?

Clearing or drawing/filling with background colour are both acceptable solutions. Without this, I need to redraw the entire display when I actually only need di redraw a portion of it, which is wasteful.

ondras commented 7 years ago

The ROT.Display API works (only) on the cell level.

If you want to clear a set of cells, just draw() them with a blank character (or no character at all; draw(3, 4) would work as well). You do not need to worry much about performance, as these calls are batched and the actual canvas is processed in an asynchronous requestAnimationFrame loop.

mingos777 commented 7 years ago

OK, I will do that then, though personally I believe such functionality should belong to ROT.js and not necessarily my codebase ;)

ondras commented 7 years ago

What API do you propose?