-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Image stroke #2926
Image stroke #2926
Conversation
@@ -164,12 +164,12 @@ | |||
* @param {CanvasRenderingContext2D} ctx Context to render on | |||
*/ | |||
_stroke: function(ctx) { | |||
ctx.save(); | |||
this._setStrokeStyles(ctx); |
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.
_stroke is called by the _render function, _setStrokeStyle has been already done.
ctx.lineTo(w, -h); | ||
ctx.lineTo(w, h); | ||
ctx.lineTo(-w, h); | ||
ctx.lineTo(-w, -h); |
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 looks like an un-optimization, but in my opinion it simplify the rendering flow for the dev.
The point is that every shape do its path in the _render function and then we call .fill(); and .stroke(); Image was the only one that was doing differently, it was drawing the eventual border inside the renderStroke with strokeRect function and then not doing the ctx.stroke(); I think that getting 4 lineTo instead of strokeRect is slower, but we get a cleaner pipeline. Oh, also we had a very very rare bug: If someone would stroke with dash Array and gradient with gradientTransform, well, gradientTransform was not applied... no one notice in 2 years so not so popular combination |
Also look this code:
look results: left rectangle, right a chubby line. We are not translating the gradient for stroke ( and so patterns!!!) |
I will post screenshot to check i did not broke anything, but looks like that we have some mess in the stroke rendering under certain conditions.