class CrossOver { CrossOver() { } PGraphics crossover(PGraphics momg, PGraphics dadg) { PGraphics child = createGraphics(32, 32, JAVA2D); child.beginDraw(); child.image(momg, 0, 0); child.blend(dadg, 0, 0, 32, 32, 0, 0, 32, 32, BLEND); child.endDraw(); return child; } } class Stripes extends CrossOver { PGraphics crossover(PGraphics momg, PGraphics dadg) { PGraphics child = createGraphics(32, 32, JAVA2D); child.beginDraw(); child.image(momg, 0, 0); for (int i = 0; i < 32; i += 8) { child.copy(dadg, 0, i, 32, 4, 0, i, 32, 4); } child.endDraw(); return child; } } class HalfAndHalf extends CrossOver { PGraphics crossover(PGraphics momg, PGraphics dadg) { PGraphics child = createGraphics(32, 32, JAVA2D); child.beginDraw(); child.image(momg, 0, 0); child.copy(dadg, 0, 0, 32, 16, 0, 0, 32, 16); child.endDraw(); return child; } } class PixelByPixel extends CrossOver { PGraphics crossover(PGraphics momg, PGraphics dadg) { PGraphics child = createGraphics(32, 32, JAVA2D); child.beginDraw(); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { // if (noise(i/8f, j/8f) > 0.5) { if (random(1) > 0.5) { child.set(i, j, momg.get(i, j)); } else { child.set(i, j, dadg.get(i, j)); } } } child.endDraw(); return child; } } class Spot extends CrossOver { PGraphics crossover(PGraphics momg, PGraphics dadg) { PGraphics child = createGraphics(32, 32, JAVA2D); PGraphics buff = createGraphics(32, 32, JAVA2D); // draw a white spot on a black background in buff buff.beginDraw(); buff.smooth(); buff.noStroke(); buff.fill(255); buff.ellipse(16, 16, 20, 20); buff.endDraw(); child.beginDraw(); child.image(momg, 0, 0); PImage p = dadg.get(0, 0, 32, 32); p.mask(buff); child.image(p, 0, 0); child.endDraw(); return child; } }