waterbearlang / waterbear

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

Merge Shape and Path blocks #1238

Closed dethe closed 8 years ago

dethe commented 8 years ago

This is kind of a biggie, but the existing Path blocks are confusing and don't interact well with Shape blocks. Currently you have to create a PathSet block and add segments to it, then draw the PathSet. You cannot draw, say, an Arc by itself.

Also, the segment blocks are named "draw x" when they don't draw anything (they just add a segment to the Path, which can then be drawn).

My proposal is that we move all the Path blocks to the Shapes menu and add a "Last point" block which I'll explain below.

Each of the current Path blocks for segments would become usable as a stand-alone Shape block or could be placed in a Path block (renamed from PathSet, and I'm open to a better name for this). A Path is basically a collection of shapes (segments) that makes sense to draw on it's own.

Each of the segments would need one more value socket for a starting point/vector.

When drawing a segment as a standalone shape:

When drawing a segment as part of a Path block:

If the Last Point block is used outside of a Path or as the first block in a path, it would resolve to <0,0>.

All the segments should be renamed to not have "draw" in their names.

Essentially, the Path block becomes an shape expression context for grouping any of the shapes and all of the segments become shapes.

I hope this is clear. Happy to elaborate as needed. Interested in hearing other thoughts on this.

CelticMinstrel commented 8 years ago

I was also thinking a context type block would make more sense for this. Or perhaps it could be handled similarly to the array block, with + and - buttons, allowing you to put path segments in each slot. (This really depends on whether it makes more sense for the path segments to be steps or expressions.)

dethe commented 8 years ago

Yes, I was thinking that it would be like the Array block (that and Object are the only examples so far of "expression context" blocks). It would be nice if those blocks automatically grew a new row if you drag a matching expression over them.

CelticMinstrel commented 8 years ago

I'm assuming you only closed this by accident.

Growing a new row sounds like a good idea with array/dictionary blocks. (I think dictionary might be a better name than object.)

dethe commented 8 years ago

Ha. Yes, clicked the wrong button, thanks! I like Dictionary better, and recent browsers actually have a dictionary object which doesn't inherit from Object.

CelticMinstrel commented 8 years ago

That's the first I've heard of that, but it's only implemented on Firefox, apparently.

dethe commented 8 years ago

Part of ES6, I think. We can simulate by using an Object with no prototype (not a perfect simulation, but good enough for our purposes).

CelticMinstrel commented 8 years ago

I was under the impression that a null prototype was equivalent to using Object.prototype as the prototype.

dethe commented 8 years ago

No, you can try setting proto to null on an object, you're no longer able to access toString or other standard properties of Object. The official way to to this is Object.create(null).

ghost commented 8 years ago

Closed by #1246