hundredrabbits / Dotgrid

Minimalist Vector Tool
https://hundredrabbits.itch.io/dotgrid
Other
1.04k stars 75 forks source link

Implement serialization, clipboard #22

Closed 0x0ade closed 6 years ago

0x0ade commented 6 years ago

This PR adds some basic serialization and copy - paste functionality.

Copying puts a serialized, plain-text representation of the image and a text/svg+xml representation in your system's clipboard. Unfortunately putting files into the system clipboard doesn't work at the moment (see https://bugs.chromium.org/p/chromium/issues/detail?id=504700), so I'm resorting to text/svg+xml. It's the same, except for storing the SVG as plain-text (similar to text/html), not as file.

This allows copying from Dotgrid and immediately pasting into rotonde:

image

The serialized result uses arrays instead of objects to keep clutter to a minimum:

{"dotgrid":[[[";","Path_Line",[";",".",30,90],[";",".",60,60],[";",".",90,90]],[";","Path_Line",[";",".",60,180],[";",".",150,270],null]],10,"square","#000000",1,false]}

This could also be used to save Dotgrid "project" files.

neauoire commented 6 years ago

Oh shit, I was actually working exactly on this.

0x0ade commented 6 years ago

Oops 😅 I guess I'll close this PR then

neauoire commented 6 years ago

WAIIIIIIIIIIIT

neauoire commented 6 years ago

Give me a minute, I'm thinking.

neauoire commented 6 years ago

Okay, since you got this far... How much more work do you think it would be to use this system to make a .dot file with the json on export. And allow this .dot file to be loaded back into the canvas?

0x0ade commented 6 years ago

Working on it :)

To keep things easy for now (I don't know where to place a "load" button 😅), exporting will save a .dot next to the .png and .svg; opening will be done via drag-n-drop or via CTRL + O. Does that sound okay?

neauoire commented 6 years ago

Yeah, don't add a load button.

neauoire commented 6 years ago

Okay, I've got rid of my stuff and merged so I can complete my work on the zoom feature.

0x0ade commented 6 years ago

I've just finished my .dot save & load work T.T

neauoire commented 6 years ago

Send away :) I ll merge with my stuff and push it.