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

Conversation

mateusz-sz
Copy link
Contributor

No description provided.

Copy link
Owner

@tilk tilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have several concerns with this PR which need to be addressed.

src/circuit.mjs Outdated Show resolved Hide resolved
src/circuit.mjs Outdated Show resolved Hide resolved
src/circuit.mjs Outdated Show resolved Hide resolved
@yuyichao
Copy link
Contributor

Note that unless jointjs's internal is changed, simply extracting the svg won't work due to the use of style sheets and foreign objects. (The resulting SVG renders differently compared to what was in the browser window).

Apparently this is something the paid version supports but not the free version. There was a google group post roughly how to fix those. See https://github.com/yuyichao/digitaljs_code/blob/75a49dd290f7c06a97c3b883133a3905b6e0afec/view/imgutils.mjs for what I needed to do along with other tweaks to achieve a good frame rectangle, minimum svg file size etc. A few aspects are still not very generic (size, style, assumptions on property names etc) but other bits should be reusable.

@mateusz-sz
Copy link
Contributor Author

mateusz-sz commented Aug 21, 2022

Hi @yuyichao thanks for your engagement!
I am not sure if you're right or not. I've seen this google discussion you're talking about, and I'm aware of the "Rappid" paid JointJS plugin.

I exported SVG via digitaljs_online client. It seems like everything works well for me. I saved the exported SVG in a file and opened it in another browser, and the exported circuit looks good.

Do you think / suggest that this is not going to work if I'd use digitaljs without this client?

Here is the result of the export (above the simulation in the web client; below the exported SVG file):
image

From above picture looks like all the styles have been preserved.

@yuyichao
Copy link
Contributor

No, all the paths are preserved not all the styles.

You can see that the content of the input and output boxes are not rendered correctly, the buttons on the subcircuits are shown but shouldn't be there and so is the base selectors for input/output. The input/output are also foreign objects that I don't think works in non-browsers. They show up as black boxes for me in some viewers IIRC. (The font is also different but I'm not an expert on that...)

@mateusz-sz
Copy link
Contributor Author

Okay I see the problem now. Removing base selectors and subcircuits buttons seems to be pretty easy. But replacing inputs and rendering them in a correct place is going to be more challenging.

Anyway – thank you for your input. I am going to work more on that and fix the mentioned issues.

@mateusz-sz mateusz-sz marked this pull request as draft August 21, 2022 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants