I accidentally left a color specifier for a layout element that had an svg image and the colors were all messed up and I couldn't figure out why. Then I realized that the stray color tag was there. Sure enough, it's documented in the mame layout docs:
For image components, the colour of the image pixels is multiplied by the specified colour. If no such element is present, the colour defaults to opaque white.
I was brainstorming and realized that this could be extremely useful to show/hide layout elements.
Just set the alpha to zero in a set_color_callback() function with
"return emu.render_color(1,1,1,1) " for opaque (alpha = 1)
"return emu.render_color(0,1,1,1) " for invisible (alpha = 0)
So for example to vary the transparency of an item:
function code_pressed(code) return machine.input:code_pressed(machine.input:code_from_token(code)) end
curcolor = curcolor or 1 -- start out with 1
if code_pressed("KEYCODE_T") then curcolor = 1.0 end
if code_pressed("KEYCODE_R") then curcolor = 0.7 end
if code_pressed("KEYCODE_E") then curcolor = 0.5 end
if code_pressed("KEYCODE_W") then curcolor = 0.2 end
if code_pressed("KEYCODE_Q") then curcolor = 0.0 end