**EDIT: I guess this is irrelevant for you now, but it is still interesting.**
If the squares with any edges inside the "path" are included, I found something interesting that I cant quite get into a formula.

Follow me below. When I talk about width and height, I am talking about a large square, where each of the start and end points provided are two corners of the square. So for the one above, the large square would have a width of 4 and a height of 7.

Ok, so:

For every "path" with a slope of 1: when you increase the width by 1, the number of squares increase by 3.

For every "path" with a slope of 2: when you increase the width by 1, the number of squares increase by 5.

For every "path" with a slope of 3: when you increase the width by 1, the number of squares increase by 7.

And so on in that pattern.

There is also something else I found:

For every large square with a width of 2: the number of squares in the path increase by 2 compared to the preceding slope.

For every large square with a width of 3: the number of squares in the path increase by 4 compared to the preceding slope.

For every large square with a width of 4: the number of squares in the path increase by 6 compared to the preceding slope.

For every large square with a width of 5: the number of squares in the path increase by 8 compared to the preceding slope.

And so on in that pattern also.

So, for the above path:

The large square has a width of 4 and a height of 7.

The slope is 2.

So the number of squares is 16.

I'm not sure how to make a formula out of those trends. Any thoughts?

EDIT AGAIN: I may have figured out a formula. It works for all my test cases. All my test cases have positive integer slopes.

Formula: squares = (Width+Length)+(Length-2)

It is odd, but it works...