I have an rectangle:
<Border x:Name="Elem1" BorderThickness="2" Height="100" Width="200" BorderBrush="Red" />
And a Windows.UI.Composition.SpotLight moving togehter with pointer:
const float LightDistance = 20;
_compositor = Window.Current.Compositor;
_pointLight = _compositor.CreatePointLight();
_pointLight.Color = Colors.White;
_pointLight.Targets.Add(ElementCompositionPreview.GetElementVisual(Elem1));
PointerMoved += (o, e) => {
var point = e.GetCurrentPoint(this).Position;
_pointLight.Offset = new Vector3((float)point.X, (float)point.Y, LightDistance);
};
When there is no light over rectagle, it remain black:
I would like the rest of the rectangle to be transparent, so only enlightened part will be visible
I've tried to add transparent AmblientLight, but the aplha channel is ignored.
I guess it could be achieved by SceneLightingEffect
, but how? :)
Special for you :D
Works better than ever!