int main(void) { clearscreen(); position(5, 20); textcolor(RED); backcolor(BLUE); texteffect(BOLD); printf(" Hello "); position(15, 55); backcolor(RED); textcolor(WHITE); texteffect(FAINT); printf(" World "); textcolor(DEFAULT); texteffect(NORMAL); printf("\n\n\n"); }
void consolColor_Init(void) { #ifndef UBUNTU console_textColor = textcolor(); // console_textColor = 0x0E; console_backgroundColor = backcolor(); #endif // //log // printf("[%s:%d] color init => textcolor=%d, backcolor=%d\n", // base_name(__FILE__), __LINE__, // console_textColor, // console_backgroundColor); }
void generateBackground(HumdrumFile& infile, int rfactor, Array<PixelRow>& picturedata, Array<PixelRow>& background) { background.setSize(picturedata.getSize()); int i, j; PixelColor backcolor(bgcolor); for (i=0; i<picturedata.getSize(); i++) { background[i].setSize(picturedata[i].getSize()); for (j=0; j<picturedata[i].getSize(); j++) { background[i][j] = backcolor; } } PixelColor whitekeys(keyboardcolor); if (keyboardQ) { for (i=0; i<background.getSize(); i++) { switch (i % 12) { case 0: case 2: case 4: case 5: case 7: case 9: case 11: for (j=0; j<background[i].getSize(); j++) { background[i][j] = whitekeys; } break; } } } int index; int min = infile.getMinTimeBase(); PixelColor measureColor; measureColor.setColor(25, 25, 25); for (i=0; i<infile.getNumLines(); i++) { if (infile[i].isMeasure()) { index = (int)(infile[i].getAbsBeat() * min / 4.0 * rfactor); for (j=0; j<background.getSize(); j++) { background[j][index] = measureColor; } } } }
int ImportDiagram::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3MainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: createMdiChild(); break; case 1: timerEvent(); break; case 2: showTable(); break; case 3: showSelector(); break; case 4: screenshort(); break; case 5: refresh(); break; case 6: backcolor(); break; case 7: legendIsClicked((*reinterpret_cast< QwtPlotItem*(*)>(_a[1]))); break; case 8: onAutoscale((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 9; } return _id; }
int generatePicture(HumdrumFile& infile, Array<PixelRow>& picture, int style) { Array<char> marks; getMarkChars(marks, infile); PixelColor matchcolor(255,255,255); infile.analyzeRhythm("4"); int min = infile.getMinTimeBase(); double totaldur = infile.getTotalDuration(); int columns = (int)(totaldur * min / 4.0 + 0.5) + 5; if (columns > 50000) { cout << "Error: picture will be too big to generate" << endl; exit(1); } int factor = (int)(maxwidth / columns); if (factor <= 0) { factor = 1; } if (factor > maxfactor) { factor = maxfactor; } // set picture to black first. Black regions will be filled in // with the background later. picture.setSize(128); int i, j, k; PixelColor backcolor(bgcolor); for (i=0; i<picture.getSize(); i++) { picture[i].setSize(columns * factor); for (j=0; j<picture[i].getSize(); j++) { picture[i][j] = backcolor; // picture[i][j].setRed(0); // picture[i][j].setGreen(0); // picture[i][j].setBlue(0); } } // examine metric levels for metric coloration Array<int>rhylev; infile.analyzeMetricLevel(rhylev); for (i=0; i<rhylev.getSize(); i++) { // reverse sign so that long notes are positive. rhylev[i] = -rhylev[i]; } PixelColor color; int minpitch = 128; int maxpitch = -1; int pitch = 0; double duration = 0; double start = 0; char buffer[1024] = {0}; for (i=0; i<infile.getNumLines(); i++) { if (debugQ) { cout << "Processing input line " << i + 1 << '\t' << infile[i] << endl; } if (infile[i].isData()) { start = infile[i].getAbsBeat(); for (j=0; j<infile[i].getFieldCount(); j++) { if (strcmp(infile[i].getExInterp(j), "**kern") != 0) { continue; } // duration = Convert::kernToDuration(infile[i][j]); duration = infile.getTiedDuration(i, j); color = makeColor(infile, i, j, style, rhylev, infile[i].getPrimaryTrack(j)); for (k=0; k<infile[i].getTokenCount(j); k++) { infile[i].getToken(buffer, j, k); if (strchr(buffer, '_') != NULL) { continue; } if (strchr(buffer, ']') != NULL) { continue; } pitch = Convert::kernToMidiNoteNumber(buffer); if (pitch < 0) { // ignore rests continue; } if (pitch < minpitch) { minpitch = pitch; } if (pitch > maxpitch) { maxpitch = pitch; } if (isMatch(marks, buffer)) { placeNote(picture, pitch, start, duration, min, color, factor, 1); } else { placeNote(picture, pitch, start, duration, min, color, factor, 0); } } } } } gmaxpitch = maxpitch; gminpitch = minpitch; return factor; }
void printPicture(Array<PixelRow>& picturedata, Array<PixelRow>& background, int rfactor, int cfactor, int minp, int maxp, HumdrumFile& infile) { if (minp > 0) { minp--; } if (maxp < 127) { maxp++; } int i, j; int m; int width = picturedata[0].getSize(); int height = (maxp - minp + 1); cfactor = (int)(maxheight / height); if (cfactor <= 0) { cfactor = 1; } if (cfactor > maxfactor) { cfactor = maxfactor; } PixelColor temp; PixelColor black(0,0,0); PixelColor backcolor(bgcolor); height = cfactor * height; if (P3Q) { cout << "P3\n" << width << " " << height << "\n255\n"; } else { cout << "P6\n" << width << " " << height << "\n255\n"; } for (i=maxp; i>=minp; i--) { for (m=0; m<cfactor; m++) { for (j=0; j<picturedata[i].getSize(); j++) { if (picturedata[i][j] == backcolor) { if (P3Q) { background[i][j].writePpm3(cout); } else { background[i][j].writePpm6(cout); } } else { if ((i > 0) && (cfactor > 1) && (m == cfactor-1) && (picturedata[i-1][j] == picturedata[i][j])) { temp = picturedata[i][j] * 0.667; if (P3Q) { temp.writePpm3(cout); } else { temp.writePpm6(cout); } } else { if (P3Q) { picturedata[i][j].writePpm3(cout); } else { picturedata[i][j].writePpm6(cout); } } } } if (P3Q) { cout << "\n"; } } } }