You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • You can do:

    JsVar* v = jsvArrayBufferGet(arrayBuffer, 30);
    jsvArrayBufferSet(arrayBuffer, 60, v);

    But that's not as fast. The ideal thing is to read or write data sequentially:

    JsvArrayBufferIterator it;
    jsvArrayBufferIteratorNew(&it, start_index);
    while (pixels--) {
      jsvArrayBufferIteratorSetByteValue(&it, value);

    Your other option is to use 'flat strings' - if you can use them then when you use JSV_GET_AS_CHAR_ARRAY you'll get a pointer to the underlying data, so there is no need to copy back.

    The ability to scroll with the Graphics library would actually be really useful, although that's a bit tricker to deal with as you need to cope with bit-based graphics where the pixels are in strange formats...

    No problem if you're doing this for fun yourself - but I don't see I'll be able to include this code in Espruino itself - there's just too little flash memory available for me to be be able to use it on something that's very single-purpose.


Avatar for Gordon @Gordon started