Comments (2)
I don't know if this will help you, but I've been using this JavaScript library in C++ by calling it via a .NET javascript compiler from Microsoft called ClearScript https://github.com/microsoft/ClearScript which works on Windows, Linux, and MacOS.
I use ClearScript in C# like this to run milsymbol.js:
V8ScriptEngine engine = new V8ScriptEngine(nameof(MilStd2525), V8ScriptEngineFlags.EnableDebugging);
string jsContents = string.Empty;
using (Stream stream = File.Open("milsymbol.js"))
{
using (var reader = new StreamReader(stream))
{
jsContents = reader.ReadToEnd();
}
}
engine.Execute(jsContents);
and I have a function that gives me the symbol like this:
public string CreateSymbolAsSvgString(int size, string sidc, out bool isValid)
{
sidc = $"\"{sidc}\"";
// Insert javascript as a string for the milsymbol creation
var script = $@"var size = {size};
var sidc = {sidc};
var symbol = new ms.Symbol(sidc, {{ size: {size} }});
var symbolValid = symbol.isValid(false);
var symbolSvg = symbol.asSVG();";
engine.Execute(script);
isValid = (bool)engine.Script.symbolValid;
// Return svg as string
return (string)engine.Script.symbolSvg;
}
from milsymbol.
Thanks for the example code, I ended up doing something similar since I was using UE4, I just used the unreal.js plugin to handle the milsymbol side of things and then send the svg string over to cpp.
from milsymbol.
Related Issues (20)
- monoColor HOT 3
- Provide a CLI to generate and export symbols HOT 2
- iconColor has no effect for SIDC EO* and WO* (NodeRED World Map) HOT 1
- Change Font Size and position of additionalInformation HOT 2
- Searchable milsymbols HOT 2
- just simple question
- render tactical symbols HOT 4
- what is rbb error? HOT 1
- Publishing latestest version to npm HOT 1
- Selecting "set" of symbols with AMD in similar way to ES6 HOT 1
- Where is the definition for letterbased sidc? HOT 2
- Wheeled modifier overlaps infantry icon HOT 3
- Update mil-std-2525 D cyberspace according to the standard
- Center symbol with modifier fields while maintaining consistent size HOT 1
- toDataUrl is not correctly creating images HOT 2
- Make Reinforced Reduced amplifier bigger HOT 1
- High Contrast Background HOT 4
- MilSymbol 2.2.0 breaks NextJS build since 2.0.0 HOT 7
- All unit symbols should have country field in the same way as activities
- Wrong symbols rendered for 3 codes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from milsymbol.