Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Last active November 17, 2023 22:28
Show Gist options
  • Save GoodBoyNinja/83b8c95969a5341083cca392f4321c77 to your computer and use it in GitHub Desktop.
Save GoodBoyNinja/83b8c95969a5341083cca392f4321c77 to your computer and use it in GitHub Desktop.
Use this to paint a group or a panel object by passing the object variable and an RGBA color ([x,x,x,x])
function FillPanel(panelOBJ, color) {
if (
panelOBJ &&
color &&
(panelOBJ.type == "panel" ||
panelOBJ.type == "group" ||
panelOBJ.type == "dialog" ||
panelOBJ.type == "palette" ||
panelOBJ.type == "window") &&
panelOBJ.graphics.BrushType
) {
try {
color[3] = color[3] == undefined ? 1 : color[3];
if (!(color.length >= 3)) {
// color is not propper rgb array
return;
}
var g = panelOBJ.graphics;
if (g !== undefined) {
g.backgroundColor = g.newBrush(g.BrushType.SOLID_COLOR, color);
}
} catch (e) {
// something went wrong, you could print or alet an error here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment