-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Graphics: adaptive calculation of quadratic curve and arc subdivision #4658
Conversation
Adaptive rasterizing is good, but that change breaks previous behaviour. I approve it either other approve either if something like |
Also it has max segments lengths constant. Lets see if @GoodBoyDigital and @bigtimebuddy agree to changes in current form. |
src/core/graphics/Graphics.js
Outdated
/** | ||
* Calculate length of quadratic curve. | ||
* The detailed explanation of math behind this can be found under | ||
* http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be tagged by @see
http://usejsdoc.org/tags-see.html
Big +1 As for BC I'm not sure it applies here, so we should be able to drop it for next patch/minor version.
|
src/core/graphics/Graphics.js
Outdated
else if (result > 2048) | ||
{ | ||
result = 2048; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain more about these magic numbers 10
and clamping to 8
and 2048
? What's the rationale? Are there scenarios where you'd want to alter these?
I say just put those numbers and behaviour switch in constant and document it properly , and then merge. Set behaviour by default in next major version. |
These constants were selected experimentally. 10 is the length of a single segment. It seems to give good looking results on the curves of average length. 8 seems to be enough for very short curves. 2048 is just some "bug number" limiting the maximal number of segments. But you right, there could be some corner cases, when these constants won't be adequate. So I agree, the setting for this is the best choice. I fix it soon. |
Btw, currently, all vector things in pixi work for scale=1. Transform isnt taken into account in rasterizing, and for now its ok. |
@icosaeder Don't forget about the regular Another way to get number of segments using hyperbola.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! Nice work @icosaeder 👍
@OSUblake makes a good point! @icosaeder, Thanks for your efforts so far, think you could round this PR off by adding similar functionality to |
Thank you! :) |
hey @icosaeder, any progress on this with |
Hi! I'm very sorry for the delay, the last couple of weeks I had some urgent things to do. But now I pushed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the settings to Graphics.CURVES
object instead of creating new setting
properties. I also tweaked the property names slightly for brevity and clarity.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Evaluating PIXI (great engine indeed!) I found that the curves have constant subdivision ratio. This produces jagged edges if the curves are long enough:
https://www.dropbox.com/s/y9hxkkhjbtpkgsm/pixi_curves_old.png?dl=0
So I suggest calculating the subdivision based on the curves' length:
https://www.dropbox.com/s/h1dx5smaxp7inzl/pixi_curves_new.png?dl=0