Setting SVG bg image sticks

V13.24.1
using

function OnClick(clickData)
{
	var rgb = function() {
	    var r = Math.floor(Math.random() * 256);
	    var g = Math.floor(Math.random() * 256);
	    var b = Math.floor(Math.random() * 256);
	    return "rgb(" + r + "," + g + "," + b + ")";
	}();		
	var img = DOpus.LoadImage('<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">  <circle cx="20" cy="20" r="10" fill="' + rgb + '"/></svg>');
	var func = "Set BACKGROUNDIMAGE=filedisplay:" + img + " BACKGROUNDIMAGEOPTS=tile,opacity:30";
	var cmd = clickData.func.command;
	cmd.RunCommand(func);
}

in a button to set svg image works great - only problem is normal background images cannot be set afterwards - a close and restart fixes

Set via which method(s)?

Using background changer in slideshow mode and single image mode - the bg changes for everything except filesdisplay which is specified in the script above.

Set BACKGROUNDIMAGE=filedisplay:"C:\Pathto\wallpaper image.png" BACKGROUNDIMAGEOPTS=tile,opacity:30

This can be used to achieve same result.

Use Set BACKGROUNDIMAGE=filedisplay BACKGROUNDIMAGEOPTS=local,reset to reset it back to the global settings.

That works in buttons on toolbar, but using

command = 'Set BACKGROUNDIMAGE=filedisplay BACKGROUNDIMAGEOPTS=local,reset';
cmd.Run();

or

command = 'Set BACKGROUNDIMAGE=all BACKGROUNDIMAGEOPTS=local,reset';
cmd.Run();

in Backgroundchanger before image is set, does nothing, getting same result as OP. :frowning:

is there a better fix, dynamic svg backgrounds sounds exciting.

Those two code snippest don't make sense. Changing a variable named command doesn't affect what cmd.Run(); does.

awesome, many thanks, working now using RunCommand() :slight_smile:

Hmmm - after some use, in Background Changer it is causing the preview pane to flash, on changes - the same as if transitions is used.
Which is distracting when trying to read a document in the preview pane.
Please find another solution.

EDIT: background is changing every 3 seconds

Try resetting it after changing the global setting rather than before.

do not understand - how do we do this ?