Map::Move::Enum Firefly::Move(const Map::Map& map) { *m_n = *m_c; if (m_n->dest == Location()) { m_n->dest = map.RandomLocation(); } Firefly *nearby_p = map.NearestNeighbor<Firefly>(this, SCAN_DISTANCE); if (nearby_p) ExamineNeighbor(nearby_p); if (--(m_n->counter) <= 0) { NextColor(); m_n->counter = COLOR_CHANGE_TIME; ++m_n->version; m_n->source_p = this; FIREFLY_DEBUG("Source:" << m_n->source_p << "Version:" << m_n->version << "Color:" << colors[m_n->color] << "Counter:" << m_n->counter); } return Location().DirectionTo(m_n->dest); }
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB ) { EDA_COLOR_T candidate = BLACK; /* Find the 'nearest' color in the palette. This is fun. There is a gazilion of metrics for the color space and no one of the useful one is in the RGB color space. Who cares, this is a CAD, not a photosomething... I hereby declare that the distance is the sum of the square of the component difference. Think about the RGB color cube. Now get the euclidean distance, but without the square root... for ordering purposes it's the same, obviously. Also each component can't be less of the target one, since I found this currently work better... */ int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) ) { const StructColors &c = g_ColorRefs[trying]; int distance = (aR - c.m_Red) * (aR - c.m_Red) + (aG - c.m_Green) * (aG - c.m_Green) + (aB - c.m_Blue) * (aB - c.m_Blue); if( distance < nearest_distance && c.m_Red >= aR && c.m_Green >= aG && c.m_Blue >= aB ) { nearest_distance = distance; candidate = trying; } } return candidate; }
/* -------------------------------------------------------------------- */ static void plotDiffLines(PLOT_INFO *plot) { if (Color) { ResetColors(); XSetForeground(plot->dpy, plot->gc, NextColor()); } XSetLineAttributes(plot->dpy, plot->gc, LineThickness, LineSolid, CapButt, JoinMiter); plotTimeSeries(plot, &diffSet); if (Color) XSetForeground(plot->dpy, plot->gc, GetColor(0)); sprintf(buffer, "%10.2f%10.2f%10.2f%10.2f%10.2f", diffSet.stats.mean, diffSet.stats.sigma, diffSet.stats.variance, diffSet.stats.min, diffSet.stats.max); XDrawString(plot->dpy, plot->win, plot->gc, plot->x.xLegendText+100, yLegendX(plot, 0)+3, buffer, strlen(buffer)); strcpy(buffer, " mean sigma var min max"); XDrawString(plot->dpy, plot->win, plot->gc, plot->x.xLegendText+100, yLegendX(plot, 2)+12, buffer, strlen(buffer)); } /* END PLOTDIFFLINES */
void WERD::plot(ScrollView* window) { ScrollView::Color colour = FIRST_COLOUR; C_BLOB_IT it = &cblobs; for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { it.data()->plot(window, colour, CHILD_COLOUR); colour = NextColor(colour); } plot_rej_blobs(window); }
EDA_COLOR_T ColorByName( const wxString& aName ) { // look for a match in the palette itself for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) ) { if( 0 == aName.CmpNoCase( ColorGetName( trying ) ) ) return trying; } // Not found, no idea... return UNSPECIFIED_COLOR; }
void PerfRenderer::render(const NxProfileData* prof, int width, int height) { if(!m_profilerOn) return; GLFontRenderer::setScreenResolution(width, height); #ifdef __PPCGEKKO__ GLFontRenderer::setColor(0.8f, 1.0f, 0.0f, 1.0f); #else GLFontRenderer::setColor(1.0f, 0.0f, 0.0f, 1.0f); #endif //position on screen: float sx = 0.01f; float sx2= 0.38f; //float col1 = -0.5f/2; //float col2 = -0.2f/5; float sy = 0.95f; #ifdef __PPCGEKKO__ float fontHeight = 0.036f; #else float fontHeight = 0.018f; #endif char buf[256]; if(prof != NULL) { // display title sprintf(buf,"Profiler (FPS: %g)",computeFPS()); GLFontRenderer::print(sx, sy, fontHeight, buf, false, 11, true); //display headings #ifdef NX_ENABLE_PROFILER_COUNTER GLFontRenderer::print(sx2, sy, fontHeight, "count %parent %total %self hier self counter"); #else GLFontRenderer::print(sx2, sy, fontHeight, "count %parent %total %self hier self"); #endif sy -= 2*fontHeight; //The total for the top level is the sum of all the top level zones //(There could be multiple top level zones, eg threading enabled). float total = 0.0f; for(unsigned int i=0;i<prof->numZones;i++) { if(prof->profileZones[i].recursionLevel==0) total+=prof->profileZones[i].hierTime; } NextColor(true); for(unsigned int i=0;i<prof->numZones;i++) { NxProfileZone & z = prof->profileZones[i]; #ifdef __CELLOS_LV2__ // Skip internal SPU Dynamics profile zones // if (!strncmp("PXS_PROFILE_ZONE_DYNAMICS_SPU_",z.name,strlen("PXS_PROFILE_ZONE_DYNAMICS_SPU_"))) continue; #endif if(z.callCount) //skip empty zones { float precTotal = total ? z.hierTime * 100.0f / total : 0.0f; float percSelf = z.hierTime ? z.selfTime * 100.0f / z.hierTime : 0.0f; #ifdef NX_ENABLE_PROFILER_COUNTER sprintf(buf, "%4d %4.0f %4.0f %4.0f %6d %6d %7d", z.callCount, z.percent, precTotal, percSelf, z.hierTime, z.selfTime,z.counter); #else sprintf(buf, "%4d %4.0f %4.0f %4.0f %10d %10d", z.callCount, z.percent, precTotal, percSelf, z.hierTime, z.selfTime); #endif GLFontRenderer::print(sx + 0.012f*z.recursionLevel, sy, fontHeight, z.name+2, false, 11, true); GLFontRenderer::print(sx2, sy, fontHeight, buf, true, 11, true); NextColor(); sy -= fontHeight; } } } else if(m_profilerOn) {//we can still display frame rate even if NX was not compiled with profiling support. // display title #ifdef __PPCGEKKO__ sprintf(buf,"FPS: %d",(unsigned int)computeFPS()); #else sprintf(buf,"FPS: %g",computeFPS()); #endif GLFontRenderer::print(sx, sy, fontHeight, buf, false, 11, true); } }
/** * Opens the DXF plot with a skeleton header */ bool DXF_PLOTTER::StartPlot() { wxASSERT( outputFile ); // DXF HEADER - Boilerplate // Defines the minimum for drawing i.e. the angle system and the // continuous linetype fputs( " 0\n" "SECTION\n" " 2\n" "HEADER\n" " 9\n" "$ANGBASE\n" " 50\n" "0.0\n" " 9\n" "$ANGDIR\n" " 70\n" " 1\n" " 9\n" "$MEASUREMENT\n" " 70\n" "0\n" " 0\n" // This means 'metric units' "ENDSEC\n" " 0\n" "SECTION\n" " 2\n" "TABLES\n" " 0\n" "TABLE\n" " 2\n" "LTYPE\n" " 70\n" "1\n" " 0\n" "LTYPE\n" " 2\n" "CONTINUOUS\n" " 70\n" "0\n" " 3\n" "Solid line\n" " 72\n" "65\n" " 73\n" "0\n" " 40\n" "0.0\n" " 0\n" "ENDTAB\n", outputFile ); // Text styles table // Defines 4 text styles, one for each bold/italic combination fputs( " 0\n" "TABLE\n" " 2\n" "STYLE\n" " 70\n" "4\n", outputFile ); static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"}; for(int i = 0; i < 4; i++ ) { fprintf( outputFile, " 0\n" "STYLE\n" " 2\n" "%s\n" // Style name " 70\n" "0\n" // Standard flags " 40\n" "0\n" // Non-fixed height text " 41\n" "1\n" // Width factor (base) " 42\n" "1\n" // Last height (mandatory) " 50\n" "%g\n" // Oblique angle " 71\n" "0\n" // Generation flags (default) " 3\n" // The standard ISO font (when kicad is build with it // the dxf text in acad matches *perfectly*) "isocp.shx\n", // Font name (when not bigfont) // Apply a 15 degree angle to italic text style_name[i], i < 2 ? 0 : DXF_OBLIQUE_ANGLE ); } // Layer table - one layer per color fprintf( outputFile, " 0\n" "ENDTAB\n" " 0\n" "TABLE\n" " 2\n" "LAYER\n" " 70\n" "%d\n", NBCOLORS ); /* The layer/colors palette. The acad/DXF palette is divided in 3 zones: - The primary colors (1 - 9) - An HSV zone (10-250, 5 values x 2 saturations x 10 hues - Greys (251 - 255) There is *no* black... the white does it on paper, usually, and anyway it depends on the plotter configuration, since DXF colors are meant to be logical only (they represent *both* line color and width); later version with plot styles only complicate the matter! As usual, brown and magenta/purple are difficult to place since they are actually variations of other colors. */ static const struct { const char *name; int color; } dxf_layer[NBCOLORS] = { { "BLACK", 7 }, // In DXF, color 7 is *both* white and black! { "GRAY1", 251 }, { "GRAY2", 8 }, { "GRAY3", 9 }, { "WHITE", 7 }, { "LYELLOW", 51 }, { "BLUE1", 178 }, { "GREEN1", 98 }, { "CYAN1", 138 }, { "RED1", 18 }, { "MAGENTA1", 228 }, { "BROWN1", 58 }, { "BLUE2", 5 }, { "GREEN2", 3 }, { "CYAN2", 4 }, { "RED2", 1 }, { "MAGENTA2", 6 }, { "BROWN2", 54 }, { "BLUE3", 171 }, { "GREEN3", 91 }, { "CYAN3", 131 }, { "RED3", 11 }, { "MAGENTA3", 221 }, { "YELLOW3", 2 }, { "BLUE4", 5 }, { "GREEN4", 3 }, { "CYAN4", 4 }, { "RED4", 1 }, { "MAGENTA4", 6 }, { "YELLOW4", 2 } }; for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) ) { fprintf( outputFile, " 0\n" "LAYER\n" " 2\n" "%s\n" // Layer name " 70\n" "0\n" // Standard flags " 62\n" "%d\n" // Color number " 6\n" "CONTINUOUS\n",// Linetype name dxf_layer[i].name, dxf_layer[i].color ); } // End of layer table, begin entities fputs( " 0\n" "ENDTAB\n" " 0\n" "ENDSEC\n" " 0\n" "SECTION\n" " 2\n" "ENTITIES\n", outputFile ); return true; }
/** * Opens the DXF plot with a skeleton header */ bool DXF_PLOTTER::StartPlot() { wxASSERT( outputFile ); // DXF HEADER - Boilerplate // Defines the minimum for drawing i.e. the angle system and the // 4 linetypes (CONTINUOUS, DOTDASH, DASHED and DOTTED) fputs( " 0\n" "SECTION\n" " 2\n" "HEADER\n" " 9\n" "$ANGBASE\n" " 50\n" "0.0\n" " 9\n" "$ANGDIR\n" " 70\n" " 1\n" " 9\n" "$MEASUREMENT\n" " 70\n" "0\n" " 0\n" // This means 'metric units' "ENDSEC\n" " 0\n" "SECTION\n" " 2\n" "TABLES\n" " 0\n" "TABLE\n" " 2\n" "LTYPE\n" " 70\n" "4\n" " 0\n" "LTYPE\n" " 5\n" "40F\n" " 2\n" "CONTINUOUS\n" " 70\n" "0\n" " 3\n" "Solid line\n" " 72\n" "65\n" " 73\n" "0\n" " 40\n" "0.0\n" " 0\n" "LTYPE\n" " 5\n" "410\n" " 2\n" "DASHDOT\n" " 70\n" "0\n" " 3\n" "Dash Dot ____ _ ____ _\n" " 72\n" "65\n" " 73\n" "4\n" " 40\n" "2.0\n" " 49\n" "1.25\n" " 49\n" "-0.25\n" " 49\n" "0.25\n" " 49\n" "-0.25\n" " 0\n" "LTYPE\n" " 5\n" "411\n" " 2\n" "DASHED\n" " 70\n" "0\n" " 3\n" "Dashed __ __ __ __ __\n" " 72\n" "65\n" " 73\n" "2\n" " 40\n" "0.75\n" " 49\n" "0.5\n" " 49\n" "-0.25\n" " 0\n" "LTYPE\n" " 5\n" "43B\n" " 2\n" "DOTTED\n" " 70\n" "0\n" " 3\n" "Dotted . . . .\n" " 72\n" "65\n" " 73\n" "2\n" " 40\n" "0.2\n" " 49\n" "0.0\n" " 49\n" "-0.2\n" " 0\n" "ENDTAB\n", outputFile ); // Text styles table // Defines 4 text styles, one for each bold/italic combination fputs( " 0\n" "TABLE\n" " 2\n" "STYLE\n" " 70\n" "4\n", outputFile ); static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"}; for(int i = 0; i < 4; i++ ) { fprintf( outputFile, " 0\n" "STYLE\n" " 2\n" "%s\n" // Style name " 70\n" "0\n" // Standard flags " 40\n" "0\n" // Non-fixed height text " 41\n" "1\n" // Width factor (base) " 42\n" "1\n" // Last height (mandatory) " 50\n" "%g\n" // Oblique angle " 71\n" "0\n" // Generation flags (default) " 3\n" // The standard ISO font (when kicad is build with it // the dxf text in acad matches *perfectly*) "isocp.shx\n", // Font name (when not bigfont) // Apply a 15 degree angle to italic text style_name[i], i < 2 ? 0 : DXF_OBLIQUE_ANGLE ); } // Layer table - one layer per color fprintf( outputFile, " 0\n" "ENDTAB\n" " 0\n" "TABLE\n" " 2\n" "LAYER\n" " 70\n" "%d\n", NBCOLORS ); /* The layer/colors palette. The acad/DXF palette is divided in 3 zones: - The primary colors (1 - 9) - An HSV zone (10-250, 5 values x 2 saturations x 10 hues - Greys (251 - 255) */ for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) ) { fprintf( outputFile, " 0\n" "LAYER\n" " 2\n" "%s\n" // Layer name " 70\n" "0\n" // Standard flags " 62\n" "%d\n" // Color number " 6\n" "CONTINUOUS\n",// Linetype name dxf_layer[i].name, dxf_layer[i].color ); } // End of layer table, begin entities fputs( " 0\n" "ENDTAB\n" " 0\n" "ENDSEC\n" " 0\n" "SECTION\n" " 2\n" "ENTITIES\n", outputFile ); return true; }