简体   繁体   中英

c++ algorithm with html(/javascript) SVG graphics - few questions

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. :)

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++.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM