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

WIP: Saving and loading akira through serialization #209

Closed
wants to merge 2 commits into from

Conversation

albfan
Copy link
Collaborator

@albfan albfan commented Oct 9, 2019

Summary / How this PR fixes the problem?

Use existing serialization:

to save and load canvas contents.

Steps to Test

This is just a PoC so it only saves first item from canvas and loads it as a rectangle.

Example file (you can generate other saving your canvas):

file.akira

{"line-width":1.0,"stroke-color-rgba":2863311615,"fill-color-rgba":3435973887,"x":699.6171875,"y":67.75390625,"width":104.0,"height":97.0}
  • It needs to traverse all items on save
  • Seems serialization has problems with CanvasItem (cannot recognize as a type), so it will need to store type (Rect, Ellipse, Text) for each item to deserialize

Screenshots

open-save-akira

Known Issues / Things To Do

  • Add akira filter to open/save dialogs
  • Test load items order

This PR fixes/implements the following bugs/features:

Relates to #90. A svg format would be preferred anyway.

@albfan
Copy link
Collaborator Author

albfan commented Oct 10, 2019

First functional format:

{
  "items": [
    {
      "type": "GooCanvasRect",
      "item": {
        "line-width": 1,
        "stroke-color-rgba": 255,
        "fill-color-rgba": 1318717183,
        "x": 104.32421875,
        "y": 70.765625,
        "width": 282,
        "height": 232
      }
    },
    {
      "type": "GooCanvasEllipse",
      "item": {
        "line-width": 1,
        "stroke-color-rgba": 255,
        "fill-color-rgba": 4012452351,
        "center-x": 368.61328125,
        "center-y": 305.26171875,
        "radius-x": 147.5,
        "radius-y": 145.5,
        "x": 221.11328125,
        "y": 159.76171875,
        "width": 295,
        "height": 291
      }
    }
  ]
}
  • Mark objects to not save (as hover and select effect)

@albfan
Copy link
Collaborator Author

albfan commented Oct 10, 2019

@AUNaseef please keep in mind this is a tentative design (mostly a PoC that we can discard early), but can you check if you can save/load your draws with this branch?

I would love to load any of your draws and take a look. (Specially for the group feature)

@albfan
Copy link
Collaborator Author

albfan commented Oct 11, 2019

  • store transformation: Now it is missing. It should be just store and load the transform matrix
  • Group objects. Just store the parent item? It will be done automatically? What if parent do not exists while loading?
  • Mark special objects (like artboards) Includes grouping and intersections (invisible parts for items inside and artboard

@albfan albfan force-pushed the wip/albfan/serialization branch 2 times, most recently from dfa843e to b70676e Compare October 12, 2019 06:43
@albfan
Copy link
Collaborator Author

albfan commented Oct 12, 2019

  • Add artboard layers on load

@albfan albfan force-pushed the wip/albfan/serialization branch 4 times, most recently from 4f62f09 to b3c8db8 Compare October 13, 2019 08:05
@albfan
Copy link
Collaborator Author

albfan commented Oct 13, 2019

  • save json in pretty format

@albfan albfan force-pushed the wip/albfan/serialization branch 2 times, most recently from 65338fd to cfeb982 Compare December 19, 2019 15:38
@albfan albfan force-pushed the wip/albfan/serialization branch 2 times, most recently from 26bf57e to c72e1ae Compare December 26, 2019 19:55
@albfan albfan force-pushed the wip/albfan/serialization branch 5 times, most recently from deb6b65 to f950c95 Compare January 7, 2020 19:39
@Alecaddd Alecaddd mentioned this pull request Mar 25, 2020
4 tasks
@Alecaddd Alecaddd deleted the wip/albfan/serialization branch July 12, 2020 18:01
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.

None yet

3 participants