- From: Christoph Guttandin via GitHub <sysbot+gh@w3.org>
- Date: Thu, 09 Mar 2023 11:53:17 +0000
- To: public-webtiming@w3.org
What about adding another overload to the constructor which accepts two functions to modify the vector when querying it or when updating it? Let's say we want to scale the position by 2 we could then do the following. ```js const scaledTimingObject = new TimingObject( timingObject, { query: ({ position, ...vector }) => ({ position * 2, ...vector }), update: ({ position, ...vector }) => ({ position / 2, ...vector }) }) ); ``` It would be similar to `new timingsrc.ScaleConverter(to, 2)` from the demo implementation linked above. One could also use this to implement similar readymade converters. ```js const scale = (timingObject, factor) => new TimingObject( timingObject, { query: ({ position, ...vector }) => ({ position * factor, ...vector }), update: ({ position, ...vector }) => ({ position / factor, ...vector }) }) ); ``` It could be used by calling `scale(to, 2)`. -- GitHub Notification of comment by chrisguttandin Please view or discuss this issue at https://github.com/webtiming/timingobject/issues/13#issuecomment-1461893662 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 9 March 2023 11:53:19 UTC