private void ProcessPointerInput()

in ExampleGallery/GameOfLife.xaml.cs [291:328]


        private void ProcessPointerInput(PointerRoutedEventArgs e)
        {
            if (!isPointerDown)
                return;

            // Invert the display transform, to convert pointer positions into simulation rendertarget space.
            Matrix3x2 transform;
            Matrix3x2.Invert(GetDisplayTransform(canvas), out transform);

            foreach (var point in e.GetIntermediatePoints(canvas))
            {
                if (!point.IsInContact)
                    continue;

                var pos = Vector2.Transform(point.Position.ToVector2(), transform);

                var x = canvas.ConvertDipsToPixels(pos.X, CanvasDpiRounding.Floor);
                var y = canvas.ConvertDipsToPixels(pos.Y, CanvasDpiRounding.Floor);

                // If the point is within the bounds of the rendertarget, and not the same as the last point...
                if (x >= 0 &&
                    y >= 0 &&
                    x < simulationW &&
                    y < simulationH &&
                    ((x != lastPointerX || y != lastPointerY)))
                {
                    // We avoid manipulating GPU resources from inside an input event handler
                    // (since we'd need to handle device lost and possible concurrent running with CreateResources).
                    // Instead, we collect up a list of points and process them from the Draw handler.                    
                    hitPoints.Add(new IntPoint(x, y));

                    lastPointerX = x;
                    lastPointerY = y;
                }
            }

            canvas.Invalidate();
        }