waterbearlang / waterbear

Visual block syntax for programming languages
http://waterbearlang.com/
358 stars 88 forks source link

Add blocks to support Processing API #898

Open dethe opened 9 years ago

dethe commented 9 years ago

We should be able to support doing anything Processing.js or http://p5js.org can do, short of 3D. We don't have to do everything the same way, but we should be able to do it.

dethe commented 8 years ago

To be more specific, we'd like to support the ability to do what these APIs do: http://processingjs.org/reference/. That can be an overwhelming list, but the first step would be to remove all the APIs marked in red (which the JS version of Processing does not support), all of the 3D methods (out of scope) and then all of the things we already do. I think that would result in a more manageable list.

We don't have to have blocks 1:1 with Processing APIs either. Ideally we can have simpler ways of doing things than Processing does. And we certainly don't have to support all of the Java keywords like void, super, static, etc.

P5 (http://p5js.org/) is a re-thinking of Processing. Similar goals, but starting from JavaScript rather than from Java, so http://p5js.org/reference/ might be a better starting point than the Processing reference.

Some features may be out of scope due to complexity, for instance we already have a feature issue for creating new blocks (i.e., functions) so any Processing APIs for that would not be part of this issue. Once we have a list of features supported by Processing that are not yet a part of Waterbear we can discuss that list to prioritize, scope to blocks, etc.

ghost commented 8 years ago

Here's a list of APIs supported by p5js that are not currently supported by waterbear:

\ updated list to reflect comments

dethe commented 8 years ago

My thoughts on these. If I don't mention something from the above list, that's because I think it is straight-up a good block to have.

dethe commented 8 years ago

There are some more APIs around Acceleration, Pixels, Input, Output, etc., but this is a good start.

ghost commented 8 years ago

I guess I missed the arcs, bezier curves and quadratic curves, I see them now though! Maybe that is an indication that Paths isn't an intuitive name for these? At least not for me, but I may not be the general case :). As for the keyboard ones I think that there may be value to detect arbitrary keys, a lot of the p5js examples use "if any key down", so I included them here. I wasn't sure how much of the acceleration API we are currently covering, I have started to make a little example so I can figure out the scope of our implementation now, but I agree that they could be included in this list. As for the Pixels, I wasn't sure if that was a high priority or not, same with Input and Output. They would be useful at some point but to me seemed like a different project, say an I/O feature.

CelticMinstrel commented 8 years ago

Distance and square root are both possible currently, though it's probably more convenient (and maybe even less confusing) if they're included directly. I could do this, if you like. I notice we're also missing logarithms.

CelticMinstrel commented 8 years ago
distance()

I needed that enough to add it to my branch in utils, but haven't made a block yet

This is Euclidean distance, right? Only asking because I noticed the great circle distance implementation under geolocation (which, incidentally, appears not to have a block?).

ghost commented 8 years ago

log() is on the first list. I think those operations are common enough that they should be included as blocks

ghost commented 8 years ago

And yes distance() would be the Euclidean distance.

CelticMinstrel commented 8 years ago

Euclidean distance is easily implementable using Math.hypot().

CelticMinstrel commented 8 years ago

Since you self-assigned it, does that mean I shouldn't add the math blocks?

ghost commented 8 years ago

I am going to do this for my term project. If you do add the blocks there will still be enough for me to take on for the term, so you are welcome to if you want, but I can also do them once we have prioritized the list.

dethe commented 8 years ago

I agree 100% that Path isn't the right term. These should be part of the Shapes collection of blocks, I think. We should probably have a generalized regular polygon block too.

CelticMinstrel commented 8 years ago

I was thinking about the lack of polygons a little while ago, actually.

CelticMinstrel commented 8 years ago

The path blocks are also kind of weird, and I don't really understand how you'd use them.

ghost commented 8 years ago

@dethe do you have any input for prioritizing the updated list ?

dethe commented 8 years ago

@AdriennePind sorry for the delay. I think the new shape blocks are probably the most important of the missing pieces, especially if you can merge shapes and paths as discussed in #1238. Happy to talk more about this as needed.

ghost commented 8 years ago

@dethe no problem! I was thinking the same thing so I started working on adding a triangle block yesterday. I also think that merging shapes and paths is a pretty high priority so once I have finished this triangle block, and know a bit more about how shapes work, I will work on that.

ghost commented 8 years ago

@dethe I think I'm going to move on to adding some of the API's for input. You had mentioned something about that in the meeting on Monday that you would like me to address (for touch inputs I think). Would you be able to elaborate on that?

dethe commented 8 years ago

Mainly that I want to unify touch and mouse inputs as pointer inputs. We already do that for drag-and-drop, but should expose them that way for the blocks.