-
Notifications
You must be signed in to change notification settings - Fork 15
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
visualizers enable mouseClicked(); visualizers access their canvas #120
Comments
I believe this is part of @katestange's work on #115. (Or at least she made this issue while working on #115.) |
This blocks progress on #115. |
This may be helpful: vue-p5 project by Kinrany |
So the canvas you refer to is present in the p5 object as (in our case) So there are a couple of ways I have thought of to proceed:
(2A) The wrapper could be changed to capture that canvas object and transmit it to the Visualizer. That's totally fine and doable. The only con to this approach is that it proceeds in the direction of making Numberscope more specifically tailored to p5-based Visualizers, when my preference would be to head in the other direction of making easier to add a Visualizer based on DataTables or three.js or whatever. (2B) The CanvasArea wrapper could be simplified or perhaps removed altogether, so that the createCanvas would be happening in Visualizer code, where its return value could easily be saved for later use. The drawback here is that then there's common code that all Visualizers would need. But we could handle that by putting that boilerplate in VisualizerDefault that all visualizers derive from anyway. And this path moves in the direction of making the containing component less specific to p5, and hence easier to adapt in the future to other packages for visualization. Let me know your thoughts on how you'd like to proceed here at the moment (we could refactor to another approach later). |
This might be worth a live discussion, since I think I don't entirely understand the issues of specifically tailoring visualizer support to p5 vs. different platforms. Let's add it to the agenda for the meeting. |
At 2022-07-25 meeting, we agreed that 2B is the correct approach. |
I'd like to move up the priority for this one slightly. I think our students may appreciate having mouseClicked() -- at least, I would. ;) |
OK I haven't had the time to get to Zulip and now the Tuesday build has to be my top priority. So I will do Zulip as soon as I have all prep for Tuesday done, and then put this next on my agenda. |
I would like to have keyPressed() also... I think at a first glance this is suffering the same issue. |
Assigning myself. I am going to try to implement the solution described in 2B in #120 (comment). |
Yeah, I figured that was coming. Please do add it to the TODO discussion, and decide whether it's worth it to make a Project for the frontscope to prioritize things like I did with the backscope. Thanks. Unless @Vectornaut calls for help on the remaining backscope items (all of which are currently nominally in his court), I will make this my next Numberscope priority (but won't self-assign until I start in on it, in case someone else is just itching to give it a crack). |
PS Whoever does work on it needs an example visualizer that would use the functionality, so if anyone is able to provide a specific example patch to an existing visualizer, or a new toy visualizer that would use this, please either provide a branch with that, or post a visualizer source file here, or something. It would be hard to implement without some example client code that would make use of it. Thanks! |
The following branch should provide a simple tester that will check for mousePressed(), mouseReleased() and keyPressed(). It is also easily modifiable to add others. However, I don't have any way to test if it works! Note: I adapted the code from the p5.js reference pages. https://github.com/katestange/frontscope/tree/mouse_tester. |
To use it ought to be self-evident; open numberscope and click on Mouse Tester visualizer, which has no parameters. The visualizer itself displays instructions. |
Correspondingly, remove all p5-specific code from the Vue views and components. This means the Visualizer code is handling all the canvas operations, so p5-based visualizers have access to the canvas. In addition, any of the standard p5 methods that are present as methods of the visualizer are installed on the sketch, so they will be called by the sketch when the associated events occur. Finally, this commit adds methods to dispose of the visualizer, to avoid multiple dangling sketch instances, which could otherwise cause events to be multiply processed. Resolves numberscope#120. Resolves numberscope#272. Possibly it also handles numberscope#244; it should be checked after this is merged.
The visualizer should be able to use the mouseClicked() feature of p5.js.
Visualizers should be encouraged to use it as associated to a canvas, so the user has to click in the canvas (not just anywhere). In order for this to happen, the visualizer has to have access to its own canvas, as in the examples at the link above. See also #118.
The text was updated successfully, but these errors were encountered: