0

I am a newbie using webgl implementation as a dependent module for my project. I am trying to use .toDataURL() function using node-webgl wrapper at server side. But I get an error station .toDataURL() is undefined. For more detail, please have a look at this link: canvas.toDataURL() is not a function - error node-webGL wrapper

Well the current post is definitely not a duplicate. In the post(earlier link shared) I am trying to find an alternative way to access the data of canvas. The goal of this current post is to implement the .toDataURL() function. I am novice in these webgl. Could you please share some links or procedure on how to implement this small function. or Could I access the same function of browser implementation(copy it here), where can I get that?

Any suggestions will definitely be helpful.

Thank You.

Community
  • 1
  • 1
Prajwal_7
  • 109
  • 1
  • 16
  • Please choose and stick to one place(webgl-dev list or stackoverflow) when you ask questions to avoid wasting peoples time because you already got answered elsewhere. Stackoverflow is reputation based, taking the time to write a good answer and then never "receiving the check" is frustrating and drives qualified answerers away from the platform or at least your questions. In addition to that please consider doing some/more research on your own, as I see it now you're practicing stackoverflow driven development which does not benefit you nor future readers. *Regards, the community* – LJᛃ Sep 23 '16 at 16:15
  • Hey sorry!! I never meant to waste anyone's time. I know stack overflow is a wonderful forum. I have got many doubts cleared from this forum. The current volume rendering domain is totally new to me. That is the reason I have posted many doubts recently and got cleared. – Prajwal_7 Sep 23 '16 at 21:25
  • Regarding this post, I have posted this doubt also in webgl-dev list and raised an issue in github/node-webgl for the same. Yes, I need to research a lot and I am a noob in this field. I will definitely take care. I made a mistake posting it in other google group. – Prajwal_7 Sep 23 '16 at 21:26
  • My main motive was to inform node-webgl developers that this feature is not available, and if its relevant they might add it in next versions. Sorry if I have hurt StackOverflow community unknowingly, I wont repeat it again. – Prajwal_7 Sep 23 '16 at 21:26

1 Answers1

2

A data URI consists of:

data:[<media type>][;base64],<data>

All you need to do is concatenate:

  1. a string "data:"
  2. a media type - e.g. "image/jpeg"
  3. a string ";base64,"
  4. Base64 representation of your data

For more info see:

There are several modules on npm that can help you generate Base64:

This is basically everything that you need to know to implement toDataURL() function.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • Looks I have put the question in the wrong way, yes this dataURL format can be implemented. But how to access the data. How to get the data fom the node-webgl canvas? – Prajwal_7 Sep 23 '16 at 15:34
  • @Prajwal_7 [`gl.readPixels`](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels) – LJᛃ Sep 23 '16 at 15:53