The first step would be to get the previousState. This var is set when the rule was triggered by changed, so we already have it. As the item which triggered the rule is an color item, you will have to split the state to different values, either HSB or RGB. This has to be done for previousState and for Item.state. Please take a look at Example: Convert Color Item Values To RGB (With Explanation).
From this point, I think, it’s a simple task…