MyClass() { QString xres("{ 'var' : 'xres', 'name' : 'Image Width', 'type' : 'int', 'min' : 1, 'max' : 4096, 'value' : 1024 }"); QString yres("{ 'var' : 'yres', 'name' : 'Image Height', 'type' : 'int', 'min' : 1, 'max' : 4096, 'value' : 768 }"); QString samplingWidth("{ 'var' : 'samplingWidth', 'name' : 'Sampling Width', 'type' : 'float', 'min' : 1, 'max' : 8, 'value' : 3 }"); QString exposure("{ 'var' : 'exposure', 'name' : 'Exposure', 'type' : 'float', 'min' : 0.001, 'max' : 1000, 'value' : 1.0 }"); QStringList atts; atts << xres << yres << samplingWidth << exposure; addAttributes(atts); }
VImage VImage::new_from_image( std::vector<double> pixel ) { VImage onepx = VImage::black( 1, 1, VImage::option()->set( "bands", bands() ) ); onepx = onepx.linear( to_vectorv( 1, 1.0 ), pixel ).cast( format() ); VImage big = onepx.embed( 0, 0, width(), height(), VImage::option()->set( "extend", VIPS_EXTEND_COPY ) ); big = big.copy( VImage::option()-> set( "interpretation", interpretation() )-> set( "xres", xres() )-> set( "yres", yres() )-> set( "xoffset", xres() )-> set( "yoffset", yres() ) ); return( big ); }
void init_board(void) { int i, j; startx = 50, starty = 50, endx=xres() - 50, endy = yres() - 50, scope = 0; maxn = (xres() - 500) / D, maxm = (yres() - 150) / D; if (maxn >= MAXWIDTH) maxn = MAXWIDTH - 1; if (maxm >= MAXHEIGHT) maxm = MAXHEIGHT - 1; //init board to zero for (i = 0; i<= maxn; i++) for (j = 0; j<= maxm; j++) board[j][i] = 0; printf("\033[?25l"); //隐藏光标 system("clear"); background_pic("background.bmp"); draw_board(); printlet((maxn + 2) * D + 50, 2 * D + 100, "NEXT"); print_scope(0); }
void init(void) { int i; srand(getpid()); for (i = 0; i < BOX_SIZE; i++) { box[i].cent.x = (unsigned)rand() % (xres() - 200) + 100; box[i].cent.y = (unsigned)rand() % (yres() - 200) + 100; box[i].dir = (unsigned)rand() % 4; box[i].r = 50; box[i].color = 0xaf; } }
static void change_dir__(struct circle *p) { if (p->cent.x - p->r == 0 && p->cent.y - p->r == 0) { p->dir = 1; } else if (p->cent.x - p->r == 0 && p->cent.y + p->r == yres() - 1) { p->dir = 0; } else if (p->cent.x + p->r == xres() - 1 && p->cent.y - p->r == 0) { p->dir = 2; } else if (p->cent.x + p->r == xres() - 1 && p->cent.y + p->r == yres() - 1) { p->dir = 3; } else if (p->cent.x - p->r == 0) { if (p->dir == 2) { p->dir = 1; } else { p->dir = 0; } } else if (p->cent.x + p->r == xres() - 1) { if (p->dir == 0) { p->dir = 3; } else { p->dir = 2; } } else if (p->cent.y - p->r == 0) { if (p->dir == 0) { p->dir = 1; } else { p->dir = 2; } } else if (p->cent.y + p->r == yres() - 1) { if (p->dir == 1) { p->dir = 0; } else { p->dir = 3; } } }
void move(void) { int x, y, r, l, limitx, limity; srand(getpid()); //r = rand() % 8; r = 2; y = x = rand() % 500; limitx = xres() - 2*R; limity = yres() - 2*R; while (l = 4) { switch (l){ case 1: /* x++, y++ */ for (; x <= limitx && y <= limity; x++, y += r) { dram(x,y+R*2); usleep(10000); clean(x, y+R*2); } break; case 2: /* x--, y-- */ for (; x >= 0 && y >= 0; x--, y -= r) { dram(x,y+R*2); usleep(10000); clean(x, y+R*2); } break; case 3: /* x--, y++ */ for (; x >= 0 && y <= limity; x--, y += r) { dram(x,y+R*2); usleep(10000); clean(x, y+R*2); } break; case 4: /* x++, y-- */ for (; x <= limitx && y >= 0; x++, y -= r) { dram(x,y+R*2); usleep(10000); clean(x, y+R*2); } break; default: break; } } }
int main(void) { int ret; ret = fb_open(); if (ret != 0) { fprintf(stderr, "fb_open() error.\n"); exit(1); } //srand(getpid()); //r = rand() % 10; //printf("x=%d, y=%d, rand=%d\n",xres(),yres(),r); clear(0,yres()); move(); fb_close(); return 0; }
static void init_board(void) { int i, j, startx = 50, starty = 50, endx=xres() - 50, endy = yres() - 50; int BW = 1, che_count = 1, winner = 1, space = 0, col = 0; boardx = (endx - 100) / D > MAXBOARD ? MAXBOARD: (endx - 100) / D; boardy = (endy - 100) / D > MAXBOARD ? MAXBOARD: (endy - 100) / D; system("clear"); for (; startx <= endx - 400 ; startx += D) for (starty = 100; starty <= endy; starty +=D) { for (i = 0; i <= D; i++) for (j = 0; j <= D; j++) if ((i < D - 1) && (j < D -1) ) { fb_draw_point(i+startx ,j+starty , 244); } else fb_draw_point(i+startx ,j+starty ,0x00); //printdig(i+startx ,j+starty , col++); } }