int main(int argc, char * argv[]) { if (argc != 3) { COneStepCheckers checkers("input.txt"); checkers.WriteStepResultInFile("output.txt"); } else { COneStepCheckers checkers(argv[1]); checkers.WriteStepResultInFile(argv[2]); } return 0; }
int main(){ /* Read from stdin */ int h,w; scanf("%d %d\n", &h, &w); char board[h][w+1]; // +1 for null terminator /* Get the board */ int bufferSize = 256; char buffer[bufferSize]; int i; for (i = 0; i < h; i++){ fgets(buffer, bufferSize, stdin); strncpy(board[i], buffer, sizeof(char)*w); // Copy part of the buffer onto the board board[i][w] = '\0'; } /* Perform breadth first search, keeping track of visited squares along the way. */ int tail = 0; int stack[h*w]; int done[h][w]; int j; for (i = 0; i < h; i++){ for (j = 0; j < w; j++){ done[i][j] = 1; stack[tail] = i*j; tail++; int dir = checkers(w, h, board, stack, tail); while (tail){ if (!dir){ tail--; continue; } switch (dir){ case 1: if (!chilies(w, h, done, stack, tail)){ } } } } } for (i = 0; i < h; i++){ printf("%s\n", board[i]); } return 0; }
ShadowTest::ShadowTest() { Texture::textureManager.emplace("test.png"); Texture::textureManager.emplace("bricks.jpg"); Texture::textureManager.emplace("bricks_normal.jpg"); Material checkers(Texture::textureManager.getPointer("test.png")); Material bricks(Texture::textureManager.getPointer("bricks.jpg"), Texture::textureManager.getPointer("bricks_normal.jpg"), nullptr, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), 0, 0); Model modelPlane; modelPlane.makePlane(ROOM_WIDTH, ROOM_WIDTH, 1); modelPlane.finalize(); Mesh::meshManager.emplace("plane", modelPlane); Model modelPlane2; modelPlane2.makePlane(ROOM_WIDTH, ROOM_HEIGHT, 1); modelPlane2.finalize(); Mesh::meshManager.emplace("planeSmall", modelPlane2); Mesh::meshManager.emplace("cube.obj"); Mesh::meshManager.emplace("monkey3.obj"); Entity* camera = new Entity(); BaseCameraComponent* cameraComponent = new FPCameraComponent(70, 1.0); camera->addComponent(cameraComponent); camera->getLocalTransform().translate(glm::vec3(0.0f, ROOM_HEIGHT / 8.0f, ROOM_WIDTH / 4.0f)); m_gameWorld.rootEntity.addChildEntity(camera); m_gameWorld.currentCamera = cameraComponent; Entity* floor = new Entity(); floor->addComponent(new RenderComponent(Mesh::meshManager.getPointer("plane"), checkers)); m_gameWorld.rootEntity.addChildEntity(floor); Entity* light = new Entity(); light->addComponent(new DirectionalLightComponent(glm::vec3(1.0, 1.0, 1.0), 0.8f)); light->getLocalTransform().setRotation(glm::radians(-45.0f), glm::vec3(1.0, 0.0, 0.0)); m_gameWorld.rootEntity.addChildEntity(light); addObject(m_gameWorld.rootEntity, "cube.obj", bricks, glm::vec3(ROOM_WIDTH / 8.0f, 1.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f)); addObject(m_gameWorld.rootEntity, "cube.obj", checkers, glm::vec3(ROOM_WIDTH / 8.0f, 1.25f, 0.0f), glm::vec3(0.1f, 0.1f, 0.1f), true); addObject(m_gameWorld.rootEntity, "monkey3.obj", bricks, glm::vec3(-ROOM_WIDTH / 8.0f, 1.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f)); m_gameWorld.ambientLight = glm::vec3(0.05, 0.05, 0.05); }
void KisNodeDelegate::drawThumbnail(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const { KisNodeViewColorScheme scm; const int thumbSize = scm.thumbnailSize(); const qreal oldOpacity = p->opacity(); // remember previous opacity QImage img = index.data(int(KisNodeModel::BeginThumbnailRole) + thumbSize).value<QImage>(); if (!(option.state & QStyle::State_Enabled)) { p->setOpacity(0.35); } QRect fitRect = scm.relThumbnailRect().translated(option.rect.topLeft()); QPoint offset; offset.setX((fitRect.width() - img.width()) / 2); offset.setY((fitRect.height() - img.height()) / 2); offset += fitRect.topLeft(); KisConfig cfg; // paint in a checkerboard pattern behind the layer contents to represent transparent const int step = scm.thumbnailSize() / 6; QImage checkers(2 * step, 2 * step, QImage::Format_ARGB32); QPainter gc(&checkers); gc.fillRect(QRect(0, 0, step, step), cfg.checkersColor1()); gc.fillRect(QRect(step, 0, step, step), cfg.checkersColor2()); gc.fillRect(QRect(step, step, step, step), cfg.checkersColor1()); gc.fillRect(QRect(0, step, step, step), cfg.checkersColor2()); QBrush brush(checkers); p->setBrushOrigin(offset); p->fillRect(img.rect().translated(offset), brush); p->drawImage(offset, img); p->setOpacity(oldOpacity); // restore old opacity QRect borderRect = kisGrowRect(img.rect(), 1).translated(offset); KritaUtils::renderExactRect(p, borderRect, scm.gridColor(option, d->view)); }