bool Window::IsInBounds(int row, int col) const // post: returns true if the point (row, col) is in this window // otherwise, returns false { if (row < 0 || row >= myNumRows || col < 0 || col >= myNumCols) return false; return true; } void Window::ColorSqaure(int ULrow, int ULcol, int N, int val) // post: all points in this window that are also in the N-by-N square // with upper left corner (ULro, ULcol) have been set to val; // points in the square that are not in this window are ignored { for (int row = 0; row < N; row++) { int x = row + ULrow; for (int col = 0; col < N; col++) { int y = col + ULcol; if (IsInBounds(x, y)) myMat[x][y] = val; } } } void Enlarge(Window & W, const Rectangle & rect, int factor) // pre: factor > 0 { int lastRow = (rect.numRows - 1) * factor + rect.ULrow; for (int r = rect.ULrow + rect.numRows - 1; r >= rect.ULrow; r--) { int lastCol = (rect.numCols - 1) * factor + rect.ULcol; for (int c = rect.ULcol + rect.numCols - 1; c >= rect.ULcol; c--) { W.ColorSqaure(lastRow, lastCol, factor, W.ValAt(r,c)); lastCol -= factor; } lastRow -= factor; } }