-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
finish file I/O implementation #40
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
Comments
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: |
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:
Stuff I don't think makes sense for p5:
|
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! |
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. |
great, sounds good! |
A small note I think that it might make sense to include something like |
@lmccart : Could you please tell me what's left for the full file I/O implementation to be complete for p5.js? :) |
I think @therewasaguy has outlined what's left here: #40 (comment). |
Cool! @lmccart Also can you give me a little picture of where and when to use loadXML() ? As in, what conditions would require the use of loadXML() ? I am asking this so that I could get a better picture and then start work on this accordingly! :) |
loadXML() could be used just like loadJSON() or loadStrings(), either in preload() or setup() or on some event (like a mouse press). here is a test file that you can load with p5.js, but the resulting data object is a little complicated to parse with native JS calls. there are also some external APIs that return XML rather than JSON, for example the NYC MTA subway API: does that answer your question, or am I misunderstanding? |
Yeah, thanks a lot! I'd like to start looking into it! |
wonderful! let me know if you have any questions. |
Sure! Has any progress been made on this? I checked out |
I think it makes sense to carry on with this, the todo here is probably to add another object called p5.XML that gets returned from loadXML(), similar to how loadTable() returns a p5.Table object. |
@lmccart How would you like the structure of the XML to be parsed? If I am not wrong is this a place where we would have to use Data Structures like B-Tree or Hash Map to reconstruct a perfect DOM behaviour for the resulting parsed XML? |
@lmccart will the p5.XML object be having all the methods associated with it as in the case of its processing counterpart? Also for methods requiring searching what kind of solution do you think would be apt for searching an XML node inside another ones? |
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 2.) Also in case of 3.) If I call |
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. <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? |
Woops! Sorry, about the 3rd question I meant what if xml = the animal node and then we call |
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? |
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 :) |
oops sorry missed that! will take a look next chance i get. |
@lmccart Is this finished? Or is there anythiing left with file I/O ? |
@DarkPrince304 the three checkboxes in the first post still need looking into. |
@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 |
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. |
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. |
yes, definitely. the svg issue is still open: #458. |
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:
The text was updated successfully, but these errors were encountered: