int main(int ac, char **av) { WINDOW *my_wins[3]; PANEL *my_panels[3]; setlocale(LC_ALL, ""); Explorer exp((ac < 2) ? "/" : av[1]); exp.sort(); MenuLeft menu_left(&exp); MenuRight menu_right(&exp); initCurses(); initColor(); init_wins(my_wins, 3); menu_left.setup(my_wins[0]); menu_right.setup(my_wins[1]); traceExplorateur(); refresh(); setUpPanel(my_panels, my_wins); eventManager(&menu_left, &menu_right, my_wins[2], my_panels); endwin(); std::cout << exp << std::endl; return 0; }
static void * t3d_init (Display *dpy, Window window) { struct state *st = (struct state *) calloc (1, sizeof(*st)); st->dpy = dpy; st->window = window; st->dpy = dpy; st->window = window; initialize(st); initColor(st,st->r,st->g,st->b); init_3d(st); st->zeit=(struct tm *)malloc(sizeof(struct tm)); init_kugel(st); st->startx=st->scrnWidth/2; st->starty=st->scrnHeight/2; st->scrnH2=st->startx; st->scrnW2=st->starty; st->vspeed=0; vektorprodukt(st->x,st->y,st->v); viewpoint(st/*m,v*/); setink (BlackPixelOfScreen(st->xgwa.screen)); XFillRectangle (st->dpy, st->window, st->gc, 0, 0, st->scrnWidth, st->scrnHeight); XQueryPointer (st->dpy, st->window, &st->junk_win, &st->junk_win, &st->junk, &st->junk, &st->px, &st->py, &st->kb); return st; }
KeyVertex::KeyVertex(VAC * vac, QTextStream & in) : Cell(vac, in), KeyCell(vac, in), VertexCell(vac, in) { initColor(); // Position Field field; QString stringPos; in >> /*field >>*/ stringPos; // Reason of comment: see Cell::Cell(VAC * vac, QTextStream & in) // be careful, would not give // the expexcted result if // whitespace are in pos QStringList list = stringPos.split(QRegExp("\\s*[\\(\\,\\)]\\s*"), QString::SkipEmptyParts); pos_[0] = list[0].toDouble(); pos_[1] = list[1].toDouble(); // Size in >> field >> size_; // Tangent Edges in >> tangentEdges_; }
int main(int argc, char **argv) { initScreen(); //初始化屏幕 initColor(); //初始化颜色 bkgd(COLOR_PAIR(1));//给背景设定颜色 box(stdscr, 0, 0); //画边框 editWin = newwin(LINES-4, COLS-4, 3, 2); wbkgd(editWin, COLOR_PAIR(2)); wattron(editWin, COLOR_PAIR(3)); //当前使用该色彩 box(editWin, 0, 0); wattroff(editWin, COLOR_PAIR(3)); //不使用该色彩了 wattron(editWin,COLOR_PAIR(7)); initMenu(); //初始化菜单 draw_main_menu(stdscr); //画菜单 initList(); //初始化链表 while(isOn){ wnoutrefresh(stdscr); wnoutrefresh(editWin); doupdate(); drawMenuList(0, 0); touchwin(editWin); wrefresh(editWin); } exitScreen(); //退出函数 return 0; }
//-------------------------------------------------------------- void testApp::setup() { ofSetFrameRate( 60 ); ofSetVerticalSync( true ); bDebug = false; bSmoothing = false; bPause = false; bDrawPoints = false; bDrawLines = false; bDrawCurves = false; bDrawSimplified = false; bDrawColor = true; bRotateColor = true; screenRect.width = ofGetWidth(); screenRect.height = ofGetHeight(); switch ( 1 ) { case 1 : noiseRect.width = 160; noiseRect.height = 120; break; case 2 : noiseRect.width = 320; noiseRect.height = 240; break; case 3 : noiseRect.width = 640; noiseRect.height = 480; break; } debugRect.width = 160; debugRect.height = 120; float largeRectExtra; largeRectExtra = 0.04; // the extra is to cover the whole screen. set to 0 to see what happens without it. largeRect = ofxResizeUtil :: cropToSize( noiseRect, screenRect ); largeRect.x -= largeRect.width * largeRectExtra * 0.5; largeRect.y -= largeRect.height * largeRectExtra * 0.5; largeRect.width *= 1 + largeRectExtra; largeRect.height *= 1 + largeRectExtra; screenGrabUtil.setup( "movie/frame" ); screenGrabUtil.setPause( true ); tileSaver.init( 10, 0, true ); initNoise(); initOpenCv(); initContours(); initGui(); initColor(); }
// Constructors DisplayManager() { initscr(); /* Start curses mode */ curs_set(0); /* Hide cursor */ raw(); /* Line buffering disabled */ keypad(stdscr, TRUE); /* We get F1, F2 etc.. */ noecho(); /* Don't echo() while we do getch */ start_color(); /* Colors */ initColor(); /* Init color pairs */ }
KeyVertex::KeyVertex(KeyVertex * other): Cell(other), KeyCell(other), VertexCell(other) { initColor(); pos_ = other->pos_; size_ = other->size_; }
CtrlList::CtrlList() { _id = 0; _default = 0.0; _curVal = 0.0; _mode = INTERPOLATE; _dontShow = false; _selected = false; _visible = false; initColor(-1); }
CtrlList::CtrlList(int id, bool dontShow) { _id = id; _default = 0.0; _curVal = 0.0; _mode = INTERPOLATE; _dontShow = dontShow; _visible = false; _guiUpdatePending = false; initColor(id); }
CtrlList::CtrlList(int id, QString name, double min, double max, bool dontShow) { _id = id; _default = 0.0; _curVal = 0.0; _mode = INTERPOLATE; _name = name; _min = min; _max = max; _dontShow = dontShow; _selected = false; _visible = false; initColor(id); }
CtrlList::CtrlList(int id, QString name, double min, double max, CtrlValueType v, bool dontShow) { _id = id; _default = 0.0; _curVal = 0.0; _mode = INTERPOLATE; _name = name; _min = min; _max = max; _valueType = v; _dontShow = dontShow; _visible = false; _guiUpdatePending = false; initColor(id); }
int main() { hidden(hOut); initColor(); SetConsoleTitle(" 贪吃蛇 1.1"); system("mode con cols=100 lines=40"); GameOver = 0; score = 0; gotoxy(75, 4); puts("分数:0"); gotoxy(75, 6); puts("关数:1"); gotoxy(75, 8); puts("方向键 ↑↓ ← →"); gotoxy(78, 10); puts("控制蛇的前进方向"); gotoxy(75, 12); puts("按 p 键暂停或继续,"); gotoxy(78, 14); puts("按 Esc 键退出游戏"); Snake s(3); s.paintBorder(); s.addWall(2); s.reloadCandy(); s.print(); while(true) { while(kbhit()) { s.move(getch()); if(GameOver == true) break; } if(GameOver == true) { gotoxy(20, 10); setColor(WHITE); puts("GameOver"); gotoxy(0, 33); break; } s.move(); } getch(); getch(); setColor(WHITE); return 0; }
int main (void) { int n; int i; int r, g, b; Color c[N], average; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d%d%d", &r, &g, &b); initColor(&(c[i]), r, g, b); printColor(&(c[i])); } average = averageColor(c, n); printColor(&average); return 0; }
/* ** Mandala entry point. */ int main() { Sdl *sdl = initSdl(); Window *window = initWindow(); Color *color = initColor(); Mandala *mandala = initMandala(); while (checkUserInput(sdl, color, mandala) == 0) { drawBackground(sdl, color); drawMandala(sdl, color, mandala, window); SDL_RenderPresent(sdl->renderer); mandala->myTable += mandala->myStep; } freeAllTheThings(sdl, window, mandala, color); return 0; }
/* Returns an initialized control */ control* initControl(enum control_type ctrl_type, int x, int y, int width, int height) { control* ctrl = NULL; ctrl = (control*) malloc(sizeof(control)); if (ctrl != NULL) { ctrl->ctrl_type = ctrl_type; ctrl->rect = initRect(x,y,width,height); ctrl->color = initColor(255,255,255); /* default color: white */ ctrl->print = TRUE; ctrl->freeControl = &freeControl; ctrl->surface = NULL; ctrl->next = NULL; ctrl->children = NULL; } else { printf("ERROR: standard function malloc has failed\n"); } return ctrl; }
int main(int ac, char **av, char **env) { t_canard myCanard; if ((ac != 2) || (atof(av[1]) < 0) || (atof(av[1]) > 2.5) || env[0] == NULL) { printf("Usage: ./204canards [NB]\n"); printf("With [NB] > 0 AND [NB] <= 2.5\n"); return (-1); } if (strspn(av[1], ".0123456789") != strlen(av[1])) return (-1); myCanard.number = atof(av[1]); initColor(&myCanard); initSDL(&myCanard); loopSDL(&myCanard); return (0); }
KeyVertex::KeyVertex(VAC * vac, XmlStreamReader & xml) : Cell(vac, xml), KeyCell(vac, xml), VertexCell(vac, xml) { initColor(); // Position QString stringPos = xml.attributes().value("position").toString(); QStringList list = stringPos.split(","); pos_[0] = list[0].toDouble(); pos_[1] = list[1].toDouble(); // Size //in >> field >> size_; // Tangent Edges //in >> tangentEdges_; }
Interface::Interface() { if((SDL_Init(SDL_INIT_EVERYTHING) == -1)) throw errGraphic("Init"); screen = SDL_SetVideoMode(1600, 1000, 32, SDL_SWSURFACE); if (screen == NULL) throw errGraphic("Can't init the window"); SDL_WM_SetCaption("Plazza", NULL); if (TTF_Init() == -1) throw errGraphic("Can't init TTF"); initColor(); loadFile(); input = new Input(); posStatMenu = 0; posStatList = 0; posStatSize = 0; posComMenu = 0; posComList = 0; posComSize = 0; }
Color averageColor(Color c[], int n) { Color result; int i; initColor(&result, 0, 0, 0); if (n == 0) return result; for (i = 0; i < n; i++) { result.r += c[i].r; result.g += c[i].g; result.b += c[i].b; } result.r /= n; result.g /= n; result.b /= n; return result; }
//=================>>> vColorButtonCmd::vColorButtonCmd <<<===================== vColorButtonCmd::vColorButtonCmd(vCmdParent* dp, CommandObject* dc) : vButtonCmd(dp, dc) { initColor(); }
void CtrlList::read(Xml& xml) { QLocale loc = QLocale::c(); bool ok; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::Attribut: if (tag == "id") { //_id = xml.s2().toInt(); _id = loc.toInt(xml.s2(), &ok); if (!ok) { printf("CtrlList::read failed reading _id string: %s\n", xml.s2().toLatin1().constData()); initColor(0); //Set the default color if we have an error } else { initColor(_id); } } else if (tag == "cur") { //_curVal = xml.s2().toDouble(); _curVal = loc.toDouble(xml.s2(), &ok); if (!ok) printf("CtrlList::read failed reading _curVal string: %s\n", xml.s2().toLatin1().constData()); } else if(tag == "visible") { _visible = (bool)xml.s2().toInt(); } else if(tag == "color") { ;//xml.skip(tag); } else printf("unknown tag %s\n", tag.toLatin1().constData()); break; case Xml::Text: { // Changed by Tim. Users in some locales reported corrupt reading, // because of the way floating point is represented (2,3456 not 2.3456). /* QByteArray ba = tag.toLatin1(); const char* s = ba;.constData(); int frame; double val; for (;;) { char* endp; while (*s == ' ' || *s == '\n') ++s; if (*s == 0) break; frame = strtol(s, &endp, 10); s = endp; while (*s == ' ' || *s == '\n') ++s; val = strtod(s, &endp); add(frame, val); s = endp; ++s; } */ // Added by Tim. p3.3.6 //printf("CtrlList::read tag:%s\n", tag.toLatin1().constData()); int len = tag.length(); int frame; double val; int i = 0; for (;;) { while (i < len && (tag[i] == ',' || tag[i] == ' ' || tag[i] == '\n')) ++i; if (i == len) break; QString fs; while (i < len && tag[i] != ' ') { fs.append(tag[i]); ++i; } if (i == len) break; // Works OK, but only because if current locale fails it falls back on 'C' locale. // So, let's skip the fallback and force use of 'C' locale. //frame = fs.toInt(&ok); frame = loc.toInt(fs, &ok); if (!ok) { printf("CtrlList::read failed reading frame string: %s\n", fs.toLatin1().constData()); break; } while (i < len && (tag[i] == ' ' || tag[i] == '\n')) ++i; if (i == len) break; QString vs; while (i < len && tag[i] != ' ' && tag[i] != ',') { vs.append(tag[i]); ++i; } // Works OK, but only because if current locale fails it falls back on 'C' locale. // So, let's skip the fallback and force use of 'C' locale. //val = vs.toDouble(&ok); val = loc.toDouble(vs, &ok); if (!ok) { printf("CtrlList::read failed reading value string: %s\n", vs.toLatin1().constData()); break; } // Added by Tim. p3.3.6 //printf("CtrlList::read i:%d len:%d fs:%s frame %d: vs:%s val %f \n", i, len, fs.toLatin1().constData(), frame, vs.toLatin1().constData(), val); add(frame, val); if (i == len) break; } } break; case Xml::TagEnd: if (xml.s1() == "controller") { // Added by Tim. p3.3.6 //printf("CtrlList::read _id:%d _curVal:%f\n", _id, _curVal); return; } default: break; } } }
//value ImageStringTTF(value img,value fontname,value ptsize, value angle, value x, value y,value string, value align, value antiAntiAlias, value color) { value ImageStringTTF(value *args,int nargs) { enum {eImg,eFontname,ePtsize,eAngle,eX,eY,eString,eAlign,eAntiAlias,eColor,eSize}; if (nargs!=eSize) neko_error(); ImageData _img = getImage(args[eImg]); char *_fontname = val_string(args[eFontname]); double _ptsize = val_float(args[ePtsize]); double _angle = val_float(args[eAngle]); int _x = val_int(args[eX]); int _y = val_int(args[eY]); char *_string = val_string(args[eString]); int _align = val_int(args[eAlign]); int _antiAliasing = val_bool(args[eAntiAlias]); //calculation size of output int brect[8]; char *err; err = gdImageStringFT(NULL,&brect[0],0,_fontname,_ptsize,_angle,0,0,_string); if (err) val_throw(alloc_string(err)); int width = brect[2] - brect[6]; int height = brect[3] - brect[7]; switch (_align) { case 0: // LeftTop break; case 1: // CenterTop _x-=width/2; break; case 2: // RightTop _x-=width; break; case 3: // LeftMiddle _y-=height/2; break; case 4: // CenterMiddle _y-=height/2; _x-=width/2; break; case 5: // Right Middle _y-=height/2; _x-=width; break; case 6: // LeftBottom _y-=height; break; case 7: // CenterBottom _y-=height; _x-=width/2; break; case 8: // RightBottom _y-=height; _x-=width; break; default: //something went wrong val_throw(alloc_string("unknown position type")); break; } _y+=height; //drawing int _color = initColor(_img,args[eColor]); err = gdImageStringFT(imageImage(_img),&brect[0],getAntiAliasingColor(_color,_antiAliasing),_fontname,_ptsize,_angle,_x,_y,_string); if (err) val_throw(alloc_string(err)); return val_null; }
void CtrlList::read(Xml& xml) { QLocale loc = QLocale::c(); bool ok; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::Attribut: if (tag == "id") { _id = loc.toInt(xml.s2(), &ok); if (!ok) { printf("CtrlList::read failed reading _id string: %s\n", xml.s2().toLatin1().constData()); initColor(0); //Set the default color if we have an error } else { initColor(_id); } } else if (tag == "cur") { _curVal = loc.toDouble(xml.s2(), &ok); if (!ok) printf("CtrlList::read failed reading _curVal string: %s\n", xml.s2().toLatin1().constData()); } else if(tag == "visible") { _visible = (bool)xml.s2().toInt(); } else if(tag == "color") { ;//xml.skip(tag); } else printf("unknown tag %s\n", tag.toLatin1().constData()); break; case Xml::Text: { int len = tag.length(); int frame; double val; int i = 0; for (;;) { while (i < len && (tag[i] == ',' || tag[i] == ' ' || tag[i] == '\n')) ++i; if (i == len) break; QString fs; while (i < len && tag[i] != ' ') { fs.append(tag[i]); ++i; } if (i == len) break; // Works OK, but only because if current locale fails it falls back on 'C' locale. // So, let's skip the fallback and force use of 'C' locale. frame = loc.toInt(fs, &ok); if (!ok) { printf("CtrlList::read failed reading frame string: %s\n", fs.toLatin1().constData()); break; } while (i < len && (tag[i] == ' ' || tag[i] == '\n')) ++i; if (i == len) break; QString vs; while (i < len && tag[i] != ' ' && tag[i] != ',') { vs.append(tag[i]); ++i; } // Works OK, but only because if current locale fails it falls back on 'C' locale. // So, let's skip the fallback and force use of 'C' locale. //val = vs.toDouble(&ok); val = loc.toDouble(vs, &ok); if (!ok) { printf("CtrlList::read failed reading value string: %s\n", vs.toLatin1().constData()); break; } //printf("CtrlList::read i:%d len:%d fs:%s frame %d: vs:%s val %f \n", i, len, fs.toLatin1().constData(), frame, vs.toLatin1().constData(), val); add(frame, val); if (i == len) break; } } break; case Xml::TagEnd: if (xml.s1() == "controller") { return; } default: break; } } }
/* Changes the color of the control */ void changeControlColor(control* ctrl, int r, int g, int b) { ctrl->color = initColor(r,g,b); }
int main(void) { int key; int i; int iframe; Bullet *bul = new Bullet[200]; Bullet *bulEn = new Bullet[100]; Ship *ship = new Ship[50]; Ast *ast = new Ast[50]; Star *stars = new Star[100]; Player *player = new Player; key = 0; iframe = 0; srand(time(NULL)); initscr(); initColor(); keypad(stdscr, TRUE); curs_set(0); nodelay(stdscr, TRUE); while (key != 'q' && player->getLife() > 0) { usleep(19000); clear(); spawnStars(stars, iframe); spawnEnemy(ship, iframe); spawnAst(ast, iframe); displayText(player); displayEdge(); displayStars(stars); displayEnemy(ship, player); displayAst(ast, player); displayBullet(bul, ship, ast, player); displayEnemyBullet(bulEn, ship, player); mvaddch(player->getX(), player->getY(), '>'|COLOR_PAIR(4)); key = getch(); refresh(); if (key == 258 && player->getX() < 30) player->setX(player->getX() + 1); else if (key == 259 && player->getX() > 4) player->setX(player->getX() - 1); else if (key == 260 && player->getY() > 4) player->setY(player->getY() - 1); else if (key == 261 && player->getY() < 52) player->setY(player->getY() + 1); else if (key == 32) { i = 0; while (bul[i].getY() < 100 && i < 200) i++; bul[i].setX(player->getX()); bul[i].setY(player->getY() + 1); } iframe++; if (iframe == 100) iframe = 0; } clear(); refresh(); endwin(); }
int main(int argc, char** argv) { int method = 0; double start, finish; srand((unsigned int)time(NULL)); fopen_s(&result, "mapColoring.txt", "w"); if(result == NULL) printf("ERROR: File Open Failed"); // Create Map Information printf("Start Map Generating..\n"); createPoint(); printf("Start Line Generating..\n"); createEdge(); if(boolAllEdge) createAllEdge(); // Plus Edge incremently.. if(boolLog) { int a = 0; for(int i=0; i<POINT_COUNT; i++) a += mapPoints[i].edgeCount; printf("\n Created Edges Count:%d \n", a/2); } // Save the Result if(boolSave) saveFile(); initColor(); // Select Color using each strategy for(method = 0; method < 3; method++) { // method 0~2 kColor = 3; printf("\nStart map Coloring using %s\n", method == 0? "Backtracking" : method == 1? "Backtracking using Foward check" : "Backtracking using Arc Consistency"); if(boolSave) fprintf(result, "\nStart map Coloring using %s\n", method == 0? "Backtracking" : method == 1? "Backtracking using Foward check" : "Backtracking using Arc Consistency"); // time check start = clock(); initColor(); if(!backtrackingSearch(method)) { printf("ERROR: It can't make %d-Coloring Map!!\n", kColor); if(boolSave) fprintf(result, "ERROR: It can't make %d-Coloring Map!!\n", kColor); kColor = 4; if(boolLog) printf("\nStart %d-Colorings Search\n", kColor); if(boolSave) fprintf(result, "\nStart %d-Colorings Search\n", kColor); initColor(); backtrackingSearch(method); // mapColoring using k = 4 } printf("Map Coloring using %s is finished!!\n", method == 0? "Backtracking" : method == 1? "Backtracking using Foward check" : "Backtracking using Arc Consistency"); if(boolSave) fprintf(result, "Map Coloring using %s is finished!!\n", method == 0? "Backtracking" : method == 1? "Backtracking using Foward check" : "Backtracking using Arc Consistency"); // end time finish = clock(); printf("time : %.3fs\n", ((finish-start)/CLOCKS_PER_SEC)); if(boolSave) fprintf(result, "%s time : %.3fs\n" , method == 0? "Backtracking" : method == 1? "Backtracking using Foward check" : "Backtracking using Arc Consistency" , ((finish-start)/CLOCKS_PER_SEC)); //printf("time : %f, %f, %.3f\n", start, finish, difftime(finish, start)); } fclose(result); if(boolShowWindow) { glutInit(&argc, argv); mapDisplay(); } return 0; }
void initGameSystem(void) { int i, numInitFuns; void (*initFuncs[]) (void) = { initFonts, initInput, initResources, initSounds, initWidgets, initGame, loadFighterDefs, loadCapitalShipDefs, loadItemDefs, initBulletDefs, initStarSystems, initChallenges, initStats, initModalDialog, initBackground, initStars, initControls, initTrophies }; numInitFuns = sizeof(initFuncs) / sizeof(void*); initColor(&colors.red, 255, 0, 0); initColor(&colors.orange, 255, 128, 0); initColor(&colors.yellow, 255, 255, 0); initColor(&colors.green, 0, 255, 0); initColor(&colors.blue, 0, 0, 255); initColor(&colors.cyan, 0, 255, 255); initColor(&colors.purple, 255, 0, 255); initColor(&colors.white, 255, 255, 255); initColor(&colors.black, 0, 0, 0); initColor(&colors.lightGrey, 192, 192, 192); initColor(&colors.darkGrey, 128, 128, 128); for (i = 0 ; i < numInitFuns ; i++) { showLoadingStep(i + 1, numInitFuns); initFuncs[i](); } }