kformeck
kformeck

Reputation: 1923

Given top left and bottom right points, how can I find all points inside a rectangle?

I am trying implement an excel-like click+drag feature where the user clicks on a cell and drags. When the user stops dragging, I am able to calculate the top left corner and the bottom right corner of the rectangle. I can also easily calculate the length, height and area of the rectangle, but how do I calculate the coordinates inside the rectangle?

Upvotes: 0

Views: 1396

Answers (1)

John
John

Reputation: 16007

Pseudocode:

for i = left_edge to right_edge
    for j = top_edge to bottom_edge
        add [i, j] to list of points inside rectangle

Upvotes: 1

Related Questions