-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
ImDrawList curve drawing apis #311
Comments
NB I have edited the post above a few times. Some links Some Code API |
I myself would skip everything except for Bezier. Does anyone here sees a firm reason for adding e.g. Catmull-Rom spline? |
Sounds reasonable and not complicated for maintenance. |
I'll aim to just add cubic/quad bezier for now, as per your post here Probably rename them also AddBezier() AddQuadraticBezier() |
…nd reads current point back, more standard (#311)
I'm closing this for now. I think we're good for a while with just the cubic beziers. |
Everyone using/writing node editors, @rokups has now added helpers functions in imgui_internal.h which may be of use to hover/interact with curves with the mouse:
|
What is the recommended way to have control points that sit on the curve? Catmull-Rom would be useful for this, but I'm probably missing something |
Following my example code in #306
I would like to introduce curve to the lower level ImDrawList API. I'm a bit ignorant on this matter so had to research it.
My main wonder is to find what's the best API for this sort of features. Here using (pos0,cp0,cp1,pos1) for bezier and (pos0,tan0,pos1,tan1) for Hermite makes sense according to apparently common representation but isn't it error-prone? Could Hermite be parametrized as (pos0,tan0,-tan1-pos1) ? Is that a thing that people do? When you add Catmull Rom into the mix, which as I understand are a subset of Hermite, then typically the inputs becomes (pos0,pos1,pos2,pos3), aka (pos0-tan0, pos0, pos1, pos1+tan1) expressed from the parameter of an Hermite curve. Should I skip general Hermite alltogether and just provide bezier & catmull rom?
Confusing.
Also haven't started looking at providing API taking multiple points to draw, e.g. a catmull rom from them.
Basically I want an API where different types of curves can co-exist, and user can draw piece-wise (single curves) or pass a connected list of points (in the case of, e.g. catmull rom splines).
Curiously it seemed hard to find reference curve API that were obvious, handled variants and not bloated. Partly because they tend to implement more complex features than just drawing.
Here what I got so far in ImDrawList as part of the pathing API.
Most simple/common case:
The Add* functions are generally helpers, here
NanoVG does:
Which it was I based it on except I added the first point as well (at the cost of not adding it if its a duplicate). I could also remove the first parameter from PathCubicXXTo() functions, and make AddCubicXX() functions call PathLineTo() to add a first point as well.
You can use the path functions to create path, mix curves and lines, stroke/fill the paths, etc.
Also considering different strategy for tesselation:
Basic implementation:
The text was updated successfully, but these errors were encountered: