Created
June 23, 2016 18:42
-
-
Save CalebWhiting/43e80749ad4662968fd6aaac9f002d7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.jscrape; | |
| import org.jscrape.internal.*; | |
| import org.jscrape.mouse.*; | |
| import org.jscrape.spline.*; | |
| import org.jscrape.util.*; | |
| import java.awt.geom.*; | |
| public class Main { | |
| public static void main(String[] args) { | |
| try { | |
| Point2D.Double start = new Point2D.Double(Cursor.getCursorX(), Cursor.getCursorY()); | |
| /** | |
| * Random point within the bounds of the display | |
| */ | |
| Point2D.Double end = new Point2D.Double( | |
| RNG.nextInt(ScreenBounds.getScreenWidth()), | |
| RNG.nextInt(ScreenBounds.getScreenHeight()) | |
| ); | |
| SplineBuilder builder; | |
| int n = RNG.nextInt(2); | |
| switch (n) { | |
| case 0: | |
| /** | |
| * Port of Benland100's spline from the old RSBot/Simba | |
| */ | |
| builder = BenlandSplineBuilder.getInstance(); | |
| break; | |
| case 1: | |
| /** | |
| * Self-explanatory | |
| */ | |
| builder = BezierSplineBuilder.getInstance(); | |
| break; | |
| case 2: | |
| /** | |
| * Slightly less enthusiastic, takes into consideration the distance to traverse | |
| * and calculates a reasonable amount of control points and the radius of them, | |
| * to avoid having a very curvy short spline or very straight long spline. | |
| */ | |
| builder = ModerateBezierSplineBuilder.getInstance(); | |
| break; | |
| default: | |
| throw new IndexOutOfBoundsException("No SplineBuilder associated with #" + n); | |
| } | |
| if (RNG.nextBoolean()) { | |
| /** | |
| * Generates two splines to the target, either around the target or | |
| * somewhere in the middle of the spline, using the given SplineBuilder | |
| * to generate the segments. | |
| */ | |
| builder = OvershootingSplineBuilder.getInstance(builder, -1); | |
| } | |
| Spline spline = builder.build(start, end, null); | |
| /** | |
| * Removes points which are on top of each-other | |
| */ | |
| spline = spline.space(0); | |
| /** | |
| * Retains every nth point, to trim the spline but retain any point-clusters | |
| */ | |
| spline = spline.trim(10); | |
| /** | |
| * Iterates the spline with a gradual increase in delay between each step | |
| */ | |
| spline.iterateIncrementalDelay(Cursor:: setCursorPosition); | |
| } catch (Throwable ex) { | |
| ex.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment