static int autocrop (int argc, char **argv, Coord x, Coord y) { // int changed = 0; Coord dx, dy, pad; BoxType *box; box = GetDataBoundingBox (PCB->Data); /* handy! */ if (!box || (box->X1 == box->X2 || box->Y1 == box->Y2)) { /* board would become degenerate */ return 0; } /* * Now X1/Y1 are the distance to move the left/top edge * (actually moving all components to the left/up) such that * the exact edge of the leftmost/topmost component would touch * the edge. Reduce the move by the edge relief requirement XXX * and expand the board by the same amount. */ pad = PCB->minWid * 5; /* XXX real edge clearance */ dx = -box->X1 + pad; dy = -box->Y1 + pad; box->X2 += pad; box->Y2 += pad; /* * Round move to keep components grid-aligned, then translate the * upper coordinates into the new space. */ dx -= dx % (long) PCB->Grid; dy -= dy % (long) PCB->Grid; box->X2 += dx; box->Y2 += dy; /* * Avoid touching any data if there's nothing to do. */ if (dx == 0 && dy == 0 && PCB->MaxWidth == box->X2 && PCB->MaxHeight == box->Y2) { return 0; } /* Resize -- XXX cannot be undone */ PCB->MaxWidth = box->X2; PCB->MaxHeight = box->Y2; MoveAll (dx, dy); IncrementUndoSerialNumber (); Redraw (); SetChangedFlag (1); return 0; }
void FixBrick() { int i; for (i=0;i<4;i++) { board[Brick.pos.x+Shape[Brick.type][Brick.rotation][i].x][Brick.pos.y+Shape[Brick.type][Brick.rotation][i].y].type=BRICK; board[Brick.pos.x+Shape[Brick.type][Brick.rotation][i].x][Brick.pos.y+Shape[Brick.type][Brick.rotation][i].y].color=Brick.type; } brink=0; DisplayBrick(Brick,TRUE); printf("\a"); if(item) Bomb(); if(CheckBrick()) MoveAll(); }