cinder::Surface ColorAlgoGen::mutate(const cinder::Surface& s) const { cinder::Surface mutateS = s.clone(); auto mSize = mutateS.getSize(); cinder::Vec2i pixelChoose(RANDOMIZER.nextUint(mSize.x), RANDOMIZER.nextUint(mSize.y)); mutateS.setPixel(pixelChoose, cinder::ColorA8u(static_cast<uint8_t>(RANDOMIZER.nextUint(255)), static_cast<uint8_t>(RANDOMIZER.nextUint(255)), static_cast<uint8_t>(RANDOMIZER.nextUint(255)), 255 )); return mutateS; }
cinder::Surface ColorAlgoGen::crossOver(const cinder::Surface& s1, const cinder::Surface& s2) const { cinder::Surface crossOver = s1.clone(); auto s1Iter = crossOver.getIter(); auto s2Iter = s2.getIter(); while (s1Iter.line() && s2Iter.line()) { while (s1Iter.pixel() && s2Iter.pixel()) { if(RANDOMIZER.nextBool()) { s1Iter.r() = s2Iter.r(); s1Iter.g() = s2Iter.g(); s1Iter.b() = s2Iter.b(); } } } return crossOver; }