Closed mgpreston closed 5 years ago
Thanks for your contribution to the project! Looks great. I'm going to merge the PR, do some testing and will create a new release with your code in it.
I published version Q42.HueApi.Entertainment 3.9.0 to NuGet, it includes this PR and the code from this conversation.
I have a particular scenario that needs the brightness of a light to be transitioned separately to the colour, e.g. transition from 0 to 1 brightness over 10 seconds, and transition from white to red over 2 seconds.
I couldn't find a clean way to implement this externally, so I made some changes to the Transition class to support the separate transitions. Its behaviour remains the same for any existing usage of the Transition class.
Additionally, the extra properties on Transition allow for reading the current progress of the transition. I'm using a custom SetState extension method that can combine an existing brightness transition with a new colour transition, or an existing colour transition with a new brightness transition.
For example, if brightness is being transitioned from 0 to 1 over 10 seconds, and it's currently 5 seconds in (at a brightness of 0.5), and the new transition is for colour to go from current to red over 2 seconds, the combined transition will be for the remainder of the brightness transition (from 0.5 to 1 over 5 seconds) as well as the colour transition:
By default the SetState method has
overwriteExistingTransition = true
which maintains backwards compatibility with existing SetState usage, creating a fresh transition and discarding any existing transition, rather than potentially combining with the existing transition.If you see this as having any value, you're welcome to add it. You may of course have better ideas for how to support these separate transitions.
Cheers, Mark