-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add ctx transform is identic #77
base: master
Are you sure you want to change the base?
Conversation
// TODO why is the initial _path array not empty?
_path = [createCanvasEvent('beginPath', undefined, {})]; this should probably be empty in the |
return { type, transform, props }; | ||
return transform | ||
? { type, transform, props } | ||
: { type, props } |
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.
Again. I try to keep the interface exactly as it is to prevent v8 deoptimization. I don't think this is an appropriate change to jest-canvas-mock.
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.
hmm. make it optional? in my case, i dont use v8 serialize
but then i can post-process the data in my serializer ..
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.
its even simpler: we can omit the transform
field entirely, cos its 100% redundant
the transform state can always be derived from the past API calls to ctx.setTransform
etc
so .. can we add an option to omit the transform
field?
(of course in a zero-cost / unswitched way)
* This array keeps track of the current path, so that fill and stroke operations can store the | ||
* path. | ||
*/ | ||
_path = [createCanvasEvent('beginPath', [1, 0, 0, 1, 0, 0], {})]; | ||
// TODO why is the initial _path array not empty? | ||
_path = [createCanvasEvent('beginPath', undefined, {})]; |
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.
@jtenner can you explain why the _path
array is not empty?
at least in the Path2D class, there is no method beginPath
but also an empty context expects me to explicitly call beginPath
, no?
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 was a design choice, and I agree. This probably isn't correct. However, I chose to keep things consistent between CanvasRenderingContext2D
class and the Path
class. I could be convinced to make a change on the Path2D
class, but I'm not entirely sure it would be helpful.
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.
its helpful to get an *exact* record of API calls, which can be replayed to a live canvas
surely i can work around this issue in my consumer (ignore path.beginPath()
), but ..
this *should* be fixed upstream
This was a design choice
why? why should we record calls that were not explicitly made?
again, i expect this tool to produce an *exact* image of my API calls
@hustcc is this still active? |
replace #75