Apply background colors to all documents

From time to time, I need to change the background colors in Preferences>Background>Colors to help me see more clearly when I forgot my glasses or something. What’s really aggravating is that once you want to change it or notice that the colors you’ve selected are meld with colors in your sprite or whatever, the only recourse is to go into every single file you work on regularly and to this:

  1. Navigate to Preferences>Background>Colors
  2. Select “Background for New Documents” where the two new colors are selected and copy one of the two color codes
  3. Select Apply to “Background for the Current Document”, select one color and paste the code.
  4. Back to “New document” and copy the second color.
  5. Go back to “Active Document” and paste the second color code.
  6. Repeat on every document/file.

I work on around 8 tilesets and a ton of individual sprites regularly. So if I have a tough time seeing something, I have to go through each tileset and sprite, manually copy + paste two codes over and over again. It’s insanity, especially when you just changed it for a day or two or you realize the colors you pick meld with colors you’ve used in one or multiple sprites.

Personally, I don’t see the merit or reason why the background settings are document-unique/saved by default. I’d much rather see the option to toggle “Enable unique background settings for the active document” which inherits from the global setting and once enabled, you could set, save and delete a new setting, profile or whatever.

Honestly, I cannot express how much dislike I have for the current solution. It’s beyond tedious or annoyance. Especially when you have to do this semi-regularly. Sorry for the long post, I just want to accurately express the downside of the issue. I’m sure many people like to set unique backgrounds for each document but I have a hard time discerning the the background from the sprite if I use unique colors across multiple sprites/tilesets.

From past experience on this forum, making a workaround for yourself with a Lua script is your best option 9 out of 10 times.

Most feature requests are ignored. Some prompt a little debate, where the problem is agreed upon but a solution is not. On the rare occasion I’ve seen a feature request promptly implemented, I wish it hadn’t been.

Below is a sample for one of many approaches. What it does is copy the two background checker colors from the active sprite in the editor to other open sprite tabs. If you don’t think this is an effective approach, you can do your own thing instead.

local site <const> = app.site
local srcSprite <const> = site.sprite
if not srcSprite then return end

local appPrefs <const> = app.preferences
local getDocPrefs <const> = appPrefs.document

local aHex = 0xff1c1c1c
local bHex = 0xff0a0a0a

local srcDocPrefs <const> = getDocPrefs(srcSprite)
if srcDocPrefs then
    local srcBgPrefs <const> = srcDocPrefs.bg
    if srcBgPrefs then
        -- For other checker properties, such as size, type and zoom, see
        -- https://github.com/aseprite/aseprite/blob/main/data/pref.xml#L521

        local bgPrefColor1 <const> = srcBgPrefs.color1 --[[@as Color]]
        if bgPrefColor1 then
            aHex = 0xff000000 | bgPrefColor1.rgbaPixel
        end

        local bgPrefColor2 <const> = srcBgPrefs.color2 --[[@as Color]]
        if bgPrefColor2 then
            bHex = 0xff000000 | bgPrefColor2.rgbaPixel
        end
    end
end

local idSrcSprite <const> = srcSprite.id
local openSprites <const> = app.sprites
local lenOpenSprites <const> = #openSprites

local h = 0
while h < lenOpenSprites do
    h = h + 1
    local trgSprite <const> = openSprites[h]
    local idTrgSprite <const> = trgSprite.id
    if idSrcSprite ~= idTrgSprite then
        local trgDocPrefs <const> = getDocPrefs(trgSprite)
        if trgDocPrefs then
            local trgBgPrefs <const> = trgDocPrefs.bg
            if trgBgPrefs then
                trgBgPrefs.color1 = Color {
                    r = (aHex >> 0x00) & 0xff,
                    g = (aHex >> 0x08) & 0xff,
                    b = (aHex >> 0x10) & 0xff,
                    a = 255
                }

                trgBgPrefs.color2 = Color {
                    r = (bHex >> 0x00) & 0xff,
                    g = (bHex >> 0x08) & 0xff,
                    b = (bHex >> 0x10) & 0xff,
                    a = 255
                }
            end
        end
    end
end

app.sprite = srcSprite
app.refresh()

app.alert("Background checker applied.")