Skip to content

Commit 977be8b

Browse files
knowlton sketch
1 parent 934e118 commit 977be8b

17 files changed

+290
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
void draw() {
3+
4+
currentVideo = getVideo([[videoNum]]).draw();
5+
6+
for (int i = 0; i < [[iterations]]; i++) {
7+
8+
if (random() < [[mixRatio]]) {
9+
targetImage = currentVideo;
10+
} else {
11+
targetImage = originalImage;
12+
}
13+
14+
for (int i = 0; i < imageWidth; i++) {
15+
for (int j = 0; j < imageHeight; j++) {
16+
17+
int randX = random(0, imageWidth);
18+
int randY = random(0, imageHeight);
19+
20+
// randomly swap a pixel
21+
sourceImageAfterSwap = sourceImage.swapPixels(i,j, randX, randY);
22+
23+
if (distanceToOriginal(sourceImageAfterSwap) <
24+
distanceToOriginal(sourceImage)) {
25+
sourceImage = sourceImageAfterSwap;
26+
}
27+
}
28+
}
29+
30+
31+
}
32+
sourceImage.draw();
33+
}
601 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)