We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, Where or how can I access the properties (methods) that can be passed to an object? For example, if I want to know which properties I can pass to the ellipse() object, where can I find this information? I am having a hard time finding out how to talk to my objects.
At the moment I am using console.dir(Object.keys(ellipse())); but what I cannot really make sense of what it is returning.
Any help is welcome. Apologies if the question has been asked before, I could not find the answer in the forum.
Thanks! Irving.
Answers
In theory you should find all the information you need in the p5js reference. For example here's the entry for ellipse.
There's an obvious problem with using
console.dir(Object.keys(ellipse()));
to inspect Ellipse's (or any Object's) composition: it also includes inherited properties. If you look at the source you'll see that Ellipse exposes NO public properties/methods whatsoever... Note also that preceding an identifier with an _underscore is a convention for private properties/methods that you should avoid depending on in your code: and that's the case for the majority of Ellipse's inherited properties/methods...Look up its reference: http://p5js.org/reference/#/p5/ellipse
Some jargon explanation though: :-B
https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
Thank you, both, for your answers.
I apologize if I did not explain my question clearly. I am well aware of the reference page. The reason why I ask the question is because it seems to me that it lacks essential information as to which methods to pass the objects.
Regardless, it seems I was a bit confused, or just ignorant about the library.
It makes a lot of sense that ellipse() is a function, even if still an object. My guess is that I will need to create an object that holds the function.
Thanks again, your answers are very helpful.
Gonna try to be more pedantic precise. Hope it doesn't make things messier to understand. ^#(^
Hahaha, well, thank you. I do understand the concepts to a good level. It is helpful for me to see the source code and try to get the hang of it, even though I am not too familiarized with JS and the p5js libraries.
Thanks again for your time, I appreciate it!