Last active
January 27, 2020 20:16
-
-
Save rayfranco/6bc4a0d5bdcf073556da 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
var cushion = .5; | |
var length = 50; | |
var dx = point.x - mouse.x; | |
var dy = point.y - mouse.y; | |
var da = Math.sqrt(dx * dx + dy * dy); | |
// Tend à ramener la distance entre les segments à length | |
var ox = dx / da * length - dx; | |
var oy = dy / da * length - dy; | |
point.x += ox * cushion; | |
point.y += oy * cushion; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment