API quality of life updates
The API right now is really impressive, and I love the ability to reload my code in real time with every change so that development is as easy as just putting down the headset! The console placement is also excellent. After spending ~5 hours working with the plugin API, though, I have some suggestions:
1. EASY PRIMITIVE DRAWING FOR PLUGIN UI.
I would like it so that if the API needs to draw a sphere, cube, or circle, I can just specify a Vector3D and change one other parameter to have the shape be filled or hollow. Another parameter should be color (RGBA). The texture doesn’t matter – the purpose is entirely UI. (although I guess some folks are going to want to be able to change the texture, because no one really wants to define how to draw a cube path by path themselves).
2. EASIER TEMPORARY DRAWING.
One command should delete every stroke a plug-in has generated. Perhaps even the strokes from a plug-in should be kept in a separate stroke object for a greater ease of management.
This would simplify UI work GREATLY (it’s currently just really hard to delete strokes right now).
4. PLEASE NO NULLS.
Right now Sketch.stroke.count gives a NULL if the sketch has been cleared. I lied: I have substantial programming experience, but not in Lua.
I think, if a sketch has just been cleared, Sketch.stroke.count should return 0. This would simplify scripting Open Brush.
5: COPYING ERROR MESSAGES?
As I was saying, the console placement in open brush is excellent. However, I could not find a way to copy error messages on the desktop system I was using. Perhaps introduce a keyboard shortcut that copies console output or one that opens a text. Based console on the computer that open brush is running on for ease of copy/pasting error messages.
3 Replies
4. Any null errors you find are bugs and I'll fix them. I wil confess I slapped a lot of the plugin API together quickly and it's had minimal testing outside the stuff used in the example plugins - so these bug reports are invaluable.
5. Great idea
3. Where do we use alpha? I actually can't remember any place we use it off the top of my head.
2. This is a bit of a niche use case and I'd probably argue that you can implement something yourself using layers - or just keeping track of the strokes you've drawn so you can delete them when needed. (let me know anything that helps the "keep track of strokes you've drawn" part of this)
1. So - what's the list of primitives you'd like? And bear in mind "sphere" could mean a lot of different things if you are rendering it with anything other than a hull brush. Strokes are what matter.
1: Square, circle, cube, sphere. I suppose just use a matte material, but it’s really important that I can control the alpha value. That will allow the user to preview the input to the plug-in before it runs (I wanted to put a sphere at each point the user selects so that they know what three points they’ve selected.)
3: on second thought we don’t. This is AI nonsense.
2: I was a bit confused by the code to draw a circle, because it doesn’t seem to define a radius or a center point. It seems like the preview that the user interacts with defines all of this, thus the plug-in seems to function almost in a separate environment.
My thinking was, if we are going to keep the plug-in separate from the sketch, perhaps we should keep the strokes from the plug-in separate from the sketch as well because I had a lot of difficulty trying to delete them programmatically .
1. we don't really have materials as such - we have brushes. and there's not really any support for alpha as you might have noticed from paint tools. the API does offer some support for "dissolve" which is a bit like alpha. it's not very well documented because it's still a work in progress but have a look at SetShaderFloat and the crossfade layers example plugin
2. the main job of a tool plugin is just to create a bunch of strokes that form the desired shape. it's the user that decides how big to draw them when he's uses the tool plugin. its relative size that matters So the circle tool plugin just creates a unit circle at the origin.
I don't understand what you mean about keeping strokes from a plugin separate from a sketch. the job of plug insurance is to create elements in a sketch. there should be no distinction from plug in strokes and any other strokes. if you need there to be a distinction then that's down to your specific use case but it's not the normal way of things.
Update: By coincidence I was just messing around with the straight edge tool code and realised there's a mechanism for temporary preview strokes (it's used for the line and also the secret hidden circle and sphere variants that I can never remember how you activate)
I'm going to play with those and see if I can wire them up as a shape tool preview.
It might be possible to use it for simple text output but i still think this is a clunky approach.