Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to the circuit class, to export circuit SVG as url. #85

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ Some ideas for further developing the simulator.
* Saving and loading circuits, including layout and state.
* Generic handling of negation for unary/binary gates (negation on inputs/outputs) for better clarity.
* Zooming in/out on schematics.
* SVG export.
* Verilog export.
* Smartphone and tablet compatible UI.

Expand Down
6 changes: 6 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export class Circuit extends HeadlessCircuit {
this.trigger('changeRunning');
});
}
getSvgExport(jointjsPaper) {
let svgString = (new XMLSerializer()).serializeToString(jointjsPaper.svg);
svgString = '<?xml version="1.0" standalone="no"?>\r\n' + svgString;

return svgString;
}
_defaultWindowCallback(type, div, closingCallback) {
const maxWidth = () => $(window).width() * 0.9;
const maxHeight = () => $(window).height() * 0.9;
Expand Down