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.
|
||||
// https://opensource.org/licenses/MIT
|
||||
@ -8,6 +8,7 @@ package main
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
@ -69,7 +70,9 @@ func (sic *StitchedImageCache) Regenerate() *image.RGBA {
|
||||
|
||||
si := sic.stitchedImage
|
||||
|
||||
// Create new image with default background color.
|
||||
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.
|
||||
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.
|
||||
// https://opensource.org/licenses/MIT
|
||||
@ -13,6 +13,10 @@ import (
|
||||
"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.
|
||||
var StitchedImageCacheGridSize = 256
|
||||
|
||||
@ -116,7 +120,7 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
|
||||
// Determine the cache rowIndex index.
|
||||
rowIndex := (y + si.cacheRowYOffset) / si.cacheRowHeight
|
||||
if rowIndex < 0 || rowIndex >= len(si.cacheRows) {
|
||||
return color.RGBA{}
|
||||
return colorBackground
|
||||
}
|
||||
|
||||
// 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.
|
||||
// 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 {
|
||||
point := image.Point{X: x, Y: y}
|
||||
if !point.In(s.bounds) {
|
||||
return color.RGBA{}
|
||||
return colorBackground
|
||||
}
|
||||
|
||||
return s.StitchedImage.RGBAAt(x, y)
|
||||
|
Loading…
Reference in New Issue
Block a user