diff --git a/src/Cursor.java b/src/Cursor.java index 45d0f33..bccc2f7 100644 --- a/src/Cursor.java +++ b/src/Cursor.java @@ -67,7 +67,6 @@ public class Cursor { this.cursorPathsByDistance.get(cursorPath.getCursorPathDistance()).add(cursorPath); } - // TODO: make sure these are reasonable private int getRandomClickLength() { return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH); @@ -76,7 +75,7 @@ public class Cursor { private int getRandomClickReleaseLength() { return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH + 5, MAXIMUM_CLICK_LENGTH + 10); } - + // END public void leftClickCursor() throws InterruptedException { robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); diff --git a/src/CursorPath.java b/src/CursorPath.java index 9242347..56ec307 100644 --- a/src/CursorPath.java +++ b/src/CursorPath.java @@ -3,6 +3,7 @@ */ import java.util.ArrayList; +import java.util.Random; public class CursorPath { @@ -10,6 +11,7 @@ public class CursorPath { private double theta; private int distance; private int timespan; + Randomizer randomizer; public CursorPath(ArrayList cursorPoints) { @@ -17,8 +19,10 @@ public class CursorPath { this.distance = calculateCursorPathDistance(); this.theta = calculateCursorPathTheta(); this.timespan = calculateCursorPathTimespan(); + this.randomizer = new Randomizer(); } + // TODO: refactor public CursorPath(ArrayList cursorPoints, boolean setInitializiationOff) { this.cursorPoints = cursorPoints; @@ -54,20 +58,30 @@ public class CursorPath { } public CursorPath getScaledCopyOfCursorPath(double factorToScaleBy) { - ArrayList scaledCursorPath = new ArrayList(); + ArrayList scaledCursorPoints= new ArrayList(); for (CursorPoint cursorPoint : this.cursorPoints) { - scaledCursorPath.add(cursorPoint.getCursorPointScaledBy(factorToScaleBy)); + scaledCursorPoints.add(cursorPoint.getCursorPointScaledBy(factorToScaleBy)); } - return new CursorPath(scaledCursorPath, true); + return new CursorPath(scaledCursorPoints, true); } public CursorPath getRotatedCopyOfCursorPath(double angleToRotateTo) { - ArrayList rotatedCursorPath = new ArrayList(); + ArrayList rotatedCursorPoints = new ArrayList(); double angleToRotateBy = this.theta - angleToRotateTo; for (CursorPoint cursorPoint : this.cursorPoints) { - rotatedCursorPath.add(cursorPoint.getCursorPointRotatedBy(angleToRotateBy)); + rotatedCursorPoints.add(cursorPoint.getCursorPointRotatedBy(angleToRotateBy)); } - return new CursorPath(rotatedCursorPath, true); + return new CursorPath(rotatedCursorPoints, true); + } + + public CursorPath getCopyOfCursorPathTransformedByParabola() { + double[] parabolaEquation = randomizer.generateParabolaEquation(this.getCursorPathDistance()); + ArrayList transformedCursorPoints = new ArrayList(); + for (CursorPoint cursorPoint : this.cursorPoints) { + transformedCursorPoints.add(cursorPoint.getCursorPointTransformedBy(parabolaEquation);) + } + return new CursorPath(transformedCursorPoints, true); + } private int calculateCursorPathTimespan() { diff --git a/src/CursorPoint.java b/src/CursorPoint.java index 4a57d96..594eb66 100644 --- a/src/CursorPoint.java +++ b/src/CursorPoint.java @@ -34,6 +34,12 @@ public class CursorPoint { return (new CursorPoint(rotatedX, rotatedY, delay)); } + public CursorPoint getCursorPointTransformedBy(double[] parabolaEquation) { + int rotatedX = (int) 5; + int rotatedY = (int) 5; + return (new CursorPoint(rotatedX, rotatedY, delay)); + } + public CursorPoint getCursorPointWithNewDelay(int delay) { return (new CursorPoint(this.x, this.y, delay)); } diff --git a/src/Randomizer.java b/src/Randomizer.java index 1b5c768..4fa7a8a 100644 --- a/src/Randomizer.java +++ b/src/Randomizer.java @@ -21,7 +21,6 @@ public class Randomizer { } return (int) result; } - public Point generatePeakForTransformationParabola(int pathDistance) { double maxTransformationScale = 0.2; int peakX = nextGaussianWithinRange(0, pathDistance); @@ -29,7 +28,8 @@ public class Randomizer { return new Point(peakX, peakY); } - public double[] generateParabolaEquation(int pathDistance, Point peakPoint) { + public double[] generateParabolaEquation(int pathDistance) { + Point peakPoint = generatePeakForTransformationParabola(pathDistance); double[][] lhsMatrix = {{0, 0, 1}, {peakPoint.x * peakPoint.x, peakPoint.x, 1}, {pathDistance * pathDistance, pathDistance, 1}}; double[][] rhsMatrix = {{0, peakPoint.y, 0}}; diff --git a/target/classes/Cursor.class b/target/classes/Cursor.class index 8f2edb5..eedc53b 100644 Binary files a/target/classes/Cursor.class and b/target/classes/Cursor.class differ diff --git a/target/classes/CursorPath.class b/target/classes/CursorPath.class index f352f91..d872513 100644 Binary files a/target/classes/CursorPath.class and b/target/classes/CursorPath.class differ diff --git a/target/classes/CursorPoint.class b/target/classes/CursorPoint.class index 630dceb..2bdb434 100644 Binary files a/target/classes/CursorPoint.class and b/target/classes/CursorPoint.class differ diff --git a/target/classes/Randomizer.class b/target/classes/Randomizer.class index a4fbe73..cfba3b3 100644 Binary files a/target/classes/Randomizer.class and b/target/classes/Randomizer.class differ diff --git a/target/classes/RandomizerTest.class b/target/classes/RandomizerTest.class index 3e125a3..7eba454 100644 Binary files a/target/classes/RandomizerTest.class and b/target/classes/RandomizerTest.class differ