void Txtr::duplicateRectangleEdges(int x, int y, int width, int height) { if ( ! hasImage()) return; restrain<int>(x, 0, this->width-1); restrain<int>(y, 0, this->height-1); restrain<int>(width, 1, this->width-x); restrain<int>(height, 1, this->height-y); dAssert((x >= 0) && (y >= 0)); int leftSpace = x; int bottomSpace = y; int rightSpace = this->width - (x+width); int topSpace = this->height - (y+height); // duplicate in four directions duplicateColumn(x, y, height, -1, leftSpace); // left area duplicateColumn(x+width-1, y, height, 1, rightSpace); // right area duplicateRow(x, y, width, -1, bottomSpace); // bottom area duplicateRow(x, y+height-1, width, 1, topSpace); // bottom area //selectAndDuplicate(x, y, 0, 1, height, -1, 0, leftSpace); // left area //selectAndDuplicate(x, y, 1, 0, width, 0, -1, bottomSpace); // bottom area //selectAndDuplicate(x+width, y+height, 0, -1, height, 1, 0, rightSpace); // right area //selectAndDuplicate(x+width, y+height, -1, 0, width, 0, 1, topSpace); // top area //// duplicate the duplicates into the corners //selectAndDuplicate(x, y, 0, -1, bottomSpace, -1, -1, leftSpace); // left bottom down //selectAndDuplicate(x, y, -1, 0, leftSpace, -1, -1, leftSpace); // left bottom left //selectAndDuplicate(x, y+height, -1, 0, leftSpace, -1, 1, leftSpace); // left top left //selectAndDuplicate(x, y+height, 0, 1, topSpace, -1, 1, leftSpace); // left top up //selectAndDuplicate(x+width, y+height, 0, 1, topSpace, 1, 1, rightSpace); // right top up //selectAndDuplicate(x+width, y+height, 1, 0, rightSpace, 1, 1, rightSpace); // right top right //selectAndDuplicate(x+width, y, 1, 0, rightSpace, 1, -1, rightSpace); // right bottom right //selectAndDuplicate(x+width, y, 0, -1, bottomSpace, 1, -1, rightSpace); // right bottom down // fill corners fillArea(0, 0, leftSpace, bottomSpace, getPixel(x, y)); // left bottom fillArea(0, y+height, leftSpace, topSpace, getPixel(x, y+height-1)); // top left fillArea(x+width, y+height, rightSpace, topSpace, getPixel(x+width-1, y+height-1)); // top right fillArea(x+width, 0, rightSpace, bottomSpace, getPixel(x+width-1, y)); // right bottom }
/* checks if it is a valid square */ int safe(int twoDimArray[][9], int row, int col, int num) { if(duplicateRow(twoDimArray,row,num)) return 0; if(duplicateCol(twoDimArray,col,num)) return 0; if(duplicateInBox(twoDimArray, row - row % 3, col - col % 3, num)) return 0; else return 1; }