diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-07-29 16:06:19 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-07-30 11:50:25 +0100 |
| commit | 76da6ec140cbbdac6136469ce50aab40e218f398 (patch) | |
| tree | 90e92a04e2ea6196c93e21efd2f3d2ef716144a6 /emccpre.js | |
| parent | 3e7a6adce5887db04d26438da64fdc4de308f4da (diff) | |
| download | puzzles-76da6ec140cbbdac6136469ce50aab40e218f398.zip puzzles-76da6ec140cbbdac6136469ce50aab40e218f398.tar.gz puzzles-76da6ec140cbbdac6136469ce50aab40e218f398.tar.bz2 puzzles-76da6ec140cbbdac6136469ce50aab40e218f398.tar.xz | |
js: keep colour strings in JavaScript rather than in C
The drawing routines in JavaScript used to take pointers to a C string
containing a CSS colour name. That meant that JavaScript had to create
a new JavaScript string on ever call to a drawing function, which seemed
ugly.
So now we instead pass colour numbers all the way down into JavaScript
and keep an array of JavaScript strings there that can be re-used. The
conversion from RGB triples to strings is still done in C, though.
This doesn't seem to have fixed either of the bugs I hoped it would, but
it does measurably improve drawing performance so I think it's worth
doing.
Diffstat (limited to 'emccpre.js')
| -rw-r--r-- | emccpre.js | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -41,6 +41,10 @@ var ctx; // by js_canvas_end_draw. var update_xmin, update_xmax, update_ymin, update_ymax; +// Colour strings to use when drawing, to save converting them from C +// every time. +var colours = []; + // Module object for Emscripten. We fill in these parameters to ensure // that when main() returns nothing will get cleaned up so we remain // able to call the puzzle's various callbacks. |