public override void Handle(IIntent <LightingValue> obj) { LightingValue startValue = obj.GetStateAt(TimeSpan.Zero); // This is gross, but it's because when you get a value from an intent, the time // is used in an exclusive manner for reasons. So this is trying to backup // the end time without affecting the the resulting value too much. LightingValue endValue = obj.GetStateAt(obj.TimeSpan - _oneTick); // Why we have to do this? I have no idea, but without it, the gradient rendering gives strange artefacts. // (If you want to see what I mean, make a long spin (minutes) across a bunch of elements in a group with // a simple pulse down (or up). The ends/starts of the effect flip to the color of the other end briefly, // for a single pixel width. I'm guessing it's an issue in the gradient rendering for large shapes where // the gradient rectangle is within the same integer range as the rendering rectangle. float offset = _rect.X * 0.004F; RectangleF gradientRectangle = new RectangleF( (_rect.X) - offset, _rect.Y, (_rect.Width) + (2 * offset), _rect.Height ); //(float)Math.Floor(_rect.X) - (_rect.X / 300), _rect.Y, (float)Math.Ceiling(_rect.Width) + (_rect.Right / 300) + 1.0F, _rect.Height using (LinearGradientBrush brush = new LinearGradientBrush(gradientRectangle, startValue.GetAlphaChannelIntensityAffectedColor(), endValue.GetAlphaChannelIntensityAffectedColor(), LinearGradientMode.Horizontal)) { _graphics.FillRectangle(brush, _rect); } }
public override void Handle(IIntent<LightingValue> obj) { LightingValue startValue = obj.GetStateAt(TimeSpan.Zero); // This is gross, but it's because when you get a value from an intent, the time // is used in an exclusive manner for reasons. So this is trying to backup // the end time without affecting the the resulting value too much. LightingValue endValue = obj.GetStateAt(obj.TimeSpan - _oneTick); // Why we have to do this? I have no idea, but without it, the gradient rendering gives strange artefacts. // (If you want to see what I mean, make a long spin (minutes) across a bunch of channels in a group with // a simple pulse down (or up). The ends/starts of the effect flip to the color of the other end briefly, // for a single pixel width. I'm guessing it's an issue in the gradient rendering for large shapes where // the gradient rectangle is within the same integer range as the rendering rectangle. float offset = _rect.X * 0.004F; RectangleF gradientRectangle = new RectangleF( (_rect.X) - offset, _rect.Y, (_rect.Width) + (2 * offset), _rect.Height ); //(float)Math.Floor(_rect.X) - (_rect.X / 300), _rect.Y, (float)Math.Ceiling(_rect.Width) + (_rect.Right / 300) + 1.0F, _rect.Height using (LinearGradientBrush brush = new LinearGradientBrush(gradientRectangle, startValue.GetAlphaChannelIntensityAffectedColor(), endValue.GetAlphaChannelIntensityAffectedColor(), LinearGradientMode.Horizontal)) { _graphics.FillRectangle(brush, _rect); } }
public override void Handle(IIntent<LightingValue> obj) { if (obj is StaticArrayIntent<LightingValue>) { Func<TimeSpan, Color> scg = x => obj.GetStateAt(x).TrueFullColorWithAlpha; Func<TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).TrueFullColorWithAlpha; DrawStaticArrayIntent(_endTime, _rect, scg, ecg); } else { Color startColor = obj.GetStateAt(_startOffset).TrueFullColorWithAlpha; Color endColor = obj.GetStateAt(_endTime - (_endTime<obj.TimeSpan?TimeSpan.Zero:_oneTick)).TrueFullColorWithAlpha; DrawGradient(startColor, endColor, _rect); } }
public override void Handle(IIntent<LightingValue> obj) { if (obj is StaticArrayIntent<LightingValue>) { Func<TimeSpan, Color> scg = x => obj.GetStateAt(x).FullColorWithAplha; Func<TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).FullColorWithAplha; DrawStaticArrayIntent(obj.TimeSpan, _rect, scg, ecg); } else { Color startColor = obj.GetStateAt(TimeSpan.Zero).FullColorWithAplha; Color endColor = obj.GetStateAt(obj.TimeSpan - _oneTick).FullColorWithAplha; DrawGradient(startColor, endColor, _rect); } }
public override void Handle(IIntent <RGBValue> obj) { if (obj is StaticArrayIntent <RGBValue> ) { Func <TimeSpan, Color> scg = x => obj.GetStateAt(x).ColorWithAplha; Func <TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).ColorWithAplha; DrawStaticArrayIntent(_endTime, _rect, scg, ecg); } else { Color startColor = obj.GetStateAt(_startOffset).ColorWithAplha; Color endColor = obj.GetStateAt(_endTime - (_endTime < obj.TimeSpan ? TimeSpan.Zero : _oneTick)).ColorWithAplha; DrawGradient(startColor, endColor, _rect); } }
public override void Handle(IIntent <LightingValue> obj) { if (obj is StaticArrayIntent <LightingValue> ) { Func <TimeSpan, Color> scg = x => obj.GetStateAt(x).FullColorWithAplha; Func <TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).FullColorWithAplha; DrawStaticArrayIntent(obj.TimeSpan, _rect, scg, ecg); } else { Color startColor = obj.GetStateAt(TimeSpan.Zero).FullColorWithAplha; Color endColor = obj.GetStateAt(obj.TimeSpan - _oneTick).FullColorWithAplha; DrawGradient(startColor, endColor, _rect); } }