// For now, this just directly puts them into 'frags' void Board::randomizeRow(unsigned int i) { unsigned int maxInt = 8; // the higher, the more blank spaces //maxInt = 400; // good to keep whole pieces separate // maxInt = 8; // good for individual squares PRNG* rng = Tetris::TApp::theApp->rng; int j = rng->uniform() % clms; auto k = nFromIJ(i, j); unsigned int pi = rng->uniform() % maxInt; TCode p = ((1 <= pi) && (pi <= 7)) ? ((TCode)pi) : N; if (N != p) { Shape s = Shape(p); s.setRandomShape(); bool ok = testShape(s, i, j); if (ok) { placeShape(s,i,j); s.showCoords(); cout << endl << flush; } } return; }
void HistogramImage::render(std::vector<unsigned char> &rgb, double scale, double exponent) { // Tone mapping from 64-bit-per-channel to 8-bit-per-channel, with dithering. PRNG rng; rng.seed(0); unsigned i = 0; unsigned e = mWidth * mHeight * kChannels; rgb.resize(e); for (; i != e; ++i) { double u = std::max(0.0, mCounts[i] * scale); double dither = rng.uniform(); double v = 255.0 * pow(u, exponent) + dither; rgb[i] = std::max(0.0, std::min(255.9, v)); } }