ENTRYPOINT void init_noof (ModeInfo *mi) { int i; noof_configuration *bp; if (!bps) { bps = (noof_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (noof_configuration)); if (!bps) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); glDrawBuffer(GL_FRONT); glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_LINE_SMOOTH); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (i = 0; i < N_SHAPES; i++) initshapes(bp, i); reshape_noof (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); }
void myinit(void) { int i; srandom(getpid()); glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_LINE_SMOOTH); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (i = 0; i < N_SHAPES; i++) initshapes(i); myReshape(200, 200); }
static void drawleaf(noof_configuration *bp, int l) { int b, blades; float x, y; float wobble; blades = bp->blad[l]; y = 0.10 * sin(bp->geep[l] * M_PI / 180.0) + 0.099 * sin(bp->geep[l] * 5.12 * M_PI / 180.0); if (y < 0) y = -y; x = 0.15 * cos(bp->geep[l] * M_PI / 180.0) + 0.149 * cos(bp->geep[l] * 5.12 * M_PI / 180.0); if (x < 0.0) x = 0.0 - x; if (y < 0.001 && x > 0.000002 && ((bp->tko & 0x1) == 0)) { initshapes(bp, l); /* let it become reborn as something else */ bp->tko++; return; } { float w1 = sin(bp->geep[l] * 15.3 * M_PI / 180.0); wobble = 3.0 + 2.00 * sin(bp->geep[l] * 0.4 * M_PI / 180.0) + 3.94261 * w1; } /** if(blades == 2) if (y > 3.000*x) y = x*3.000; if(blades == 3) if (y > 1.732*x) y = x*1.732; if(blades == 4) if (y > x) y = x; if(blades == 5) if (y > 0.726*x) y = x*0.726; if(blades == 6) if (y > 0.577*x) y = x*0.577; if(blades == 7) if (y > 0.481*x) y = x*0.481; if(blades == 8) if (y > 0.414*x) y = x*0.414; */ if (y > x * bladeratio[blades]) y = x * bladeratio[blades]; for (b = 0; b < blades; b++) { glPushMatrix(); glTranslatef(bp->pos[l * 3], bp->pos[l * 3 + 1], bp->pos[l * 3 + 2]); glRotatef(bp->ang[l] + b * (360.0 / blades), 0.0, 0.0, 1.0); glScalef(wobble * bp->sca[l], wobble * bp->sca[l], wobble * bp->sca[l]); /** if(tko & 0x40000) glColor3f(col[l*3], col[l*3+1], col[l*3+2]); else */ glColor4ub(0, 0, 0, 0x60); /* constrain geep cooridinates here XXX */ glEnable(GL_BLEND); glBegin(GL_TRIANGLE_STRIP); glVertex2f(x * bp->sca[l], 0.0); glVertex2f(x, y); glVertex2f(x, -y); /* C */ glVertex2f(0.3, 0.0); /* D */ glEnd(); /** if(tko++ & 0x40000) glColor3f(0,0,0); else */ glColor3f(bp->col[l * 3], bp->col[l * 3 + 1], bp->col[l * 3 + 2]); glBegin(GL_LINE_LOOP); glVertex2f(x * bp->sca[l], 0.0); glVertex2f(x, y); glVertex2f(0.3, 0.0); /* D */ glVertex2f(x, -y); /* C */ glEnd(); glDisable(GL_BLEND); glPopMatrix(); } }
void initbsizeconst(void){ int i,j,x,y,ixmin,iymin,xm,ym,mid; firstsquare = 0; boardsquare = boardsize*boardsize; lastsquare = boardsquare; lastrandom = boardsize/3; brddir[0] = -boardsize; brddir[3] = boardsize; initkomi(); for(i = 0; i < 52; ++i)linktypes[i] = 0; linktypes[1] = linktypes[boardsize] = 1; linktypes[boardsize-2] = linktypes[boardsize+2] = linktypes[boardsize*2+1] = linktypes[boardsize*2-1] = 2; for(i = 0; i < 5; ++i) for(j = 0; j < 3; ++j) if(diffs4i[i][j] > 10)diffs4[i][j] = diffs4i[i][j] - 19 + boardsize; else diffs4[i][j] = diffs4i[i][j]; for(i = 0; i < 9; ++i) for(j = 0; j < 4; ++j) if(diffs5i[i][j] > 10)diffs5[i][j] = diffs5i[i][j] - 19 + boardsize; else diffs5[i][j] = diffs5i[i][j]; for(i = 0; i < 4; ++i) for(j = 0; j < 5; ++j) if(diffs6i[i][j] > 10)diffs6[i][j] = diffs6i[i][j] - 19 + boardsize; else diffs6[i][j] = diffs6i[i][j]; for(i = 0; i < 52; ++i){ if(nbri[i] == 19)nbr[i] = boardsize; else if(nbri[i] == -19)nbr[i] = -boardsize; else nbr[i] = nbri[i]; if(diagsi[i] == -18)diags[i] = -boardsize+1; else if(diagsi[i] == -20)diags[i] = -boardsize-1; else if(diagsi[i] == 18)diags[i] = boardsize-1; else if(diagsi[i] == 20)diags[i] = boardsize+1; } edge[NOSQUARE] = edge2[NOSQUARE] = NOEDGE; for(i = 0; i < boardsquare; i++){ x = xval[i] = i%boardsize; y = yval[i] = i/boardsize; xm = x+1; if(boardsize - x < xm)xm = boardsize-x; ym = y+1; if(boardsize - y < ym)ym = boardsize-y; if(xm < ym){ edge[i] = xm; edge2[i] = ym; } else { edge[i] = ym; edge2[i] = xm; } if(x == 0){ fdir[i] = 11; } if(x == boardsize-1){ fdir[i] = 14; } if(y == 0){ fdir[i] = 8; } if(y == boardsize-1){ fdir[i] = 17; } if(edge[i] != 1){ /* fdir and ldir for center */ ixmin = x; iymin = y; mid = boardsize/2; if(boardsize-1-x < ixmin)ixmin = boardsize-1-x; if(boardsize-1-y < iymin)iymin = boardsize-1-y; if(ixmin == iymin){ /* diagonal */ if(x <= mid && y <= mid){ fdir[i] = 20; } if(x > mid && y <= mid){ fdir[i] = 24; } if(x <=mid && y > mid){ fdir[i] = 28; } if(x > mid && y > mid){ fdir[i] = 32; } } else if(iymin < ixmin){ /* top or bottom */ if(y < mid){ fdir[i] = 48; } else { fdir[i] = 36; } } else { if(x < mid){ fdir[i] = 44; } else { fdir[i] = 40; } } } } edge[0] = 0; edge[boardsquare-1] = 0; edge[boardsize-1] = 0; edge[boardsquare-boardsize] = 0; edge2[0] = 0; edge2[boardsquare-1] = 0; edge2[boardsize-1] = 0; edge2[boardsquare-boardsize] = 0; fdir[0] = 0; fdir[boardsquare-1] = 6; fdir[boardsize-1] = 2; fdir[boardsquare-boardsize] = 4; initrtval(); initshapes(); }