-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cf9ae7c
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Improach | ||
Improach takes an input image and approaches that image from a random-pixel image. | ||
<br>I (Wertzui123) have basically written this implementation in 30 minutes for fun back in 2022. | ||
|
||
<img src="./preview.png"></img> | ||
|
||
## Known issues | ||
* The original will be ever-approached, but never really reached (except when the difference drops below 1 maybe) | ||
* The performance is currently not very good |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import graphics | ||
import io | ||
import os | ||
import console | ||
|
||
var int iterations = 10 | ||
var originalFile = "original.png" | ||
if(os.args().length > 1){ | ||
originalFile = os.args()[1] | ||
} | ||
if(!io.exists_file(originalFile)){ | ||
print(console.red("No file called '" + originalFile + "' found!")) | ||
exit(2) | ||
} | ||
// TODO: Support such things: var approachFile = "approach.png" | ||
|
||
var Canvas original = Canvas:fromFile(originalFile) | ||
var Canvas approach = new Canvas(original.width, original.height) | ||
|
||
if(!io.exists_directory("out")){ | ||
io.create_directory("out") | ||
} | ||
|
||
repeat(approach.height, y = 0){ | ||
repeat(approach.width, x = 0){ | ||
approach.setPixel(x, y, Color:random()) | ||
} | ||
} | ||
approach.save("out/0.png") | ||
|
||
repeat(iterations, i = 1){ | ||
repeat(approach.height, y = 0){ | ||
repeat(approach.width, x = 0){ | ||
var oc = original.getPixel(x, y) | ||
var ac = approach.getPixel(x, y) | ||
|
||
var diffA = oc.a - ac.a | ||
var diffR = oc.r - ac.r | ||
var diffG = oc.g - ac.g | ||
var diffB = oc.b - ac.b | ||
|
||
approach.setPixel(x, y, new Color( | ||
byte(ac.a + diffA / float(iterations)), | ||
byte(ac.r + diffR / float(iterations)), | ||
byte(ac.g + diffG / float(iterations)), | ||
byte(ac.b + diffB / float(iterations)) | ||
)) // TODO: Maybe the last iteration should be the original? | ||
} | ||
} | ||
approach.save("out/" + i + ".png") | ||
} | ||
|
||
var Canvas total = new Canvas(approach.width * (iterations + 1), approach.height) | ||
repeat(iterations + 1, i = 0){ | ||
var img = Canvas:fromFile("out/" + i + ".png") | ||
repeat(approach.height, y = 0){ | ||
repeat(approach.width, x = 0){ | ||
total.setPixel(x + i * approach.width, y, img.getPixel(x, y)) | ||
} | ||
} | ||
} | ||
total.save("out/total.png") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.