diff options
author | ziadb <ziadb@google.com> | 2018-07-17 15:30:55 -0400 |
---|---|---|
committer | Ziad Ben Hadj-Alouane <ziadb@google.com> | 2018-07-18 15:31:35 +0000 |
commit | a44a8a16a8e801c08ee407cfaaafd892d5c2c407 (patch) | |
tree | fae7c790d381f41b25c6dfbae9319bd5a515b8b5 /platform_tools/android/apps/skar_java/src/main/java/com/google/skar | |
parent | dc97fdc23571ab8126f8c2a8b0991cf2280ef023 (diff) |
SkAR-Java: finger painting first implementation
SkAR Java: drawing planes as paths
FREEZE.unindexed
Bug: skia:
Change-Id: I2a7a8534fc1c35c4b8d6054bc1d6e682ffabc47a
Reviewed-on: https://skia-review.googlesource.com/141827
Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'platform_tools/android/apps/skar_java/src/main/java/com/google/skar')
-rw-r--r-- | platform_tools/android/apps/skar_java/src/main/java/com/google/skar/SkARFingerPainting.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/platform_tools/android/apps/skar_java/src/main/java/com/google/skar/SkARFingerPainting.java b/platform_tools/android/apps/skar_java/src/main/java/com/google/skar/SkARFingerPainting.java new file mode 100644 index 0000000000..6d3d0582a4 --- /dev/null +++ b/platform_tools/android/apps/skar_java/src/main/java/com/google/skar/SkARFingerPainting.java @@ -0,0 +1,56 @@ +package com.google.skar; + +import android.graphics.Matrix; +import android.graphics.Path; +import android.graphics.PointF; + +public class SkARFingerPainting { ; + public Path path = new Path(); + + 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; + + // Holds the inverse model matrix of the first point that was added such that the path is drawn + // first at (0, 0) + private float[] inverseModelMatrix; + + public SkARFingerPainting() {} + + // Adds another point to the path in Local space (i.e apply InverseModelMatrix to points located + // in Global space (e.g hit positions acquired through hit tests) + public void addPoint(PointF p) { + if (numberOfPoints == 0) { + path.moveTo(p.x, p.y); + } else { + path.lineTo(p.x, p.y); + } + numberOfPoints++; + } + + public boolean isEmpty() { + return numberOfPoints == 0; + } + + public float[] getModelMatrix() { + return modelMatrix; + } + + public float[] getRawInverseModelMatrix() { + return inverseModelMatrix; + } + + public Matrix getInverseModelMatrix() { + return SkARMatrix.createMatrixFrom4x4(inverseModelMatrix); + } + + public void setModelMatrix(float[] m) { + modelMatrix = m; + } + + public void setInverseModelMatrix(float[] m) { + inverseModelMatrix = m; + } +} |