0

I have an algorithm in c++ which create an 2D table with float values, basing on that values I want to create svg graphics in html(or javascrpit). And my question is - can i anyhow make it in one code (creating that 2D array in c++, keep it in memory and basing on that, creating graphics by html), or better(/only possible?) would be for example saving 2D array to .txt then creating separately .html code in which I open the .txt file, read values and then creating svg graphics (if it is possible, i'm totally green in html/javascript). I hope You can give me some advice guys. :)

theCember
  • 71
  • 1
  • 7
  • You could have your C++ program output a SVG file with the 2D table values and have a HTML file link to that generated SVG file, or even output a HTML file with the generated SVG file embedded in it. – KompjoeFriek Oct 24 '15 at 10:48

2 Answers2

0

JavaScript doesn't have access to ANY memory management in the browsers. You could probably only connect with http requests.

However there are parsers like Rhino, which allow for Java classes to be made into javascript objects and reverse, I have yet to hear of a C++ one though.

NodeJS allows access to the filesystem, thus any files you save will be accessible and there might be an api for C++.

Olavi Sau
  • 1,647
  • 13
  • 20
0

You could use Emscripten to compyle C++ into JS, but it is hard.

You can write the table as json file that can be easy interpretted by javascript.

Or, my recomandation, use a svg library in C++ and skip html. see: Render a vector graphic (.svg) in C++ or search google.

If you are more specific about the usecase you would get batter answers:

  • How will the application run: part of a web site or local
  • Why do you need HTML
  • Who will use this: you want to convert some data to SVG for a small project or some other users will use your program for a longer time.
Community
  • 1
  • 1
Dragos Pop
  • 428
  • 2
  • 8