You are reading a single comment by @Abhigkar and its replies. Click here to read the full conversation.
  • I want to preserve the content of Graphics buffer and reuse it later. But when I store in a new Uint8Array it and call graphics.clear(), it clears the saved variable also. See below example.

    I am saving g.buffer in fb variable and after calling g.clear(), it clears fb also.

    How to resolve this?

    >g=Graphics.createArrayBuffer(8,8,8);
    =Graphics: {
      buffer: new ArrayBuffer(64)
     }
    >g.drawLine(0,0,7,7)
    =Graphics: {
      buffer: new Uint8Array([255, 0, 0, 0, 0,  ... 0, 0, 0, 0, 255]).buffer
     }
    >var fb = (new Uint8Array(g.buffer))
    =new Uint8Array([255, 0, 0, 0, 0,  ... 0, 0, 0, 0, 255])
    >print(fb);
    new Uint8Array([255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255])
    =undefined
    >g.clear();
    =Graphics: {
      buffer: new ArrayBuffer(64)
     }
    >print(fb)
    new Uint8Array(64)
    =undefined
    
About

Avatar for Abhigkar @Abhigkar started