Skip to content

finish file I/O implementation #40

Closed

Description

@lmccart

Updated after work by @therewasaguy:

XML is the one thing that could really benefit from some more work. Currently, we can load it, but it's hard to do anything with it because there is not yet an XML object like there is in Processing. An XML object could be really useful in tandem with p5.dom. An XML to JSON converter could also be useful even though that wouldn't always translate. I'd like to work on XML in theory, but in reality I'm not sure when I will get a chance, so if anybody is inspired they should go for it (and maybe open up a new ticket?).

More stuff that isn't supported and might be worth adding:

  • loadBytes() / saveBytes() --> actually spent a decent amount of time trying to figure this one out. Maybe this will help.
  • beginRecord() / endRecord() --> save a PDF of the sketch
  • beginRaw() / endRaw() --> could create a vector?

Activity

  1. lmccart commented on Sep 7, 2014

    @lmccart
    MemberAuthor

    correct me if I'm wrong, but I think we can close this general issue with the great work from @therewasaguy. the last remaining bits to resolve are discussed in these issues:
    https://github.com/lmccart/p5.js/issues/326
    https://github.com/lmccart/p5.js/issues/280

  2. therewasaguy commented on Sep 9, 2014

    @therewasaguy
    Member

    Well, I didn't actually get to all of the file i/o methods listed in the original ticket. I tried to focus on what would be most relevant.

    XML is the one thing I think could really benefit from some more work. Currently, we can load it, but it's hard to do anything with it because there is not yet an XML object like there is in Processing. An XML object could be really useful in tandem with p5.dom. An XML to JSON converter could also be useful even though that wouldn't always translate. I'd like to work on XML in theory, but in reality I'm not sure when I will get a chance, so if anybody is inspired they should go for it (and maybe open up a new ticket?).

    More stuff I haven't gotten to but might be worth doing:

    • loadBytes() / saveBytes() --> actually spent a decent amount of time trying to figure this one out. Maybe this will help.
    • beginRecord() / endRecord() --> save a PDF of the sketch
    • beginRaw() / endRaw() --> could create a vector?

    Stuff I don't think makes sense for p5:

    • createInput()
    • createOutput()
    • selectInput()
    • createReader()
    • selectFolder()
    • open()
  3. lmccart commented on Sep 10, 2014

    @lmccart
    MemberAuthor

    oops sorry for jumping the gun. I'll update the issue to reflect the current status. if these are things you'd like to tackle at some point feel free to keep your name on this issue. otherwise go ahead and deassign yourself, thanks for all your work on this area!

  4. removed their assignment
    on Sep 10, 2014
  5. therewasaguy commented on Sep 10, 2014

    @therewasaguy
    Member

    I may dive back in at some point, but I'll deassign myself for now in case somebody else is interested in working on it in the meantime.

  6. lmccart commented on Sep 10, 2014

    @lmccart
    MemberAuthor

    great, sounds good!

  7. changed the title [-]implement file I/O to the extent it makes sense[/-] [+]finish file I/O implementation[/+] on Sep 10, 2014
  8. shiffman commented on Sep 11, 2014

    @shiffman
    Member

    A small note I think that it might make sense to include something like selectInput() as an easy path to handling some of the JS File API stuff (this tutorial is a nice start). Thanks for all your amazing work @therewasaguy!

  9. 10 remaining items

  10. DarkPrince304 commented on Feb 11, 2016

    @DarkPrince304
    Contributor

    Hello @lmccart,

    I have some queries that I came across while implementing this.

    If the XML is like this

     <?xml version="1.0"?>
     <mammals>
       <animal id="0" species="Capra hircus">Goat</animal>
       <animal id="1" species="Panthera pardus">Leopard</animal>
       <animal id="2" species="Equus zebra">Zebra</animal>
     </mammals> 

    1.) and the getContent('mammals') method is called should null be returned in such a case or a complete String like " <animal id="0" species="Capra hircus">Goat</animal><animal id="1" species="Panthera pardus">Leopard</animal><animal id="2" species="Equus zebra">Zebra</animal>" ?

    2.) Also in case of getParent('mammals') should #document be returned?

    3.) If I call getChildren("animal") will it return an array containing id,species,innerText ?

  11. lmccart commented on Feb 12, 2016

    @lmccart
    MemberAuthor

    1 it should match the behavior of processing wherever it makes sense. so if you run this in processing, you get something like:

     println(xml.getContent("mammals"));
    // Goat
    // Leopard
    // Zebra

    so maybe it should return an array of these three items?

    2 I think it should return null, matching the behavior of processing.
    3 The output from processing is:

    <animal id="0" species="Capra hircus">Goat</animal> <animal id="1" species="Panthera pardus">Leopard</animal> <animal id="2" species="Equus zebra">Zebra</animal>

    so perhaps it should return the raw elements or maybe an array of p5.XMLNode objects?

  12. DarkPrince304 commented on Feb 12, 2016

    @DarkPrince304
    Contributor

    Woops! Sorry, about the 3rd question I meant what if xml = the animal node and then we call xml.getChildern(). What will be the children of animal?

  13. lmccart commented on Feb 16, 2016

    @lmccart
    MemberAuthor

    hm, what is the output for processing for this? i would try to match that conceptually as best as possible, unless it makes sense to deviate for some reason. maybe it would be useful to write out a spec of this object and methods first, and we could review to make sure it all fits together as expected, before you implement?

  14. DarkPrince304 commented on Feb 16, 2016

    @DarkPrince304
    Contributor

    I will try it out on processing soon and let you know. But I think it should be null value if xml = animal node[0].

    By the way I have done this in my PR #1255 using the class p5.XML and defined its methods and attributes too. So the loadXML() works fine except for just one thing on which I would like some help, which I have mentioned in the PR. You can check it out whenever you want :)

  15. lmccart commented on Feb 16, 2016

    @lmccart
    MemberAuthor

    oops sorry missed that! will take a look next chance i get.

  16. DarkPrince304 commented on Dec 19, 2016

    @DarkPrince304
    Contributor

    @lmccart Is this finished? Or is there anythiing left with file I/O ?

  17. lmccart commented on Dec 19, 2016

    @lmccart
    MemberAuthor

    @DarkPrince304 the three checkboxes in the first post still need looking into.

  18. DarkPrince304 commented on Dec 19, 2016

    @DarkPrince304
    Contributor

    @lmccart What do you think should be a good approach to saving the sketch as a PDF? If memory serves me I guess someone did a similar GSoC project to save data as PDF? I guess this is it: https://github.com/zenozeng/p5.js-pdf

    I am not really sure what the 3rd point is? Creating a vector of what?

    Also about the XML functionality, the saveXML() hasn't been implemented yet right? Is that also planned? Is there also anything else remaining for JSON and XML or other files?

    Thanks

  19. lmccart commented on May 10, 2017

    @lmccart
    MemberAuthor

    since we haven't heard much demand for the three remaining unimplemented pieces, I suggest we close this issue and focus on issues that are higher priority.

  20. bmoren commented on May 10, 2017

    @bmoren
    Contributor

    I agree with the bytes and pdf being pushed to the back, I've had a lot of student desire for svg/vector output to be native so they can more easily traverse p5js & css tasks & get vector information out for going to print & laser/plotter/cnc fabrication. I do think likely the svg should be an external library. But from our previous conversation, It seems a question of how possible it is given the current render setup. I also do believe that in order to get svg/vector implemented it would be super helpful to have someone with experience in this area.

  21. lmccart commented on May 10, 2017

    @lmccart
    MemberAuthor

    yes, definitely. the svg issue is still open: #458.
    though realistically, I just don't have the bandwidth to take it on anytime soon, but would welcome anyone interested in tackling it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions