Vector scaleLength(num value)

Source

Vector scaleLength(num value) {
  var scale = value / length;
  return new Vector(x * scale, y * scale);
}