With an arbitrary starting location, that can be any point along the edge of a rectangle, how would you iterate over every point in a clockwise order? So for example if the starting point happens to be (1, 0) like in the image below, how would you iterate over all the points, shown as green squares, around the rectangle. I can probably do a simple brute force method by figuring out which edge of the rectangle the starting point is on and moving the position along that edge until the max x or y is reached and then follow along the next edge until the starting point is reached again, but I'm just curious if there is a more elegant solution.
I forgot to add that the data I have to work with is the top-left position of the rectangle, its size, and the starting point along the edge.