Javascript wasm wrapper for gdstk. We use emscritpen sdk wrapper gdstk as a Javascript pacakage, so that we can use gdstk functions in web.
Both Linux and windows is ok, emsdk and cmake is required
mkdir build
cd build
emcmake cmake ..
cmake --build .
You will get wasm with it's binding js in packages
dir
Valid cmake configuration are:
CMAKE_BUILD_TYPE // default is "Release", use -DCMAKE_BUILD_TYPE=Debug when you want to get Debug packages
EXPORT_MODULE // default is "ON", you will get pacakges named "Gdstk" in directory `packages`, if "OFF", pacakges will be named "Module"
API is very similar like gdstk python interface but in Js flavor, see gdstk documentation for details
If you work in pure JS enviroment, you must cmake this gdstk_js project with option "-DEXPORT_MODULE=OFF", then use <script>xxx/gdstk.js</script>
label import gdstk as Module
object. See examples
If you work in node.js enviroment, you must cmake this gdstk_js project with option "-DEXPORT_MODULE=ON"(it's default value), then use require
to import gdstk as Gdstk
object.
- If you want set one of default value of interface, you must give all value for default parameter
- In web broswer, it's hard to operate local file directly. You can use
FS
object offered by emscripten to achieve that. Or just useupload_file
anddownload_file
js function of gdstk_js package. Notic: if useFS
, should wrapper withModule.FS
orGdstk.FS
base on you build type. Polygon.points
is a js array like proxy object. Support modify points value in place as js array ways, but not support iter yet.- When access properties like
Curve.points
(in form of native js array) in iteration, it's better save proerties as a variable, then iter it. Otherwise may cause huge useage of memory and CPU performance. FlexPath.commands
accept array of commands instead of variable length of parameters. same ofCurve.commands
- Some method like
Plygon.get_properties
not implemented yet. - Some Class like
RawCell, GdsWriter
not implemented yet.