mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-22 21:17:33 +00:00
Prevent transparent background
This commit is contained in:
parent
d82fda528a
commit
f22ef05411
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2022-2023 David Vogel
|
// Copyright (c) 2022-2024 David Vogel
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
@ -8,6 +8,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"image/draw"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -69,7 +70,9 @@ func (sic *StitchedImageCache) Regenerate() *image.RGBA {
|
|||||||
|
|
||||||
si := sic.stitchedImage
|
si := sic.stitchedImage
|
||||||
|
|
||||||
|
// Create new image with default background color.
|
||||||
cacheImage := image.NewRGBA(sic.rect)
|
cacheImage := image.NewRGBA(sic.rect)
|
||||||
|
draw.Draw(cacheImage, cacheImage.Bounds(), &image.Uniform{colorBackground}, cacheImage.Bounds().Min, draw.Src)
|
||||||
|
|
||||||
// List of tiles that intersect with the to be generated cache image.
|
// List of tiles that intersect with the to be generated cache image.
|
||||||
intersectingTiles := []*ImageTile{}
|
intersectingTiles := []*ImageTile{}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2022-2023 David Vogel
|
// Copyright (c) 2022-2024 David Vogel
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
@ -13,6 +13,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// The default background color.
|
||||||
|
// We use a non transparent black.
|
||||||
|
var colorBackground = color.RGBA{0, 0, 0, 255}
|
||||||
|
|
||||||
// StitchedImageCacheGridSize defines the worker chunk size when the cache image is regenerated.
|
// StitchedImageCacheGridSize defines the worker chunk size when the cache image is regenerated.
|
||||||
var StitchedImageCacheGridSize = 256
|
var StitchedImageCacheGridSize = 256
|
||||||
|
|
||||||
@ -116,7 +120,7 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
|
|||||||
// Determine the cache rowIndex index.
|
// Determine the cache rowIndex index.
|
||||||
rowIndex := (y + si.cacheRowYOffset) / si.cacheRowHeight
|
rowIndex := (y + si.cacheRowYOffset) / si.cacheRowHeight
|
||||||
if rowIndex < 0 || rowIndex >= len(si.cacheRows) {
|
if rowIndex < 0 || rowIndex >= len(si.cacheRows) {
|
||||||
return color.RGBA{}
|
return colorBackground
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we advanced/changed the row index.
|
// Check if we advanced/changed the row index.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2023 David Vogel
|
// Copyright (c) 2023-2024 David Vogel
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
@ -29,7 +29,7 @@ func (s SubStitchedImage) At(x, y int) color.Color {
|
|||||||
func (s SubStitchedImage) RGBAAt(x, y int) color.RGBA {
|
func (s SubStitchedImage) RGBAAt(x, y int) color.RGBA {
|
||||||
point := image.Point{X: x, Y: y}
|
point := image.Point{X: x, Y: y}
|
||||||
if !point.In(s.bounds) {
|
if !point.In(s.bounds) {
|
||||||
return color.RGBA{}
|
return colorBackground
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.StitchedImage.RGBAAt(x, y)
|
return s.StitchedImage.RGBAAt(x, y)
|
||||||
|
Loading…
Reference in New Issue
Block a user