blob: 5fc31e7ff8c0ea52cf7cd39a9587ec8694cc6551 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package com.google.skar;
import android.graphics.Path;
import android.graphics.PointF;
public class SkARFingerPainting {
public Path path = new Path();
// Previous point added to the path. This points belongs to the path in local space.
public PointF previousPoint;
private int numberOfPoints = 0;
// Holds the model matrix of the first point added to such that the path can be drawn at the
// model location (i.e on the Plane)
private float[] modelMatrix;
public SkARFingerPainting() {}
// Adds another point to the path in Local space
public void addPoint(PointF p) {
if (numberOfPoints == 0) {
path.moveTo(p.x, p.y);
} else {
path.lineTo(p.x, p.y);
}
previousPoint = p;
numberOfPoints++;
}
public boolean isEmpty() {
return numberOfPoints == 0;
}
public float[] getModelMatrix() {
return modelMatrix;
}
public void setModelMatrix(float[] m) {
modelMatrix = m;
}
public void reset() {
path = new Path();
numberOfPoints = 0;
}
}
|