1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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<Vector2D> touchPositions;
- private int width, height;
- public TouchEventVisualizer(int width, int height)
- {
- touchPositions = new List<Vector2D>();
- 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<Vector2D>().IntX, touchPositions.Last<Vector2D>().IntY, 3, 255, 0, 0);
- }
- public void Reset()
- {
- touchPositions.Clear();
- OutputImage = new OutputImage(width, height);
- }
- }
- }
|