static void draw_clear(hwloc_topology_t topology, hwloc_obj_t level) { hwloc_obj_t child; free(level->userdata); level->userdata = NULL; for(child = level->first_child; child; child = child->next_sibling) draw_clear(topology, child); for(child = level->io_first_child; child; child = child->next_sibling) draw_clear(topology, child); for(child = level->misc_first_child; child; child = child->next_sibling) draw_clear(topology, child); }
PROCESS_THREAD(oled_temp_process, ev, data) { static struct etimer sensors_timer; PROCESS_BEGIN(); draw_init(); draw_clear(); onewire_init(); etimer_set(&sensors_timer, READ_INTERVAL); timer_callback(); while(1) { PROCESS_YIELD(); if(etimer_expired(&sensors_timer)) { timer_callback(); etimer_set(&sensors_timer, READ_INTERVAL); } } PROCESS_END(); }
int main(){ Color black = make_color(0, 0, 0); MMC mmc, *mp; IMG img, *ip; while(1){ mmc = mopen(), mp = &mmc; mseek(mp, PROGRAM_SIZE, SEEK_CUR); img = iopen(mp), ip = &img; draw_clear(&black); draw_img(ip); while(1){ if(check_switch(SWITCH1, ON)){ if(seek_next_img(ip)){ mclose(mp); break; } draw_img(ip); } } } }
//画地图 void draw_map(CMAP map) { //地图 draw_clear(false); for(int i=0;i<=gConfig.map_side_num;i++) { draw_line(DRAW_MAP_MARGIN_X, DRAW_MAP_CELL_Y(i), DRAW_MAP_MARGIN_X+DRAW_MAP_WIDTH, DRAW_MAP_CELL_Y(i)); draw_line(DRAW_MAP_CELL_X(i), DRAW_MAP_MARGIN_Y, DRAW_MAP_CELL_X(i), DRAW_MAP_MARGIN_Y+DRAW_MAP_HEIGHT); } //垃圾 HGDIOBJ hBrushOld = SelectObject(gDrawBmpMemDC, GetStockObject(GRAY_BRUSH));//灰刷 HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, GetStockObject(NULL_PEN));//空笔 for(int x=0;x<gConfig.map_side_num;x++) { for(int y=0;y<gConfig.map_side_num;y++) { if(map_cell(map, x, y) == MAP_CELL_TRUSH)//有垃圾 { for(int i=0;i<=gConfig.map_side_num;i++) { draw_map_trush(x, y); } } } } SelectObject(gDrawBmpMemDC, hPenOld); SelectObject(gDrawBmpMemDC, hBrushOld); }
void TestCom(WM_MESSAGE * pMsg,ETestMode etest_mode_in) { int lenth; char buf[10]; etest_mode = etest_mode_in; if(etest_mode == TEST_MODE_COM) { _ListBox[1]="C"; }else if(etest_mode == TEST_MODE_T) { _ListBox[1]="T"; }else{ _ListBox[1]="S"; } if(ttpars.dir == 2) { _ListBox[2] = "D"; }else{ _ListBox[2] = "R"; } if((get_data.e_work_state != START_TEST)&&(get_data.e_work_state != GET_V1)) { lenth = LISTVIEW_GetNumRows(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T)); if(lenth < TEST_TIMES) { record.test_times++; sprintf(buf,"%d",lenth+1); _ListBox[0]= buf; LISTVIEW_InsertRow(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T),0,_ListBox); if(ttpars.dir !=2) { BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TRT),"正转中"); ttpars.dir = 1; }else { BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TRT),"反转中"); } motor_dir(ttpars.dir); BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TSTOP),"运行中"); start_test_init(); if(!disp_mult) { draw_clear(&tdraw); } tdraw.draw_color = _aColor[record.test_times%5]; tdraw.data_size = 0; } all_button(0,GUI_ID_BUTTON_TMAIN); botton_able(1,GUI_ID_BUTTON_TSTOP); } }
///////////////////////////////////////////// //绘制实验统计数据列表 void draw_stat_list(PHISTORY history, int &page) { RECT rect = gDrawClientRect; rect.left += DRAW_STAT_LIST_MARGIN; rect.top += DRAW_STAT_LIST_MARGIN; rect.right -= DRAW_STAT_LIST_MARGIN; rect.bottom -= DRAW_STAT_LIST_MARGIN; char v1[MAX_LOADSTRING], v2[MAX_LOADSTRING], v3[MAX_LOADSTRING], v4[MAX_LOADSTRING], v5[MAX_LOADSTRING], v6[MAX_LOADSTRING]; int column = (rect.right - rect.left) / 6; draw_clear(false); HPEN hPenRed = CreatePen(PS_SOLID, 0, RGB(128,0,0)); //深红线 HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, hPenRed); draw_test_table(10, rect, column, "世代", "子代", "代比", "姓氏", "名字", "平均分"); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; int start, end; int pages = draw_calc_page(history->count, DRAW_STAT_LIST_ROWS, page, start, end); gTableListPosTop = rect.top; //记录开始位置 PHISTORYITEM p = history->head; int i = 0; while(p != NULL) { if(i >= start && i < end) { ROBOT &robot = p->top[0]; sprintf_s(v1, sizeof(v1), "%d", p->round); sprintf_s(v2, sizeof(v2), "%d", robot.generation); sprintf_s(v3, sizeof(v3), "%.2f", (float)p->round / robot.generation); sprintf_s(v4, sizeof(v4), "X%ld", robot.father_id); sprintf_s(v5, sizeof(v5), "M%ld", robot.id); sprintf_s(v6, sizeof(v6), "%.2f", (float)robot.score / gConfig.lab_more_count); draw_test_table(10, rect, column, v1, v2, v3, v4, v5, v6); } i++; p = p->next; } gTableListPosBottom = rect.top; //记录结束位置 rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); sprintf_s(v1, sizeof(v1), "%d/%d", page, pages); TextOut(gDrawBmpMemDC, rect.left, rect.top + DRAW_PAGE_NO_Y, v1, (int)strlen(v1)); SelectObject(gDrawBmpMemDC, hPenOld); DeleteObject(hPenRed); draw_refresh(); }
static void draw_instagram(char **id, char **link) { draw_clear(); draw_photo(&*id); draw_username(); draw_likes(); draw_video(); draw_link(&*link); draw_update(); }
int closer(void *userdata) { t_context *c; ft_putendl("exit requested, i'l make some cleans before..."); c = userdata; draw_clear(c->x); if (c->colormap) free(c->colormap); ft_putendl("clean ok, bye."); exit(0); }
int huddraw_tunnel() { if (!(hud_inv & HUDINVMASK_TUNNEL)) return 0; bg_color = B1(COLOR_NETHER_RED); draw_clear(); fg_color = B3(COLOR_GOLD_YELLOW); int32_t x = (int32_t)floor(gs.own.x); int32_t y = (int32_t)floor(gs.own.y); int32_t z = (int32_t)floor(gs.own.z); extent_t ex = { { x-80, y-2, z-80 }, { x+80, y+2, z+80 } }; cuboid_t cb = export_cuboid_extent(ex); int r,c,i,j; int32_t off = cb.boff + 16*cb.sa.x + 16; for(r=0; r<128; r++) { for(c=0; c<128; c++) { int poff = off+r*cb.sa.x+c; int s1=0,s2=0; for(i=-8; i<8; i++) { for(j=0; j<5; j++) { s1+= (cb.data[j][poff-1+i*cb.sa.x].bid != 0) -2*(cb.data[j][poff+0+i*cb.sa.x].bid != 0) + (cb.data[j][poff+1+i*cb.sa.x].bid != 0); s2+= (cb.data[j][poff+i -cb.sa.x].bid != 0) -2*(cb.data[j][poff+i ].bid != 0) + (cb.data[j][poff+i +cb.sa.x].bid != 0); } } int s = MAX(s1,s2); if (s>10) hud_image[r*128+c] = B3(COLOR_RED); if (s>30) hud_image[r*128+c] = B3(COLOR_ORANGE); if (s>60) hud_image[r*128+c] = B3(COLOR_YELLOW); if (s>80) hud_image[r*128+c] = B3(COLOR_WHITE); } } for(i=0; i<256; i++) lh_free(cb.data[i]); hud_image[64*128+64] = B3(COLOR_DIAMOND_BLUE); char text[256]; sprintf(text, "%d,%d", x, z); draw_text(2, 2, text); sprintf(text, "Y:%d", y); draw_text(2, 10, text); bg_color = COLOR_TRANSPARENT; huddraw_compass(111, 16, B3(COLOR_GOLD_YELLOW), B3(COLOR_WHITE)); return 1; }
int huddraw_map() { int shading[16] = { 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 }; if (!(hud_inv & HUDINVMASK_TUNNEL)) return 0; bg_color = B0(COLOR_BLACK); draw_clear(); int32_t x = (int32_t)floor(gs.own.x); int32_t y = (int32_t)floor(gs.own.y); int32_t z = (int32_t)floor(gs.own.z); extent_t ex = { { x-80, y-12, z-80 }, { x+80, y+3, z+80 } }; cuboid_t cb = export_cuboid_extent(ex); int r,c,i,j; int32_t off = cb.boff + 16*cb.sa.x + 16; for(r=0; r<128; r++) { for(c=0; c<128; c++) { int poff = off+r*cb.sa.x+c; for(j=0; j<16; j++) { if ( cb.data[j][poff].bid ) { int8_t color = BLOCK_COLORMAP[cb.data[j][poff].bid][cb.data[j][poff].meta]; hud_image[r*128+c] = color*4 + shading[j]; } } } } for(i=0; i<256; i++) lh_free(cb.data[i]); hud_image[64*128+64] = 126; char text[256]; bg_color = B3(COLOR_WHITE); fg_color = B3(COLOR_REDSTONE_RED); sprintf(text, "%d,%d", x, z); draw_text(2, 2, text); sprintf(text, "Y:%d", y); draw_text(2, 9, text); bg_color = COLOR_TRANSPARENT; huddraw_compass(111, 16, B3(COLOR_GOLD_YELLOW), B3(COLOR_WHITE)); return 1; }
void draw_init(t_draw *draw) { float c[4]; bzero(c,4); cconv(c,draw->background_color); // clear if(draw->with_clear) { draw_clear(c[0],c[1],c[2],0); } // set depth if(draw->with_depth) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); // polygon offset if(draw->with_polygon_offset) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0,1.0); } else { glDisable(GL_POLYGON_OFFSET_FILL); } if(draw->with_blend) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else { glDisable(GL_BLEND); } t_context *C = ctx_get(); C->event->ui.use_line_global_width = 1; skt_update( C); }
//绘制文本 void draw_text(const char* fmt, ...) { draw_clear(false); va_list args; va_start(args, fmt); char buf[MAX_LOADSTRING]; vsprintf_s(buf, fmt, args); va_end(args); RECT rect = gDrawClientRect; DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); //TextOut(hdc, 0, r, buf, strlen(buf)); //DEBUG(buf); draw_refresh(); }
static void blue_screen_fb(const char* message) { draw_begin (); draw_clear (CONS_BLUE); draw_text ("K -- FATAL ERROR", GRAPHIC_WIDTH / 2 - 8 * 8, 60, CONS_BLUE, CONS_WHITE); draw_text (message, GRAPHIC_WIDTH / 2 - (strlen (message) / 2) * 8, 90, CONS_WHITE, CONS_BLUE); draw_text ("If this problem repeats,", GRAPHIC_WIDTH / 2 - 12 * 8, 120, CONS_WHITE, CONS_BLUE); draw_text ("Please contact [email protected]", GRAPHIC_WIDTH / 2 - 15 * 8, 130, CONS_WHITE, CONS_BLUE); draw_end (); while (1) continue; }
bool or_bg::render (win *_win, int32_t off_x, int32_t off_y) { if (! this->_img) { draw_clear (0); return true; } if (off_x > this->_img->w) off_x %= this->_img->w; if (off_y > this->_img->h) off_y %= this->_img->h; auto w = _win->w; if ((off_x + w) > this->_img->w) w = this->_img->w - off_x; auto h = _win->h; if ((off_y + h) > this->_img->h) h = this->_img->h - off_y; draw_put_rect ((uint32_t *)this->_img->_b, true, 0, 0, w, h); // FIXME //_win->blit2 (0, 0, off_x, off_y, w, h, this->_img); /* if (w < _win->w) w2 = _win->w - w; if (h < _win->h) h2 = _win->h - h; if (w2 || h2) { if (w2) _win->blit2 (w, 0, 0, off_y, w2, h, this->_img); if (h2) _win->blit2 (0, h, off_x, 0, w, h2, this->_img); if (w2 && h2) _win->.blit2 (w, h, 0, 0, w2, h2, this->_img); } */ return true; }
void hud_update(MCPacketQueue *cq) { hud_prune(); if (hud_id < 0 || !hud_inv) return; bg_color = 34; draw_clear(); bg_color = 0; int updated = 0; switch(hud_mode) { case HUDMODE_TEST: updated = huddraw_test(); break; case HUDMODE_INFO: updated = huddraw_info(); break; case HUDMODE_TUNNEL: updated = huddraw_tunnel(); break; case HUDMODE_MAP: updated = huddraw_map(); break; case HUDMODE_BUILD: updated = huddraw_build(); break; case HUDMODE_HELP: updated = huddraw_help(); break; default: break; } if (updated) { NEWPACKET(SP_Map, map); tmap->mapid = hud_id; tmap->scale = 0; tmap->trackpos = 0; tmap->nicons = 0; tmap->icons = NULL; tmap->ncols = 128; tmap->nrows = 128; tmap->X = 0; tmap->Z = 0; tmap->len = sizeof(hud_image); lh_alloc_num(tmap->data, sizeof(hud_image)); memmove(tmap->data, hud_image, sizeof(hud_image)); queue_packet(map, cq); } hud_inv = HUDINV_NONE; }
void timer_callback(void) { uint8_t val, frac; uint16_t temp; char buf[8]; draw_clear(); temp = onewire_temp_read(); val = temp / 100; frac = temp % 100; if (frac >= 50) { val++; } frac = '°'; sprintf(buf, "%d%cC", val, frac); draw_text(2, 1, WHITE, 1, "Temperature:"); draw_text(30, 20, WHITE, 3, buf); }
int VTrack::move_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down) { int result; result = 0; if(auto_conf->camera) result = camera_autos->move_auto(tracks->canvas, pixel, mwindow->zoom_track, zoom_units, view_start, cursor_x, cursor_y, shift_down, mwindow->session->tracks_vertical); if(auto_conf->projector && !result) result = projector_autos->move_auto(tracks->canvas, pixel, mwindow->zoom_track, zoom_units, view_start, cursor_x, cursor_y, shift_down, mwindow->session->tracks_vertical); if(result) { mwindow->tracks->hide_overlays(0); draw_clear(0, tracks->canvas->w, 0, tracks->canvas->h, 0); draw(0, tracks->canvas->w, 0, tracks->canvas->h, 0); mwindow->tracks->show_overlays(0); } return result; }
//绘制实验数据 void draw_test(int &page) { RECT rect = gDrawClientRect; rect.left += DRAW_TEST_MARGIN; rect.top += DRAW_TEST_MARGIN; rect.right -= DRAW_TEST_MARGIN; rect.bottom -= DRAW_TEST_MARGIN; draw_clear(false); HPEN hPenRed = CreatePen(PS_SOLID, 0, RGB(128,0,0)); //深红线 HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, hPenRed); draw_filename(rect); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_config(rect); //rect.top++; //draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_test_param(rect); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_test_robots(rect, page); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); SelectObject(gDrawBmpMemDC, hPenOld); DeleteObject(hPenRed); draw_refresh(); }
int huddraw_test() { int i; bg_color = B3(COLOR_WHITE); draw_clear(); fg_color = 119; for (i=0; i<36; i++) { int c=(i%6)*10+2; int r=(i/6)*10+2; bg_color = i*4+2; draw_rect(c, r, 8, 8, 1); } int x1=95, y1=95, r=29; double a; for (a=0; a<2*M_PI; a+=M_PI/6) { int x2 = x1+(int)(sin(a)*r); int y2 = y1+(int)(cos(a)*r); draw_line(x1,y1,x2,y2); } return 1; }
int md_init_motion_detector( int columns, int rows, int pixel_measure_mode, int detection_timeout, int measure_interval, int threshold, int draw_grid, int clipping_region_mode, int clipping_region_column1, int clipping_region_row1, int clipping_region_column2, int clipping_region_row2, int parameters, int pixels_step, int msecs_before_trigger ){ if(!motion_detector) { motion_detector=malloc(sizeof(struct motion_detector_s)); if(!motion_detector) return 0; // TODO make sure callers handle this } #ifdef OPT_MD_DEBUG motion_detector->comp_calls_cnt=0; #endif motion_detector->previous_picture_is_ready=0; motion_detector->curr=motion_detector->buff1; motion_detector->prev=motion_detector->buff2; if( pixel_measure_mode != MD_MEASURE_MODE_Y && pixel_measure_mode != MD_MEASURE_MODE_U && pixel_measure_mode != MD_MEASURE_MODE_V && pixel_measure_mode != MD_MEASURE_MODE_R && pixel_measure_mode != MD_MEASURE_MODE_G && pixel_measure_mode != MD_MEASURE_MODE_B ){ pixel_measure_mode = MD_MEASURE_MODE_Y; } if( columns<1 || rows<1 || columns * rows > MOTION_DETECTOR_CELLS ){ columns=3; rows=3; } if(msecs_before_trigger<0){ msecs_before_trigger=0; } if (pixels_step<1){ pixels_step=1; } if(detection_timeout<0){ detection_timeout=0; } if(measure_interval<0) { measure_interval=0; } if(threshold<0) { threshold=0; } motion_detector->msecs_before_trigger=msecs_before_trigger; motion_detector->parameters = parameters; motion_detector->pixels_step=pixels_step; motion_detector->columns=columns; motion_detector->rows=rows; motion_detector->return_value=0; motion_detector->pixel_measure_mode=pixel_measure_mode; motion_detector->timeout=detection_timeout; motion_detector->measure_interval=measure_interval; motion_detector->threshold=threshold; motion_detector->draw_grid=draw_grid; if (clipping_region_column1>clipping_region_column2){ motion_detector->clipping_region_column2=clipping_region_column1; motion_detector->clipping_region_column1=clipping_region_column2; } else { motion_detector->clipping_region_column2=clipping_region_column2; motion_detector->clipping_region_column1=clipping_region_column1; } if (clipping_region_row1>clipping_region_row2){ motion_detector->clipping_region_row2=clipping_region_row1; motion_detector->clipping_region_row1=clipping_region_row2; } else { motion_detector->clipping_region_row2=clipping_region_row2; motion_detector->clipping_region_row1=clipping_region_row1; } if (clipping_region_mode!=MD_REGION_NONE && clipping_region_mode!=MD_REGION_INCLUDE && clipping_region_mode!=MD_REGION_EXCLUDE){ clipping_region_mode=MD_REGION_NONE; } motion_detector->clipping_region_mode=clipping_region_mode; motion_detector->detected_cells=0; motion_detector->previous_picture_is_ready=0; motion_detector->start_time=get_tick_count(); motion_detector->last_measure_time = motion_detector->start_time - motion_detector->measure_interval; motion_detector->running=1; action_push(AS_MOTION_DETECTOR); draw_clear(); return 1; }
void output_draw_clear(struct lstopo_output *loutput) { hwloc_topology_t topology = loutput->topology; draw_clear(topology, hwloc_get_root_obj(topology)); }
//绘制基因 void draw_gene(CGENE gene, int &page) { RECT rect = gDrawClientRect; rect.left += DRAW_GENE_MARGIN; rect.top += DRAW_GENE_MARGIN; rect.right -= DRAW_GENE_MARGIN; rect.bottom -= DRAW_GENE_MARGIN; char v1[MAX_LOADSTRING], v2[MAX_LOADSTRING], v3[MAX_LOADSTRING], v4[MAX_LOADSTRING], *v5 = NULL; int column = (rect.right - rect.left) / 6; draw_clear(false); HPEN hPenRed = CreatePen(PS_SOLID, 0, RGB(128,0,0)); //深红线 HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, hPenRed); //表头 COLORREF hOldColor = SetTextColor(gDrawBmpMemDC, RGB(255,0,0)); //红字 draw_test_table(0, rect, column, "环境", "北-东-南-西-中", NULL, "基因", "策略", "判定"); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; SetTextColor(gDrawBmpMemDC, hOldColor); //表体 int start, end; int pages = draw_calc_page(gConfig.robot_gene_length, DRAW_GENE_ROWS, page, start, end); gTableListPosTop = rect.top; //记录开始位置 for(int env=start;env<end;env++) { //环境编码 sprintf_s(v1, sizeof(v1), "%d", env + 1); //环境编码解码 char north, east, south, west, center; map_env_decode(env, north, east, south, west, center); sprintf_s(v2, sizeof(v2), "%s-%s-%s-%s-%s", draw_env_get(north), draw_env_get(east), draw_env_get(south), draw_env_get(west), draw_env_get(center) ); //基因策略 char code = gene[env]; sprintf_s(v3, sizeof(v3), "%c", code); //反算基因策略 int score = 0; //评分: 0一般 1糟糕 2很好 switch(code) { case ROBOT_ACT_NORTH: sprintf_s(v4, sizeof(v4), "%s", "北移"); score = (north == MAP_CELL_WALL) ? 1 : 0; break; case ROBOT_ACT_SOUTH: sprintf_s(v4, sizeof(v4), "%s", "南移"); score = (south == MAP_CELL_WALL) ? 1 : 0; break; case ROBOT_ACT_EAST: sprintf_s(v4, sizeof(v4), "%s", "东移"); score = (east == MAP_CELL_WALL) ? 1 : 0; break; case ROBOT_ACT_WEST: sprintf_s(v4, sizeof(v4), "%s", "西移"); score = (west == MAP_CELL_WALL) ? 1 : 0; break; case ROBOT_ACT_RND: sprintf_s(v4, sizeof(v4), "%s", "任移"); score = (north == MAP_CELL_WALL || south == MAP_CELL_WALL || east == MAP_CELL_WALL || west == MAP_CELL_WALL) ? 1 : 0; break; case ROBOT_ACT_STAY: sprintf_s(v4, sizeof(v4), "%s", "不动"); score = (north == MAP_CELL_WALL && south == MAP_CELL_WALL && east == MAP_CELL_WALL && west == MAP_CELL_WALL) ? 2 : 1; break; case ROBOT_ACT_CLEAN: sprintf_s(v4, sizeof(v4), "%s", "拾取"); score = (center == MAP_CELL_TRUSH) ? 2 : 1; break; default: sprintf_s(v4, sizeof(v4), "%s", "未知"); throw; //break; } if(score == 1){v5 = "×";} //糟糕 else if(score == 2){v5 = "√";} //很好 else{v5 = NULL;} //一般 draw_test_table(0, rect, column, v1, v2, NULL, v3, v4, v5); } gTableListPosBottom = rect.top; //记录结束位置 rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); sprintf_s(v1, sizeof(v1), "%d/%d", page, pages); TextOut(gDrawBmpMemDC, rect.left, rect.top + DRAW_PAGE_NO_Y, v1, (int)strlen(v1)); SelectObject(gDrawBmpMemDC, hPenOld); DeleteObject(hPenRed); draw_refresh(); }
void draw_stat(PHISTORY history) { RECT rect = gDrawClientRect; rect.left += DRAW_STAT_MARGIN; rect.top += DRAW_STAT_MARGIN; rect.right -= DRAW_STAT_MARGIN; rect.bottom -= DRAW_STAT_MARGIN; draw_clear(false); //先计算最大最小值 PHISTORYITEM p = history->head; int max_round = INT_MIN; int min_round = INT_MAX; double max_gen = INT_MIN; double min_gen = INT_MAX; double max_ratio = INT_MIN; double min_ratio = INT_MAX; double max_score = INT_MIN; double min_score = INT_MAX; while(p != NULL) { if(p->round > max_round){max_round = p->round;} if(p->round < min_round){min_round = p->round;} if(p->top_len > 0) { if(p->top[0].generation > max_gen){max_gen = (double)p->top[0].generation;} if(p->top[0].generation < min_gen){min_gen = (double)p->top[0].generation;} double value = (double)p->round / p->top[0].generation; if(value > max_ratio){max_ratio = value;} if(value < min_ratio){min_ratio = value;} value = (double)p->top[0].score / gConfig.lab_more_count; if(value > max_score){max_score = value;} if(value < min_score){min_score = value;} } p = p->next; } max_round++; min_round--; max_gen++; min_gen--; max_ratio++; min_ratio--; max_score++; min_score--; //绘制世代横坐标 draw_line(rect.left, rect.bottom, rect.right, rect.bottom); int w = (rect.right - rect.left) / DRAW_STAT_TAG_NUM; int x = rect.left; int y = rect.bottom + DRAW_STAT_TAG_LEN; double value = (double)(max_round - min_round) / DRAW_STAT_TAG_NUM; char buf[MAX_LOADSTRING]; for(int i=0;i<=DRAW_STAT_TAG_NUM;i++) { draw_line(x, rect.bottom, x, y); int v = (int)(min_round + value * i); sprintf_s(buf, sizeof(buf), "%d", v); int h = 0; if(v > 100000 && i % 2 == 1) { h = DRAW_STAT_TAG_LEN * 2; } TextOut(gDrawBmpMemDC, x-DRAW_STAT_TAG_LEN*2, y + h, buf, (int)strlen(buf)); x += w; } RECT r = {rect.left, rect.bottom + DRAW_STAT_TAG_LEN * 3, rect.right, gDrawClientRect.bottom}; sprintf_s(buf, sizeof(buf), "%s", "世代"); DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE); //绘制子代 COLORREF hRed = RGB(255,0,0); //红线 HPEN hPenRed = CreatePen(PS_SOLID, 0, hRed); HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, hPenRed); COLORREF hOldColor = SetTextColor(gDrawBmpMemDC, hRed); draw_stat_chart(history, rect, max_round, min_round, max_gen, min_gen, 0); //绘制代比 COLORREF hBlue = RGB(0,0,255); //蓝线 HPEN hPenBlue = CreatePen(PS_SOLID, 0, hBlue); SelectObject(gDrawBmpMemDC, hPenBlue); SetTextColor(gDrawBmpMemDC, hBlue); draw_stat_chart(history, rect, max_round, min_round, max_ratio, min_ratio, 1); //绘制得分 COLORREF hSilver = RGB(96,96,96); //银线 HPEN hPenSilver = CreatePen(PS_SOLID, 0, hSilver); SelectObject(gDrawBmpMemDC, hPenSilver); SetTextColor(gDrawBmpMemDC, hSilver); draw_stat_chart(history, rect, max_round, min_round, max_score, min_score, 2); SetTextColor(gDrawBmpMemDC, hOldColor); SelectObject(gDrawBmpMemDC, hPenOld); DeleteObject(hPenRed); DeleteObject(hPenBlue); DeleteObject(hPenSilver); draw_refresh(); }
void draw_begin(void) { draw_clear(CONS_BLACK); }
int main ( void ) { /* read file (or part of it ) into memory */ PACKET *lPck = malloc(sizeof(PACKET)); QWORD *q; FRAMEBUFFER frame; ZBUFFER z; InitCBParam lInfo; int lFD = fioOpen ( MPEG_BITSTREAM_FILE, O_RDONLY ); long lSize; long lPTS, lCurPTS; frame.width = 640; frame.height = 512; frame.mask = 0; frame.psm = GS_PSM_32; frame.address = graph_vram_allocate(frame.width,frame.height, frame.psm, GRAPH_ALIGN_PAGE); z.enable = 0; z.mask = 0; z.method = 0; z.zsm = 0; z.address = 0; packet_allocate(lPck, 100, 0, 0); if ( lFD < 0 ) { printf ( "test_mpeg: could not open '%s'\n", MPEG_BITSTREAM_FILE ); goto end; } /* end if */ lSize = fioLseek ( lFD, 0, SEEK_END ); fioLseek ( lFD, 0, SEEK_SET ); if ( lSize <= 0 ) { printf ( "test_mpeg: could not obtain file size (%ld)\n", lSize ); goto end; } /* end if */ s_pMPEGData = ( unsigned char* )malloc ( lSize = lSize > MAX_SIZE ? MAX_SIZE : lSize ); if ( !s_pMPEGData ) { printf ( "test_mpeg: could not allocate enough memory (%ld)\n", lSize ); goto end; } /* end if */ if ( fioRead ( lFD, s_pTransferPtr = s_pMPEGData, s_MPEGDataSize = lSize ) != lSize ) { printf ( "test_mpeg: could not read file\n" ); goto end; } /* end if */ fioClose ( lFD ); /* initialize DMAC (I have no idea what this code does as */ /* I'm not quite familiar with ps2sdk) */ dma_channel_initialize ( DMA_CHANNEL_toIPU, NULL, 0 ); dma_channel_initialize ( DMA_CHANNEL_GIF, NULL, 0 ); dma_channel_fast_waits( DMA_CHANNEL_GIF ); /* initialize graphics synthesizer */ graph_initialize(0,640,512,GS_PSM_32,0,0); /* setup texture buffer address just after the framebuffer */ lInfo.m_TexAddr = graph_vram_allocate(0,0,GS_PSM_32,GRAPH_ALIGN_BLOCK); q = lPck->data; q = draw_setup_environment(q,0,&frame,&z); /* clear screen */ q = draw_clear(q,0,0,0,640.0f,512.0f,0,0,0); dma_channel_send_normal(DMA_CHANNEL_GIF, lPck->data, q - lPck->data, 0, 0); /* now it's time to initialize MPEG decoder (though it can be */ /* initialized any time). Just make sure that DMA transfers */ /* to and from IPU (and DRAM -> SPR) are not active, otherwise */ /* unpredicted things will happen. Initialization code is also */ /* allocating some memory using 'memalign' function and no */ /* check is performed whether the allocation was successful or */ /* not, so, before calling this make sure that at least WxHx4x3 */ /* bytes are avaliable for dynamic allocation (possibly using */ /* ps2_sbrk ( 0 ) call) where W and H are picture dimensions in */ /* units of pixels. */ MPEG_Initialize ( SetDMA, NULL, InitCB, &lInfo, &lCurPTS ); /* during decoding scratchpad RAM from address 0x0000 to 0x3C00 */ /* is used by the decoder. */ /* let's go */ while ( 1 ) { /* try decode picture into "lInfo.m_pData" area. It's allowed */ /* to supply different area each time, just make sure that */ /* there're no conflicts with data cache, as decoder doesn't do */ /* anything to synchronize/flush/invalidate data cache. */ /* RGB -> YUV colorspace conversion is pefromed automatically */ /* using interrupt hahdler/semaphore, so, multithreaded */ /* application can benefit from it. Usage of IPU and DMA channels */ /* to/from IPU and DRAM -> SPR is strictly forbidden during */ /* decoding :). */ if ( !MPEG_Picture ( lInfo.m_pData, &lPTS ) ) { /* MPEG_Picture returns nonzero if the picture was successfully */ /* decoded. Zero return means one of the following: */ /* - end of stream was detected (SetDMA function returned zero) */ /* - MPEG sequence end code (0x000001B7) was detected */ /* this test just finishes in both cases */ if ( lInfo.m_pInfo -> m_fEOF ) break; /* ...instead of 'break' we can continue to the next sequence...*/ /* ...but I'm too lazy to handle second call of 'InitCB' :D */ else break; } /* end if */ /* now transfer decoded picture data into texture area of GS RAM */ dma_wait_fast(); dma_channel_send_chain( DMA_CHANNEL_GIF, lInfo.m_XFerPck.data, lInfo.m_XFerPck.qwc, 0, 0); /* wait for vsync 2 times (we have interlaced frame mode) */ graph_wait_vsync (); graph_wait_vsync (); /* no need to wait for DMA transfer completion since vsyncs above */ /* have enough lattency... */ /* ...and finally draw decoded picture... */ dma_channel_send_normal( DMA_CHANNEL_GIF, lInfo.m_DrawPck.data, lInfo.m_DrawPck.qwc, 0, 0); /* ...and go back for the next one */ } /* end while */ /* free memory and other resources */ MPEG_Destroy (); end: printf ( "test_mpeg: test finished\n" ); return SleepThread (), 0; } /* end main */
int main(int argc, char *argv[]) { int rc = 0, first = 1, c = 0, i = 0, l = 0; size_t length = 0; char *exec = NULL, *arg = NULL; char *client_id = NULL, *client_secret = NULL, *access_token = NULL; char *max_id = NULL, *id = NULL, *link = NULL; exec = argv[0]; if (argc < 2) { usage(exec); rc = 1; goto cleanup; } for (i = 1, l = argc; i < l; i++) { arg = argv[i]; length = strlen(arg); if (strncmp(arg, "--client_id", 11) == 0) { length -= 12; client_id = malloc(sizeof(char) * (length + 1)); strncpy(client_id, arg + 12, length); client_id[length] = '\0'; } if (strncmp(arg, "--client_secret", 15) == 0) { length -= 16; client_secret = malloc(sizeof(char) * (length + 1)); strncpy(client_secret, arg + 16, length); client_secret[length] = '\0'; } } if (get_access_token(&access_token, client_id, client_secret) != 0) { printf("Unable to get access_token\n"); rc = 1; goto cleanup; } draw_init(); while (1 == TRUE) { c = getch(); draw_border(); if ((photo_pos == 0 && first == 1) || photo_pos == photo_count - 1) { get_feed(access_token, &max_id); draw_instagram(&id, &link); if (first == 1) { first = 0; } } switch (c) { case '\033': getch(); c = getch(); switch (c) { case 'A': photo_pos--; if (photo_pos < 0) { photo_pos = 0; } break; case 'B': photo_pos++; if (photo_pos >= MAX) { goto cleanup; } break; default: break; } draw_instagram(&id, &link); break; case 'o': open_url(link); break; case 'q': goto cleanup; break; default: break; } } cleanup: draw_clear(); draw_end(); if (client_id) { free(client_id); } if (client_secret) { free(client_secret); } if (access_token) { free(access_token); } if (id) { free(id); } if (link) { free(link); } return rc; }
static void refresh_display(void) { struct xy pos; int i; do_refresh = 0; draw_clear(); draw_activity(1); switch (visual) { case VIEW_SATS: draw_sats(&gps_state); break; case VIEW_MAP: /* show map scale */ if (show_scale) draw_scale(); /* show gps coordinates */ if (show_gpscoords) draw_gpscoords(); vfdlib_setClipArea(0, 0, VFD_WIDTH - VFD_HEIGHT, VFD_HEIGHT); /* draw tracklog */ if (show_track) track_draw(); /* draw route we're following */ route_draw(&gps_coord.xy); /* highlight waypoints */ i = 0; while (route_getwp(i, &pos, NULL, NULL)) { draw_point(&pos, VFDSHADE_BRIGHT); if (i++ != nextwp) continue; /* add focus to next waypoint */ draw_mark(&pos, -1, VFDSHADE_MEDIUM); } /* draw our own location */ draw_mark(&gps_coord.xy, gps_bearing, VFDSHADE_BRIGHT); vfdlib_setClipArea(0, 0, VFD_WIDTH, VFD_HEIGHT); draw_info(); break; case VIEW_ROUTE: draw_wpstext(); break; } if (load_route) routes_list(); else if (menu) draw_msg(menu_msg[menu_pos]); else if (lastmenu) { char *msg=NULL; lastmenu--; switch(menu_pos) { case 2: switch (show_popups) { case 0: msg = "No Popups"; break; case 1: msg = "Popups"; break; case 2: msg = "Permanent Popups"; break; } break; case 3: msg = (show_metric?"Meters":"Miles"); break; case 4: msg = (show_gpscoords?"Coordinates":"No Coordinates"); break; case 5: msg = (show_time?"Time":"Distance"); break; case 6: msg = (show_track?"Track":"No Track"); break; case 7: switch (coord_format) { case 0: msg = "DDD Coords"; break; case 1: msg = "DMM Coords"; break; case 2: msg = "DMS Coords"; break; } break; } if (msg) draw_msg(msg); } draw_display(); #ifndef __arm__ { extern int stats_toTM; extern int stats_distance; extern int stats_bearing; fprintf(stderr, "conv stats: GPS>TM %d DIST %d HDG %d\n", stats_toTM, stats_distance, stats_bearing); stats_toTM = stats_distance = stats_bearing = 0; } #endif }
void run_demo(packet_t *packet) { int context = 0; vertex_t v0; color_t c0; color_t c1; texbuffer_t texbuf; clutbuffer_t clut; lod_t lod; packet_t *packets[2]; packet_t *current; packets[0] = packet_init(10000,PACKET_NORMAL); packets[1] = packet_init(10000,PACKET_NORMAL); // Use linear filtering for good scaling results lod.calculation = LOD_USE_K; lod.max_level = 0; lod.mag_filter = LOD_MAG_LINEAR; lod.min_filter = LOD_MIN_LINEAR; lod.l = 0; lod.k = 0; texbuf.width = 512; texbuf.psm = GS_PSM_4; texbuf.address = myaddress; texbuf.info.width = draw_log2(512); texbuf.info.height = draw_log2(256); texbuf.info.components = TEXTURE_COMPONENTS_RGBA; texbuf.info.function = TEXTURE_FUNCTION_MODULATE; clut.storage_mode = CLUT_STORAGE_MODE1; clut.start = 0; clut.psm = GS_PSM_32; clut.load_method = CLUT_LOAD; clut.address = clutaddress; v0.x = 320.0f; v0.y = 240.0f; v0.z = 4; c0.r = 0xFF; c0.g = 0xFF; c0.b = 0xFF; c0.a = 0x80; c0.q = 1.0f; c1.r = 0xFF; c1.g = 0x00; c1.b = 0x00; c1.a = 0x40; c1.q = 1.0f; // UTF-8 unsigned char str0[] = { 0x61, 0x62, 0xC2, 0xA9, 0x78, 0xC2, 0xA5, 0xC2, 0xB2, '\0'}; // Shift-JIS unsigned char str1[] = {0x81, 0xBC, 0x93, 0xF1, 0x93, 0xF1, 0x93, 0xF1, 0x81, 0x69, 0x81, 0x40, 0x81, 0x4F, 0x83, 0xD6, 0x81, 0x4F, 0x81, 0x6A, 0x93, 0xF1, 0x81, 0xBD, 0x0D, '\0' }; qword_t *q = packet->data; while(1) { current = packets[context]; q = current->data; q = draw_clear(q,0,0,0,640.0f,448.0f,0x40,0x40,0x40); q = draw_texture_sampling(q,0,&lod); q = draw_texturebuffer(q,0,&texbuf,&clut); impress.scale = 3.0f; q = fontx_print_sjis(q,0,str1,CENTER_ALIGN,&v0,&c0,&krom_u,&krom_k); q = fontstudio_print_string(q,0,str0,CENTER_ALIGN,&v0,&c1,&impress); q = draw_finish(q); dma_wait_fast(); dma_channel_send_normal(DMA_CHANNEL_GIF,current->data, q - current->data, 0,0); draw_wait_finish(); context ^= 1; graph_wait_vsync(); } free(packets[0]); free(packets[1]); }