mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-12-22 02:17:33 +00:00
Remove old blend functions
This commit is contained in:
parent
df6c27924b
commit
f5693b96f1
@ -85,121 +85,3 @@ func (b BlendMethodMedian) Draw(tiles []*ImageTile, destImage *image.RGBA) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*// BlendNewestPixel takes the given tiles and only draws the newest pixel (based on file modification time) of any overlapping tiles.
|
||||
func BlendNewestPixel(tiles []*ImageTile, destImage *image.RGBA) {
|
||||
bounds := destImage.Bounds()
|
||||
|
||||
// Sort tiles by date.
|
||||
sort.Slice(tiles, func(i, j int) bool { return tiles[i].modTime.After(tiles[j].modTime) })
|
||||
|
||||
// List of images corresponding with every tile.
|
||||
// Can contain empty/nil entries for images that failed to load.
|
||||
images := []*image.RGBA{}
|
||||
for _, tile := range tiles {
|
||||
images = append(images, tile.GetImage())
|
||||
}
|
||||
|
||||
for iy := bounds.Min.Y; iy < bounds.Max.Y; iy++ {
|
||||
for ix := bounds.Min.X; ix < bounds.Max.X; ix++ {
|
||||
point := image.Point{ix, iy}
|
||||
found := false
|
||||
|
||||
// Look for first valid pixel in stack of tiles.
|
||||
var col color.RGBA
|
||||
for _, img := range images {
|
||||
if img != nil {
|
||||
if point.In(img.Bounds()) {
|
||||
col = img.RGBAAt(point.X, point.Y)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no images to get data from, ignore the pixel.
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
destImage.SetRGBA(ix, iy, col)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BlendNewestPixelsMedian takes the given tiles and median blends the n newest pixels (based on file modification time) of any overlapping tiles.
|
||||
// n is some hardcoded value inside this function.
|
||||
func BlendNewestPixelsMedian(tiles []*ImageTile, destImage *image.RGBA) {
|
||||
bounds := destImage.Bounds()
|
||||
|
||||
// Sort tiles by date.
|
||||
sort.Slice(tiles, func(i, j int) bool { return tiles[i].modTime.After(tiles[j].modTime) })
|
||||
|
||||
// List of images corresponding with every tile.
|
||||
// Can contain empty/nil entries for images that failed to load.
|
||||
images := []*image.RGBA{}
|
||||
for _, tile := range tiles {
|
||||
images = append(images, tile.GetImage())
|
||||
}
|
||||
|
||||
// Create arrays to be reused every pixel.
|
||||
rListEmpty, gListEmpty, bListEmpty := make([]int, 0, len(tiles)), make([]int, 0, len(tiles)), make([]int, 0, len(tiles))
|
||||
|
||||
for iy := bounds.Min.Y; iy < bounds.Max.Y; iy++ {
|
||||
for ix := bounds.Min.X; ix < bounds.Max.X; ix++ {
|
||||
rList, gList, bList := rListEmpty, gListEmpty, bListEmpty
|
||||
point := image.Point{ix, iy}
|
||||
count := 0
|
||||
|
||||
// Iterate through all images and create a list of colors.
|
||||
for _, img := range images {
|
||||
if img != nil {
|
||||
if point.In(img.Bounds()) {
|
||||
col := img.RGBAAt(point.X, point.Y)
|
||||
rList, gList, bList = append(rList, int(col.R)), append(gList, int(col.G)), append(bList, int(col.B))
|
||||
count++
|
||||
if count == 9 { // Max. number of tiles to median blend.
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no images to get data from, ignore the pixel.
|
||||
if count == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Sort colors.
|
||||
sort.Ints(rList)
|
||||
sort.Ints(gList)
|
||||
sort.Ints(bList)
|
||||
|
||||
// Take the middle element of each color.
|
||||
var r, g, b uint8
|
||||
if l := len(rList); l%2 == 0 {
|
||||
// Even.
|
||||
r = uint8((rList[l/2-1] + rList[l/2]) / 2)
|
||||
} else {
|
||||
// Odd.
|
||||
r = uint8(rList[(l-1)/2])
|
||||
}
|
||||
if l := len(gList); l%2 == 0 {
|
||||
// Even.
|
||||
g = uint8((gList[l/2-1] + gList[l/2]) / 2)
|
||||
} else {
|
||||
// Odd.
|
||||
g = uint8(gList[(l-1)/2])
|
||||
}
|
||||
if l := len(bList); l%2 == 0 {
|
||||
// Even.
|
||||
b = uint8((bList[l/2-1] + bList[l/2]) / 2)
|
||||
} else {
|
||||
// Odd.
|
||||
b = uint8(bList[(l-1)/2])
|
||||
}
|
||||
|
||||
destImage.SetRGBA(ix, iy, color.RGBA{r, g, b, 255})
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
Loading…
Reference in New Issue
Block a user