using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using bbiwarg.Detectors.Touch; using bbiwarg.Utility; namespace bbiwarg.Graphics { class TouchEventVisualizer { public OutputImage OutputImage { get; private set; } private List touchPositions; private int width, height; public TouchEventVisualizer(int width, int height) { touchPositions = new List(); this.width = width; this.height = height; } public void addPalmTouchEvent(PalmTouchEvent e) { Vector2D pos = new Vector2D((int) (e.RelativePalmPosition.X * width), (int) (e.RelativePalmPosition.Y * height)); touchPositions.Add(pos); } public void updateImage() { OutputImage = new OutputImage(width, height); for (int i = 1; i < touchPositions.Count; ++i) { OutputImage.drawLineSegment(new LineSegment2D(touchPositions[i - 1], touchPositions[i]), 255, 255, 255); } if (touchPositions.Count != 0) OutputImage.fillCircle(touchPositions.Last().IntX, touchPositions.Last().IntY, 3, 255, 0, 0); } public void Reset() { touchPositions.Clear(); OutputImage = new OutputImage(width, height); } } }