void GradientLayer::drawGradient(Graphics* const TheGraphics, const Pnt2f& Origin, const Vec2f& Size, const Vec2f& UAxis, const Real32& Start, const Real32& End, const Real32& Opacity) const { glPushMatrix(); Matrix Transformation; Transformation.setTransform(Vec3f(Origin.x()+Start*UAxis.x()*Size.x(), Origin.y()+Start*UAxis.y()*Size.x(),0.0f), Quaternion(Vec3f(1.0f,0.0f,0.0f),Vec3f(UAxis.x(), UAxis.y(), 0.0f)), Vec3f(Size.x()*(End-Start), Size.y(),0.0f)); glMultMatrixf(Transformation.getValues()); if (osgMin(getMFColors()->size(),getMFStops()->size()) > 1) { if(getMFColors()->size() != getMFStops()->size()) { SWARNING << "GradientLayer::drawGradient: The number of colors and the number of stops are not equal." << std::endl; } UInt32 NumStops = osgMin(getMFColors()->size(),getMFStops()->size()); Real32 CurentRelaviteStop= 0.0f; for(UInt32 i(0) ; i<NumStops-1 ; ++i) { TheGraphics->drawQuad(Pnt2f(getStops(i),0.0f), Pnt2f(getStops(i+1),0.0f), Pnt2f(getStops(i+1),1.0f), Pnt2f(getStops(i),1.0f), getColors(i), getColors(i+1), getColors(i+1), getColors(i), Opacity); } } glPopMatrix(); }
void Palette::savePal(const std::string &file) const { std::ofstream out(file.c_str(), std::ios::out | std::ios::binary); short count = _count; // RIFF header out << "RIFF"; int length = 4 + 4 + 4 + 4 + 2 + 2 + count * 4; out.write((char*) &length, sizeof(length)); out << "PAL "; // Data chunk out << "data"; int data = count * 4 + 4; out.write((char*) &data, sizeof(data)); short version = 0x0300; out.write((char*) &version, sizeof(version)); out.write((char*) &count, sizeof(count)); // Colors SDL_Color *color = getColors(); for (short i = 0; i < count; ++i) { char c = 0; out.write((char*) &color->r, 1); out.write((char*) &color->g, 1); out.write((char*) &color->b, 1); out.write(&c, 1); color++; } out.close(); }
//色付文字を出力 DWORD Console::outputString(int foreground,int background,const TCHAR* fmt,...){ DWORD written_chars=0; if(fmt==NULL)return written_chars; int orig_colors=getColors(); if(!isRedirected()){ //色設定を変更する if(foreground!=NONE)setFGColor(foreground); if(background!=NONE)setBGColor(background); } va_list argp; va_start(argp,fmt); write(fmt,argp,&written_chars); va_end(argp); if(!isRedirected()){ //色設定を元に戻す setColors(orig_colors); } return written_chars; }
void plSpanInstance::prcWrite(pfPrcHelper* prc) { prc->writeSimpleTag("plSpanInstance"); prc->writeTagNoBreak("Local2World"); prc->directWrite( ST::format("[ {_0.4f}, {_0.4f}, {_0.4f}, {_0.4f} " "; {_0.4f}, {_0.4f}, {_0.4f}, {_0.4f} " "; {_0.4f}, {_0.4f}, {_0.4f}, {_0.4f} ]", fL2W[0][0], fL2W[0][1], fL2W[0][2], fL2W[0][3], fL2W[1][0], fL2W[1][1], fL2W[1][2], fL2W[1][3], fL2W[2][0], fL2W[2][1], fL2W[2][2], fL2W[2][3])); prc->closeTagNoBreak(); prc->writeSimpleTag("PosDeltas"); std::vector<hsVector3> verts = getPosDeltas(); for (size_t i=0; i<verts.size(); i++) verts[i].prcWrite(prc); prc->closeTag(); prc->writeSimpleTag("Colors"); std::vector<unsigned int> colors = getColors(); for (size_t i=0; i<colors.size(); i++) { prc->startTag("Color"); prc->writeParamHex("value", colors[i]); prc->endTag(true); } prc->closeTag(); prc->closeTag(); }
int main(int argc, char *argv[]) { char *iim, *idb, * oim; ObjectDB newobjs, known; Image im; if (argc != 4) { fprintf(stderr, "usage: %s <input labeled image> <input database> <output image>", argv[0]); } iim=argv[1]; idb=argv[2]; oim=argv[3]; readImage(&im, iim); readDatabase(&known, idb); /* get the database of known objects */ makeODB(&newobjs, getColors(&im)); /* create the database for the input image */ getObjects(&im, &newobjs); /* fill the database for the input image */ filterObjects(&im, &newobjs, &known); /* find known objects in the database and throw away those unknown */ drawLines(&im, &newobjs); /* draw lines in the input image */ writeImage(&im, oim); /* write the output image */ free(newobjs.objs); free(known.objs); free(im.data); return 0; }
Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { _oldColors = NULL; _newColors = NULL; _showQ = new Queue(true); _spareQ = new Queue(false); _sysPal = new Dac[kPalCount]; for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } #if 0 // This part was used to display credits at the beginning of the game for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { debugN(1, "%s\n", text); } } #endif _oldColors = (Dac *)malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *)malloc(sizeof(Dac) * kPalCount); getColors(_oldColors); sunset(); setColors(); clear(0); }
int main(int argc, char *argv[]) { char *ifname, *odname, *ofname; ObjectDB odb; Image im; if (argc < 4) { fprintf(stderr, "usage: %s <input labeled image> <output database> <output image>", argv[0]); return 1; } ifname=argv[1]; odname=argv[2]; ofname=argv[3]; readImage(&im, ifname); makeODB(&odb, getColors(&im)); getObjects(&im, &odb); writeDatabase(&odb, odname); drawLines(&im, &odb); writeImage(&im, ofname); free(odb.objs); free(im.data); return 0; }
int getPallet(PALLET* pal, FILE* fp) { if (getHeader(&pal->header, fp) == 0) return 3; if (isBMP(&pal->header) == 0) return 4; if (getInfo(pal, fp) == 0) return 5; if (getColors(pal, fp) == 0) return 6; return 0; }
void NgonGeneralData::getDataProperty(int property, void **_pvData) { switch (property) { case NUM_ELEMENTS_ARRAY : /* Not implemented yet */ // getNumElementsArray(); break; case COORDINATES : *_pvData = getData(); break; case X_COORDINATES : *_pvData = getDataX(); break; case Y_COORDINATES : *_pvData = getDataY(); break; case Z_COORDINATES : *_pvData = getDataZ(); break; case COLORS : *_pvData = getColors(); break; case NUM_COLORS : ((int *) *_pvData)[0] = getNumColors(); break; default : NgonData::getDataProperty(property, _pvData); } }
void VCSColorsConfigWidget::slotAccept() { VCSColors selectedColors; getColors( selectedColors ); m_part->vcsColors = selectedColors; }
int main(int ac, char **av) { ll_node *head; int steps, i; t_map map; /* Get user input */ head = getColors(); if (!head) return (0); steps = atoi(readLine(0)); /* Init the map */ map.nodes = malloc(sizeof(ll_node *) * WIDTH * HEIGHT); map.x_ant = WIDTH / 2; map.y_ant = HEIGHT / 2; map.dir = 0; for (i = 0; i < WIDTH * HEIGHT; ++i) { map.nodes[i] = head; } map.nodes[i] = NULL; while (steps--) moveAnt(&map); printMap(map.nodes); }
void plSpanInstance::prcWrite(pfPrcHelper* prc) { prc->writeSimpleTag("plSpanInstance"); prc->writeTagNoBreak("Local2World"); prc->getStream()->writeStr( plString::Format("[ %.04f, %.04f, %.04f, %.04f " "; %.04f, %.04f, %.04f, %.04f " "; %.04f, %.04f, %.04f, %.04f ]", fL2W[0][0], fL2W[0][1], fL2W[0][2], fL2W[0][3], fL2W[1][0], fL2W[1][1], fL2W[1][2], fL2W[1][3], fL2W[2][0], fL2W[2][1], fL2W[2][2], fL2W[2][3])); prc->closeTagNoBreak(); prc->writeSimpleTag("PosDeltas"); hsTArray<hsVector3> verts = getPosDeltas(); for (size_t i=0; i<verts.getSize(); i++) verts[i].prcWrite(prc); prc->closeTag(); prc->writeSimpleTag("Colors"); hsTArray<unsigned int> colors = getColors(); for (size_t i=0; i<colors.getSize(); i++) { prc->startTag("Color"); prc->writeParamHex("value", colors[i]); prc->endTag(true); } prc->closeTag(); prc->closeTag(); }
void Vga::sunset() { Dac tab[256]; getColors(tab); for (int i = 64; i >= 0; i -= kFadeStep) { setColors(tab, i); waitVR(); updateColors(); } }
vector<ofColor> ofxColourTheory::getRange(vector<ofColor> cols, int num, float variance, ofVec2f hueConstraint,ofVec2f saturationConstraint,ofVec2f brightnessConstraint,ofVec2f alphaConstraint) { vector<ofColor> list; int numPerRange = (int)floor(float(num/cols.size())); for (int i = 0; i < cols.size()-1; i++) { //check out this vector concat! //todo..fix vector length vector<ofColor> b = getColors(cols[i],numPerRange,variance,hueConstraint,saturationConstraint,brightnessConstraint,alphaConstraint); list.insert(list.end(), b.begin(), b.end()); } //add last to fill unevenly split range, eg. 33,33,33,34 to get 100 int i = cols.size()-1; int remainingNum = numPerRange + num-numPerRange*cols.size(); // ofLog()<<"numPerRange "<<numPerRange<<" remainingNum "<<remainingNum<<endl; vector<ofColor> b = getColors(cols[i],remainingNum,variance,hueConstraint,saturationConstraint,brightnessConstraint,alphaConstraint); list.insert(list.end(), b.begin(), b.end()); return list; }
void CThemes::readFile(char* themename) { if(themefile.loadConfig(themename)) { getColors(themefile); colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL); hasThemeChanged = true; } else printf("[neutrino theme] %s not found\n", themename); }
int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); buildUrl(); getColors(); RestClient client; Runner r; TestRunner* runner = getColorsAsync(client); QObject::connect(runner, SIGNAL(done()), &r, SLOT(run())); return a.exec(); }
/* Draw the minimum second moment of every object in the database */ void drawLines(Image *im, ObjectDB *odb) { double i, j; Object *obj; int k, b, h, d; setColors(im, getColors(im)+1); /* add new level for lines */ for (k=0; k < odb->nObjects; ++k) { obj=odb->objs+k; b=obj->right - obj->left; h=obj->bottom - obj->top; d=sqrt(b*b+h*h)/2.0; i=d*sin(obj->sm.thetaMin); j=d*cos(obj->sm.thetaMin); line(im, obj->fm[0] - i, obj->fm[1] - j, obj->fm[0] + i, obj->fm[1] + j, getColors(im)-1); } }
void ofxMesh::fromMesh(const ofMesh & mesh){ if (mesh.hasVertices()) { getVertices()=mesh.getVertices(); } if (mesh.hasColors()) { getColors()=mesh.getColors(); } if (mesh.hasNormals()) { getNormals()=mesh.getNormals(); } if (mesh.hasTexCoords()) { getTexCoords()=mesh.getTexCoords(); } if (mesh.hasIndices()) { getIndices()=mesh.getIndices(); } }
void plot3D(std::vector<std::vector<std::vector<double> > > datas, std::vector<std::string> names, const std::string xlabel, const std::string ylabel, const std::string zlabel, const std::string style) { Gnuplot gp; gp << "reset\n"; gp << "set xlabel '" << xlabel << "'\n"; gp << "set ylabel '" << ylabel << "'\n"; gp << "set zlabel '" << zlabel << "'\n"; // z-Achsen Offset ausschalten gp << "set ticslevel 0\n"; gp << "set tics out nomirror\n"; gp << "set autoscale\n"; gp << "set view equal xyz\n"; gp << "set key noenhanced\n"; // Farben std::vector<std::string> colors = getColors(); // Plotstring bauen und an Gnuplot schicken std::stringstream plotstring; plotstring << "splot "; for (unsigned i = 0; i < datas.size(); i++) { plotstring << "'-' " << style << " lt rgb '" << colors[i] << "' t '" << names[i] << "'"; if (i != datas.size() - 1) { plotstring << ","; } } gp << plotstring.str() << "\n"; // Daten senden for (std::vector<std::vector<std::vector<double> > >::iterator data = datas.begin(); data != datas.end(); ++data) { gp.send1d(*data); } std::cout << "Continue with Enter." << std::endl; std::cin.get(); }
void ofxMesh::toMesh(ofMesh & mesh){ mesh.clear(); if (hasVertices()) { mesh.getVertices()=getVertices(); } if (hasColors()) { mesh.getColors()=getColors(); } if (hasNormals()) { mesh.getNormals()=getNormals(); } if (hasTexCoords()) { mesh.getTexCoords()=getTexCoords(); } if (hasIndices()) { mesh.getIndices()=getIndices(); } }
Picture Picture::operator -(Picture const& pic) const { if (pic.getColors() != getColors() || pic.getHeight() != getHeight() || pic.getWidth() != getWidth()) return Picture(0, 0); Picture res = pic.clone(); for (int c = 0; c < colors; ++c) { for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int sum = pic.get(i, j, c); sum -= get(i, j, c); sum += 256; res.at(i, j, c) = (unsigned char) (sum % 256); } } } return res; }
int writeImage(const Image *im, const char *fname) { FILE *output; int nRows; int nCols; int colors; int i, j; /* open the file */ if (!fname || (output=fopen(fname,"wb"))==0) return(-1); nRows=getNRows(im); nCols=getNCols(im); colors=getColors(im); /* write the header */ fprintf(output,"P5\n"); /* magic number */ fprintf(output,"#\n"); /* empty comment */ fprintf(output,"%d %d\n%03d\n",nCols,nRows,colors); /* image info */ /* write pixels row by row */ for(i=0;i<nRows;i++) { for(j=0;j<nCols;j++) { int byte=getPixel(im,i,j); if (fputc(byte,output)==EOF) /* couldn't write */ { fclose(output); return -1; } } } /* close the file */ fclose(output); return 0; /* OK */ }
displayStatus::displayStatus(UIObject& parent, int max): UIObject("displayStatus", parent, xmFrameWidgetClass, XmNshadowType, XmSHADOW_ETCHED_IN, XmNmarginWidth, 2, XmNmarginHeight, 2, NULL) { XColor fgclr, bgclr; allocColor("Linen", &fgclr); allocColor("PaleVioletRed3", &bgclr); Pixel fgRet, top, bottom, select; getColors(bgclr.pixel, &fgRet, &top, &bottom, &select); setValues(XmNforeground, fgclr.pixel, XmNbackground, bgclr.pixel, XmNtopShadowColor, top, XmNbottomShadowColor, bottom, XmNborderColor, fgRet, XmNwidth, 400, NULL); maxLength = max; dpyLabel = new UIObject("hello", *this, xmLabelWidgetClass, NULL); dpyLabel->allocColor("Linen", &fgclr); dpyLabel->allocColor("PaleVioletRed3", &bgclr); dpyLabel->getColors(bgclr.pixel, &fgRet, &top, &bottom, &select); dpyLabel->setValues(XmNforeground, fgclr.pixel, XmNbackground, bgclr.pixel, XmNtopShadowColor, top, XmNbottomShadowColor, bottom, XmNselectColor, select, XmNarmColor, select, XmNborderColor, fgRet, NULL); }
// Set background color void setBackgroundColor () { // Call the color picker dialog static COLORREF arrayColor[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; getColors (arrayColor); // Reset the struct CHOOSECOLOR cc; memset (&cc, 0, sizeof(CHOOSECOLOR)); // Fill the struct cc.lStructSize=sizeof(CHOOSECOLOR); cc.rgbResult=backGround; cc.lpCustColors=arrayColor; cc.Flags=CC_RGBINIT|CC_ANYCOLOR|CC_FULLOPEN; // Open it if (ChooseColor (&cc)) { // Set the color backGround=cc.rgbResult; setColors (arrayColor); } }
Console::Console(DWORD handle_type): m_handle(::GetStdHandle(handle_type)), m_is_redirected(false), m_orig_colors(0), io_buffer_size(2048) #ifdef UNICODE ,m_ansi_mode(false) #endif { #ifdef _DEBUG //VS2015でビルドすると、環境によっては_tsetlocale()でハングアップしてしまう? _tsetlocale(LC_ALL,_tsetlocale(LC_CTYPE,_T(""))); #endif { //リダイレクトされているかどうか DWORD mode=0; CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; m_is_redirected=(handle_type==STD_INPUT_HANDLE)? !getConsoleMode(&mode) :!::GetConsoleScreenBufferInfo(m_handle,&screen_buffer_info); m_orig_colors=getColors(); } }
void plot1D(std::vector<std::vector<std::vector<double> > > data, std::vector<std::string> names, const std::string xlabel, const std::string ylabel, const std::string style) { Gnuplot gp; gp << "reset\n"; gp << "set xlabel '" << xlabel << "'\n"; gp << "set ylabel '" << ylabel << "'\n"; gp << "set key noenhanced\n"; // Farben std::vector<std::string> colors = getColors(); // Plotstring bauen und an Gnuplot schicken std::stringstream plotstring; plotstring << "plot "; for (unsigned i = 0; i < data.size(); i++) { plotstring << "'-' " << style << " lt rgb '" << colors[i] << "' t '" << names[i] << "'"; if (i != data.size() - 1) { plotstring << ","; } } gp << plotstring.str() << "\n"; // Daten senden for (std::vector<std::vector<std::vector<double> > >::iterator dat = data.begin(); dat != data.end(); ++dat) { gp.send1d(*dat); // TODO: end points ge connected... why? } std::cout << "Continue with Enter." << std::endl; std::cin.get(); }
bool CardStat::hasColor(Color color) const { return getColors().hasColor(color); }
void plotHyperuniformity(std::vector<std::vector<std::vector<double> > > datas, double xMax, std::vector<std::string> names, const std::string xlabel, const std::string ylabel, const std::string file) { double xMin = 0; // get filename std::stringstream filestream; filestream << "tee " << file; for (std::vector<std::string>::iterator name = names.begin(); name != names.end(); ++name) { std::cout << (*name) << "\n"; (*name).erase(std::remove((*name).begin(), (*name).end(), ' '), (*name).end()); std::cout << (*name) << "\n"; filestream << "_" << *name; } filestream << ".gp | gnuplot -persist"; Gnuplot gp(filestream.str()); gp << "reset\n"; gp << "set fit logfile '/dev/null'\n"; gp << "set key top left\n"; gp << "set xrange [" << xMin << ":" << xMax << "]\n"; gp << "set yrange [0:]\n"; //gp << "set offset graph 0.05,0.05,0.05,0.0\n"; // 10 x-tics gp << "set xtics " << xMin << ",1," << xMax << "\n"; gp << "set tics out nomirror\n"; gp << "set xlabel '" << xlabel << "'\n"; gp << "set ylabel '" << ylabel << "'\n"; std::vector<std::string> colors = getColors(); std::stringstream plotstring; for (unsigned i = 0; i < datas.size(); i++) { gp << "A" << i << " = 1\n"; gp << "B" << i << " = 2\n"; gp << "f" << i << "(x) = A" << i << "*x**B" << i << "\n"; gp << "fit [0:" << xMax << "] f" << i << "(x) '-' u 1:2 via A" << i << "\n"; // , B" << i << " gp.send1d(datas[i]); if (i == 0) { plotstring << "plot "; } // '-' means read from stdin. The send1d() function sends data to gnuplot's stdin. plotstring << "'-' u 1:2 ls 7 lc rgb'" << colors[i] << "' t 'variance " << names[i] << "', f" << i << "(x) lc rgb'" << colors[i] << "' t sprintf('fit: f_" << i << "(R) = %.3fR^{%.1f}',A" << i // {\264} << ", B" << i << ")"; if (i != datas.size() - 1) { plotstring << ","; } } gp << plotstring.str() << "\n"; // Daten senden for (std::vector<std::vector<std::vector<double> > >::iterator data = datas.begin(); data != datas.end(); ++data) { gp.send1d(*data); } //gp(fopen("script.gp", "w")); // For Windows, prompt for a keystroke before the Gnuplot object goes out of scope so that // the gnuplot window doesn't get closed. std::cout << "Continue with Enter." << std::endl; std::cin.get(); }
STDMETHODIMP CVisComplexObj::get_colors(VARIANT *pVal) { VariantFromDoubleArray(getColors(), pVal); return S_OK; }
void plotHist(std::vector<std::vector<double> > datas, double min, double max, int n, std::vector<std::string> names, const std::string xlabel, const std::string file) { // get filename std::stringstream filestream; filestream << "tee " << file; for (std::vector<std::string>::iterator name = names.begin(); name != names.end(); ++name) { std::string filename = (*name); filename.erase(std::remove(filename.begin(), filename.end(), ' '), filename.end()); filestream << "_" << filename; } filestream << ".gp | gnuplot -persist"; Gnuplot gp(filestream.str()); // statistics as comments in file for (unsigned i = 0; i < datas.size(); i++) { gp << "# " << xlabel << " of pattern '" << names[i] << "'. Statistics: " << std::endl; gp << statsAsString(stats(datas[i]), "# ") << std::endl; } // Don't forget to put "\n" at the end of each line! gp << "reset\n"; gp << "n=" << n << "\n"; gp << "max=" << max << "\n"; gp << "min=" << min << "\n"; gp << "width=" << (max - min) / n << "\n"; gp << "hist(x,width)=width*floor(x/width) #+width/2.0\n"; gp << "set xrange [min:max]\n"; gp << "set yrange [0:]\n"; //gp << "set offset graph 0.05,0.05,0.05,0.0\n"; // 10 x-tics gp << "set xtics min," << (max - min) / 10 << ",max\n"; gp << "set boxwidth width*0.9\n"; gp << "set style fill solid 0.5\n"; gp << "set tics out nomirror\n"; gp << "set key left\n"; gp << "set xlabel '" << xlabel << "'\n"; gp << "set ylabel 'frequency'\n"; std::vector<std::string> colors = getColors(); // build plotstring and send to gnuplot std::stringstream plotstring; plotstring << "plot "; for (unsigned i = 0; i < datas.size(); i++) { // '-' means read from stdin plotstring << "'-' u (hist($1, width)):(1.0/" << datas[i].size() << ") w boxes smooth freq lc rgb '" << colors[i] << "' t '" << names[i] << "'"; if (i != datas.size() - 1) { plotstring << ","; } } gp << plotstring.str() << "\n"; // Daten senden for (std::vector<std::vector<double> >::iterator data = datas.begin(); data != datas.end(); ++data) { // The send1d() function sends data to gnuplot's stdin. gp.send1d(*data); } // For Windows, prompt for a keystroke before the Gnuplot object goes out of scope so that // the gnuplot window doesn't get closed. std::cout << "Continue with Enter." << std::endl; std::cin.get(); }