int expose_hook(void *data) { t_coord p; t_data *d; t_map *m; p = set_coord(-1, -1); d = (t_data*)data; m = &(d->map); clear_img(&(d->img)); while (++p.y < m->hgt) { p.x = -1; while (++p.x < m->wth) { if (m->dot[p.y][p.x].y) { if (p.y && m->dot[p.y - 1][p.x].y) iso_projection(d, p, set_coord(1, -1), set_coord(0, -1)); if (p.x && m->dot[p.y][p.x - 1].y) iso_projection(d, p, set_coord(-1, -1), set_coord(-1, 0)); } } } mlx_clear_window(d->mlx, d->win); mlx_put_image_to_window(d->mlx, d->win, d->img.i, 0, 0); return (1); }
void summit_swap(summit *UnSommetA, summit *UnSommetB) { summit TmpSommet; TmpSommet.coord = set_coord(UnSommetA->coord.i_x, UnSommetA->coord.i_y); UnSommetA->coord = set_coord(UnSommetB->coord.i_x, UnSommetB->coord.i_y); UnSommetB->coord = set_coord(TmpSommet.coord.i_x, TmpSommet.coord.i_y); }
int check_direction( int dir ) { int pos, tile; if( !dir ) { msg("You have to specify a direction when building a mine (i.e. 'build mine to the north')."); return -1; } set_direction(SINVERT_C(dir)); // Multiply up. dir = SMAKE_C(SCX(dir)*5, SCY(dir)*3, 0); pos = OFFSET_C(this_player()->query_coord(), dir); // Snap to grid pos = MAKE_C(((CX(pos)-1) / 5) * 5 + 1, ((CY(pos)-1) / 3) * 3 + 1, 0); // Now check to see if the tiletype is valid. Query the center of the tile // to make life a bit easier. tile = environment(this_player())->get_tiletype(CX(pos)+2, CY(pos)+1); if( !tile ) { msg("You can't build off the edge of the map."); return -1; } tile -= '0'; // get_tiletype uses the zbuffer, which offsets by '0' ... if( tile != LAYER_MOUNTAIN ) { //debug("tile=="+as_string(tile)+", pos = "+MAKE_CSTR(pos)); msg( "Mines must be built against a mountain face. Find a mountainous place." ); return -1; } // Offset horizontally a bit to make the entrance stick out... if( SCX(dir) ) pos = OFFSET_C(pos, SMAKE_C(-SCX(dir) / 5,0,0)); // If facing south, adjust to find the entrance. // The mountain tiles have funny patterns, and this helps // to compensate. if( query_direction() == SMAKE_C(0,1,0) ) { pos = MAKE_C(CX(pos), CY(pos)-1, CZ(pos) ); while( environment(this_player())->get_tiletype(CX(pos)+2, CY(pos)+3) == '0' + LAYER_MOUNTAIN ) { pos = MAKE_C(CX(pos),CY(pos)+1,CZ(pos)); } } // This is a north-facing version to snug the mine up as close as it can go. if( query_direction() == SMAKE_C(0,-1,0) ) { pos = MAKE_C(CX(pos), CY(pos)-1, CZ(pos) ); while( environment(this_player())->get_tiletype(CX(pos)+2, CY(pos)) != '0' + LAYER_MOUNTAIN ) { pos = MAKE_C(CX(pos),CY(pos)+1,CZ(pos)); } } set_coord( pos ); return 0; }
static void iso_projection(t_data *d, t_coord p, t_coord c, t_coord n) { t_map *m; t_coord par; t_coord a; t_coord b; t_coord alt; m = &(d->map); alt.x = m->dot[p.y][p.x].x * m->altz * m->dist / 20; alt.y = m->dot[p.y + n.y][p.x + n.x].x * m->altz * m->dist / 20; par.x = (WIN_W / 2 * d->proj) + m->dch - (m->wth * m->dist / 2); par.y = (WIN_H / 2) - alt.x + m->dcv - (m->hgt * m->dist / 2); a = set_coord((((p.x - p.y) * m->dist * d->proj) + par.x) / d->proj , ((p.x + p.y) * m->dist * d->proj / 2) + par.y); par.y = (WIN_H / 2) - alt.y + m->dcv - (m->hgt * m->dist / 2); b = set_coord((((p.x + c.x - p.y) * m->dist * d->proj) + par.x) / d->proj , ((p.x + c.y + p.y) * m->dist * d->proj / 2) + par.y); draw_line(d, a, b, set_vect(p, n)); }
void mininode_coord_animation::update_dirty() { set_coord(curve.interpolate_cubic(get_time())); mininode_coord::update_dirty(); }
mininode_coord::mininode_coord(const minicoord &c) : mininode_affine() {set_coord(c);}
void Cappdata::create_cards_layout() { Ccard *pc; t_fcoord pos, dim; t_coord wsize; Cgfxarea area(pos, dim, wsize, (char*)"empty"); string title; string text; string basedir; string cardimg; string cardcontour; TTF_Font *title_font; TTF_Font *font; SDL_Surface *contour; SDL_Surface *transparent_surface; Uint32 *pixels; int i; float xposoffset; float xpos; bool bhelper; pos.z = dim.z = 0; wsize.z = 0; // xposoffset = 7.; wsize.x = m_width; wsize.y = m_height; m_cardlayout = new CCardList(); // basedir = string(IMGPATH); // % of size dim.x = 4.4; dim.y = 6.2; //------------------------------------------------------------------- // Top //------------------------------------------------------------------- // Recording float hypos = 0.4; set_coord(&pos, 3., hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_RECORD); title = "Recording"; cardimg = basedir + string("cardrecord.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string("Records the input source")); pc->add_info_line(string("selected in the config")); pc->add_info_line(string("dialog.")); pc->add_info_line(string("(key: space bar)")); //pc->activate_card(true); m_cardlayout->add(pc); // Dialog: Save/Open the work and track set_coord(&pos, 10., hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_OPENSAVE); title = "Open/Save dialog"; cardimg = basedir + string("cardopensave.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("Action")); pc->add_info_line(string("Opens a dialog allowing to")); pc->add_info_line(string("open or to save the work.")); m_cardlayout->add(pc); // Changes the spectrometer display xpos = 73.; set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_LOGVIEW); title = "Spectrogram change"; cardimg = basedir + string("cardlogsp.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string("When activated, the")); pc->add_info_line(string("spectrogram is in decibels")); pc->add_info_line(string("instead of enhanced")); pc->add_info_line(string("details mode.")); m_cardlayout->add(pc); xpos += xposoffset; // Disable the help system set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_HELPERS); title = "Infos"; cardimg = basedir + string("cardhelp.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string(" ")); pc->add_info_line(string("Displays helper cards ")); pc->add_info_line(string("on the interface.")); m_cardlayout->add(pc); xpos += xposoffset; // Disable the help system set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_CONFIG); title = "Configuration"; cardimg = basedir + string("cardconfig.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("Action")); pc->add_info_line(string("Starts the config dialog")); pc->add_info_line(string(" ")); pc->add_info_line(string("- general configuration")); pc->add_info_line(string("- input selection")); m_cardlayout->add(pc); xpos += xposoffset; //------------------------------------------------------------------- // Bottom left //------------------------------------------------------------------- hypos = 93; xpos = 3.; // Dialog: Add an instrument set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_ADDINSTR); title = "Add an instrument"; cardimg = basedir + string("cardaddinstr.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("Action")); pc->add_info_line(string(" ")); pc->add_info_line(string("Add an instrument to")); pc->add_info_line(string("the composition.")); m_cardlayout->add(pc); xpos += xposoffset; /* // Stop on notes during practice set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_NOTEBLOCK); title = "Note barriers"; cardimg = basedir + string("notebloc.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, m_sdlRenderer); pc->add_info_line(string("State")); pc->add_info_line(string("When parcticing, the correct")); pc->add_info_line(string("notes must be played in")); pc->add_info_line(string("order to continue to the")); pc->add_info_line(string("next note.")); m_cardlayout->add(pc); xpos += xposoffset; */ // Practice session set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_PRACTICE); title = "Practice"; cardimg = basedir + string("cardpractice.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("Action")); pc->add_info_line(string(" ")); pc->add_info_line(string("Starts / Stops a practice")); pc->add_info_line(string("session.")); m_cardlayout->add(pc); xpos += xposoffset; // Open a view of the notes on the instrument set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_PLACEMENT); title = "Finger Placement"; cardimg = basedir + string("cardpracticew.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("Action")); pc->add_info_line(string(" ")); pc->add_info_line(string("Opens a window showing")); pc->add_info_line(string("where to play the notes")); pc->add_info_line(string("on the real instrument.")); m_cardlayout->add(pc); xpos += xposoffset; // Practice session set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_PRACSPEED); title = "Slow down"; cardimg = basedir + string("cardpracticespeed.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string(" ")); pc->add_info_line(string("Halfs practice speed.")); m_cardlayout->add(pc); xpos += xposoffset; // set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_AUTOBEAM); title = "Auto beam"; cardimg = basedir + string("cardautobeam.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string(" ")); pc->add_info_line(string("The notes between bars")); pc->add_info_line(string("are automaticly")); pc->add_info_line(string("connected and")); pc->add_info_line(string("the rests are displayed.")); if (m_card_states.autobeam) pc->activate_card(true); m_cardlayout->add(pc); xpos += xposoffset; // set_coord(&pos, xpos, hypos); area = Cgfxarea(pos, dim, wsize, (char*)CARD_CHORDFUSE); title = "Chord creation"; cardimg = basedir + string("cardchordfuse.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives); pc->add_info_line(string("State")); pc->add_info_line(string(" ")); pc->add_info_line(string("Overlaping notes can be")); pc->add_info_line(string("fused into chords.")); if (m_card_states.chordfuse) pc->activate_card(true); m_cardlayout->add(pc); xpos += xposoffset; //------------------------------------------------------------------- // Hidden help cards //------------------------------------------------------------------- bhelper = true; // Spectrometer set_coord(&pos, 20, 60 - dim.y / 2); area = Cgfxarea(pos, dim, wsize, (char*)"spectre"); title = "Spectrometer"; cardimg = basedir + string("cardspectre.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, bhelper); pc->add_info_line(string("Helper")); pc->add_info_line(string("- select: play a zone")); pc->add_info_line(string("- R click: add a note")); pc->add_info_line(string("- R click + w: play a note")); pc->add_info_line(string("- e + L click: add a bar")); pc->add_info_line(string("- wheel: fequency zoom")); m_cardlayout->add(pc); // Score set_coord(&pos, 15 + dim.x / 2, 95 - dim.y / 2); area = Cgfxarea(pos, dim, wsize, (char*)"score"); title = "Score"; cardimg = basedir + string("cardscore.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, bhelper); pc->add_info_line(string("Helper")); pc->add_info_line(string("- select: practice area")); pc->add_info_line(string(" play the notes")); //pc->add_info_line(string("s + select: play the track without the notes")); pc->add_info_line(string("- wheel: zoom")); pc->add_info_line(string("- s + wheel: string selection")); pc->add_info_line(string("- d + select: delete ")); m_cardlayout->add(pc); // Time bar set_coord(&pos, 50 - dim.x / 2, 75 - dim.y / 2); area = Cgfxarea(pos, dim, wsize, (char*)"timescale"); title = "Time scale"; cardimg = basedir + string("cardtscale.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, bhelper); pc->add_info_line(string("Helper")); pc->add_info_line(string("- Mouse wheel: time zoom,")); pc->add_info_line(string(" changes the view time")); pc->add_info_line(string("- Right click: grab")); pc->add_info_line(string("(The blue peaks are the")); pc->add_info_line(string(" note attacks)")); m_cardlayout->add(pc); // Freq bar set_coord(&pos, 70 - dim.x, 60 - dim.y / 2); area = Cgfxarea(pos, dim, wsize, (char*)"freqscale"); title = "Frequency scale"; cardimg = basedir + string("cardfscale.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, bhelper); pc->add_info_line(string("Helper")); pc->add_info_line(string("- Right click: change from")); pc->add_info_line(string(" frequency scale to piano")); pc->add_info_line(string(" keys")); pc->add_info_line(string("- Mouse wheel: frequency")); pc->add_info_line(string(" zoom")); m_cardlayout->add(pc); // Track visualisation set_coord(&pos, 50, 50 /*- dim.y / 2*/); area = Cgfxarea(pos, dim, wsize, (char*)"track"); title = "Track view"; cardimg = basedir + string("cardtrack.png"); pc = new Ccard(area, title, cardimg, m_gfxprimitives, bhelper); pc->add_info_line(string("Helper")); pc->add_info_line(string("- Right click: select the")); pc->add_info_line(string(" timecode.")); pc->add_info_line(string("- Mouse wheel: time zoom")); pc->add_info_line(string("- Left click: listen")); m_cardlayout->add(pc); //------------------------------------------------------------------- // Draw all the cards in a texture //------------------------------------------------------------------- title_font = TTF_OpenFont(DATAPATH BIGFONT, 36); font = TTF_OpenFont(DATAPATH BIGFONT, 32); cardcontour = basedir + string("contour.png"); try { contour = IMG_Load(cardcontour.c_str()); if (contour == NULL) throw 1; } catch (int err) { printf("User interface Error: could not load the images from \"%s\".\n", cardcontour.c_str()); exit(1); } transparent_surface = SDL_ConvertSurfaceFormat(contour, SDL_PIXELFORMAT_ARGB8888, 0); SDL_FreeSurface(contour); pixels = (Uint32*)transparent_surface->pixels; for (i = 0; i < transparent_surface->w * transparent_surface->h; i++) { if (pixels[i] == 0xFF30FF00) pixels[i] = pixels[i] & 0x00FFFFFF; } pc = m_cardlayout->get_first(); while (pc != NULL) { pc->create_texture(title_font, font, transparent_surface); pc = m_cardlayout->get_next(); } SDL_FreeSurface(transparent_surface); TTF_CloseFont(font); TTF_CloseFont(title_font); }
p_matrix = malloc(sizeof(matrix)); p_graph = malloc(sizeof(graph)); init_all(p_graph, p_matrix, EsiPtr); //Initialisation du curseur sprite UnCurseur; unsigned char sprite[12] = { 0x40,0x60,0x70,0x78,0x7C,0x7E,0x7F,0x7C, 0x4C,0x0E,0x06,0x06 }; UnCurseur.i_size = sizeof(sprite); UnCurseur.sz_bitmap = malloc(UnCurseur.i_size * sizeof(UnCurseur.sz_bitmap)); memcpy(UnCurseur.sz_bitmap, sprite, UnCurseur.i_size); UnCurseur.coord = set_coord(LCD_WIDTH/2, LCD_HEIGHT/2); sprite_draw(UnCurseur); //initialisation du clavier SetClavier(v_key); INT_HANDLER interrupt1 = GetIntVec(AUTO_INT_1); // save auto-interrupt 1 (bottom text) //********************** END OF INIT **********************// graph_draw(p_graph); ST_helpMsg("mtograph V2-2007/2008-Olivier DREVET"); ngetchx(); do{ i_menu_choice = menu_display(); //Afficher le menu switch(i_menu_choice){
CCAPTURE::CCAPTURE(int capture_nr, int x, int y, int w, int h) { fd = -1; fd = captureopen (capture_nr); set_coord (x,y, w,h); }