void drawmandelbrot(SDL_Surface *surface) { if (SDL_MUSTLOCK(surface)) { SDL_LockSurface(surface); } Uint32 *pixels = (Uint32 *) surface->pixels; for (int i = 0; i < surface->w * surface->h; i++) { int y = i / surface->w; int x = i % surface->w; float complex c = ((3.0f * x / surface->w) - 2.0f) + I * ((2.0f * y / surface->h) - 1.0f); bool diverges = false; float complex z = 0; int it; for (it = 1; it <= max_it; it++) { /* z = z² + c */ z = cpowf(z, 2) + c; /* If |z| ever gets greater than 2, it diverges. */ if (cabsf(z) > 2) { diverges = true; break; } } Uint32 color; if (diverges) { color = outcolor(it); } else { color = incolor(); } pixels[i] = color; /* Update the screen every 10 lines. */ if (y % 10 == 0 && x == 0) { SDL_Flip(surface); } } /* Update the screen a final time. */ SDL_Flip(surface); if (SDL_MUSTLOCK(surface)) { SDL_UnlockSurface(surface); } }
/* 320 * ------------------- *| | *| | *| | 240 *| | *| | * ------------------- */ void ImagDisp(void) { uint16_t i,j,m=0; uint16_t Camera_Data; for(i = 0; i < 240; i++){ for(j = 0; j < 320; j++){ READ_FIFO_PIXEL(Camera_Data); /* 从FIFO读出一个rgb565像素到Camera_Data变量 */ if((i == Mid[4].y) && (j > Mid[4].x) && (j <= Mid[4].x + pointNum)) ColorData4[0][j-Mid[4].x] = Camera_Data; if((i == Mid[4].y) && (j < Mid[4].x) && (j >= Mid[4].x - pointNum)) ColorData4[1][Mid[4].x-j] = Camera_Data; if((j == Mid[4].x) && (i >= Mid[4].y - pointNum) && (i < Mid[4].y)) ColorData4[2][Mid[4].y-i] = Camera_Data; if((j == Mid[4].x) && (i > Mid[4].y) && ( i <= Mid[4].y + pointNum)) ColorData4[3][i-Mid[4].y] = Camera_Data; if((i == Mid[2].y) && (j > Mid[2].x) && (j <= Mid[2].x + pointNum)) ColorData4[0][j-Mid[2].x] = Camera_Data; if((i == Mid[2].y) && (j < Mid[2].x) && (j >= Mid[2].x - pointNum)) ColorData4[1][Mid[2].x-j] = Camera_Data; if((j == Mid[2].x) && (i >= Mid[2].y - pointNum) && (i < Mid[2].y)) ColorData4[2][Mid[2].y-i] = Camera_Data; if((j == Mid[2].x) && (i > Mid[2].y) && ( i <= Mid[2].y + pointNum)) ColorData4[3][i-Mid[2].y] = Camera_Data; // // if(i==Mid[6].y&&j>Mid[6].x&&j<=Mid[6].x+pointNum) // ColorData6[0][j-Mid[6].x]=Camera_Data; // if(i==Mid[6].y&&j<Mid[6].x&&j>=Mid[6].x-pointNum) // ColorData6[1][Mid[6].x-j]=Camera_Data; // if(j==Mid[6].x&&i>=Mid[6].y-pointNum&&i<Mid[6].y) // ColorData6[2][Mid[6].y-i]=Camera_Data; // if(j==Mid[6].x&&i>Mid[6].y&&i<=Mid[6].y+pointNum) // ColorData6[3][i-Mid[6].y]=Camera_Data; if(i==65&&j==135) { MidColorData[0][0]=Camera_Data; Camera_Data=0; } if(i==65&&j==170) { MidColorData[0][1]=Camera_Data; Camera_Data=0; } if(i==65&&j==202) { MidColorData[0][2]=Camera_Data; Camera_Data=0; } if(i==100&&j==135) { MidColorData[1][0]=Camera_Data; Camera_Data=0; } if(i==100&&j==170) { MidColorData[1][1]=Camera_Data; Camera_Data=0; } if(i==100&&j==202) { MidColorData[1][2]=Camera_Data; Camera_Data=0; } if(i==135&&j==135) { MidColorData[2][0]=Camera_Data; Camera_Data=0; } if(i==135&&j==170) { MidColorData[2][1]=Camera_Data; Camera_Data=0; } if(i==135&&j==202) { MidColorData[2][2]=Camera_Data; Camera_Data=0; } LCD_WR_Data(Camera_Data); } } for(i=0;i<3;i++){ for(j=0;j<3;j++){ RGBtoHSL(MidColorData[i][j],hsl_l+m); outcolor(hsl_l+m); m++; } } if(ColorDataCompare(ColorData4)) { // if(ColorDataCompare(ColorData2)) Judgerubik=1; // else // Judgerubik=0; } else Judgerubik=0; }
int outDrawInvMesh ( const C_Graph * const grafptr, /* Graph structure, sorted by vertex index */ const C_Geometry * const geomptr, /* Graph geometry, sorted by vertex label */ const C_Mapping * const mapptr, /* Result mapping, sorted by vertex label */ FILE * const stream) /* Output stream */ { void (* outcolor) (const SCOTCH_Num, double[]); /* Color routine */ O_InvMeshPath * pattab; /* Array of path building data */ int * idxtab; /* Array of indexes */ int idxnbr; /* Number of indexes */ time_t pictime; /* Creation time */ double color[3]; /* Vertex color */ int i, j, k; if (geomptr->verttab == NULL) { errorPrint ("outDrawInvMesh: geometry not provided"); return (1); } time (&pictime); /* Get current time */ outcolor = (O_outParam.InvMesh.color == 'c') ? outColorColor : outColorBlw; /* Select color output routine */ if (((idxtab = (int *) memAlloc ((grafptr->edgenbr / 2) * 3 * sizeof (int))) == NULL) || ((pattab = (O_InvMeshPath *) memAlloc (grafptr->vertnbr * sizeof (O_InvMeshPath))) == NULL)) { errorPrint ("outDrawInvMesh: out of memory"); if (idxtab != NULL) memFree (idxtab); return (1); } idxnbr = 0; /* No indexes yet */ for (i = 0, j = 0; i < grafptr->vertnbr; i ++) { /* For all vertices */ pattab[i].nbr = 0; /* Compute the number of output paths */ pattab[i].idx = grafptr->verttab[i]; for ( ; j < grafptr->vendtab[i]; j ++) { if ((grafptr->edgetab[j] > i) && /* If it can be an output edge */ ((O_outParam.InvMesh.edge != 'r') || /* And this edge can be drawn */ (mapptr->labltab[i] == mapptr->labltab[grafptr->edgetab[j]]))) pattab[i].nbr ++; /* One more path to higher vertices */ } } for (i = 0; i < grafptr->vertnbr; ) { /* For all vertices */ if (pattab[i].nbr == 0) { /* If no output path for this vertex */ i ++; /* Skip to next vertex */ continue; } j = i; /* Begin with this vertex */ idxtab[idxnbr ++] = j; /* Add it to the current segment */ do { for (k = pattab[j].idx; k < grafptr->vendtab[j]; k ++) { /* Search for first output */ if ((grafptr->edgetab[k] > j) && /* If it can be an output edge */ ((O_outParam.InvMesh.edge != 'r') || /* And this edge can be drawn */ (mapptr->labltab[j] == mapptr->labltab[grafptr->edgetab[k]]))) break; } pattab[j].nbr --; /* One less output path remaining */ pattab[j].idx = k + 1; /* Search from the next position */ j = grafptr->edgetab[k]; /* Get the path end vertex number */ idxtab[idxnbr ++] = j; /* Add it to the current segment */ } while (pattab[j].nbr > 0); /* As long as there is a path */ idxtab[idxnbr ++] = ~0; /* Mark end of path */ } fprintf (stream, "#Inventor V2.0 ascii\n"); /* Write header */ fprintf (stream, "#Title: %s %s %s\n", C_filenamesrcinp, C_filenamegeoinp, C_filenamemapinp); fprintf (stream, "#Creator: out (F. Pellegrini, LaBRI, Bordeaux)\n"); fprintf (stream, "#CreationDate: %s", ctime (&pictime)); if (idxnbr == 0) /* If nothing to write */ return (0); fprintf (stream, "Separator {\n"); fprintf (stream, " LightModel {\n model\t\tBASE_COLOR\n }\n"); fprintf (stream, " DrawStyle {\n style\t\tLINES\n }\n"); fprintf (stream, " MaterialBinding {\n value\t\tPER_VERTEX\n }\n"); fprintf (stream, " Coordinate3 {\n point [\n\t%g\t%g\t%g", /* Write vertex coordinates */ geomptr->verttab[0].x, geomptr->verttab[0].y, geomptr->verttab[0].z); for (i = 1; i < grafptr->vertnbr; i ++) fprintf (stream, ",\n\t%g\t%g\t%g", geomptr->verttab[i].x, geomptr->verttab[i].y, geomptr->verttab[i].z); fprintf (stream, " ]\n }\n"); fprintf (stream, " BaseColor {\n rgb ["); /* Write color vector */ for (i = 0; i < idxnbr - 2; i ++) { if (idxtab[i] != ~0) { outcolor (mapptr->labltab[idxtab[i]], color); fprintf (stream, "\n\t%g\t%g\t%g,", (double) color[0], (double) color[1], (double) color[2]); } } outcolor (mapptr->labltab[idxtab[idxnbr - 2]], color); fprintf (stream, "\n\t%g\t%g\t%g ]\n }\n", (double) color[0], (double) color[1], (double) color[2]); fprintf (stream, " IndexedLineSet {\n coordIndex ["); /* Write set of lines */ for (i = 0; i < idxnbr - 1; i ++) { if ((i % 8) == 0) fprintf (stream, "\n"); if (idxtab[i] == ~0) fprintf (stream, "\t-1,"); else fprintf (stream, "\t%u,", idxtab[i]); } if (((idxnbr - 1) % 8) == 0) fprintf (stream, "\n"); fprintf (stream, "\t-1 ]\n }\n"); fprintf (stream, "}\n"); /* Write end of separator */ #if 0 for (i = 0; i < grafptr->vertnbr; i ++) { /* For all vertices */ outcolor (mapptr->labltab[i], color); fprintf (stream, "Separator { Translation { translation %lg %lg %lg } BaseColor { rgb [ %lg %lg %lg ] } Sphere { radius 0.3 } }\n", geomptr->verttab[i].x, geomptr->verttab[i].y, geomptr->verttab[i].z, (double) color[0], (double) color[1], (double) color[2]); } #endif memFree (pattab); /* Free path array */ memFree (idxtab); /* Free index array */ return (0); }