-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation? #18
Comments
Not the author, but just chiming in with my two cents. If you simply want to linearly move the mouse (e.g., with constant speed and no acceleration) given some time Your struct PointF64 {
x: f64,
y: f64
}
impl PointF64 {
pub fn lerp(p1: Self, p2: Self, t: f64) -> Self {
let t_clamp = t.clamp(0., 1.);
Self {
(p1.x + (p2.x - p1.x) * t_clamp),
(p1.y + (p2.y - p1.y) * t_clamp),
}
} This will give you the Then the general implementation would be (you need a given
Note on sleeping for the last step: I found the the standard library For reference, you can check out my implementation (just from a toy project, definitely take the details with a grain of salt). This one eases the movement in and out from point to point: https://github.com/bwpge/mouse-jiggler/blob/8609a1914dd25ec10b3df5ddf4716e0ec134c853/src/mouse.rs#L95-L134 If you want to get more clever than this, such as rounding off the movements to look like the mouse is waving around, you might want to look into Bezier Curves (think of the "pen" tool in Photoshop or GIMP where you can drag around anchors to make curves). I also recommend this article which has a clever way on implementing continuous or composite bezier curves (this eliminates the jagged edges when combining curves). |
@AltF02 I can submit a PR for a (simple linear) animate function if you'd like, I'm just not sure if that functionality is within the scope for this crate. I would probably gate it behind a feature |
I'm not sure, I personally planned to create an alternative https://crates.io/crates/enigo with mouse-rs under the hood at some point. But unfortunately life got in the way. I think a hypothetical library like that would be a great fit for something like this. I personally think its out of scope, but I am more than happy to provide a note to a possible external library that implements this feature. |
I know that this crate doesn't have any animation logic, however I'd like to find a way to use this lib (move mouse cursor) with animation. Is there any crates to do this?
The text was updated successfully, but these errors were encountered: