Skip to content

Instantly share code, notes, and snippets.

@marlonandrade
Created February 15, 2023 18:21
Show Gist options
  • Select an option

  • Save marlonandrade/04634daad1fccd9b0a0c74adb1ce5152 to your computer and use it in GitHub Desktop.

Select an option

Save marlonandrade/04634daad1fccd9b0a0c74adb1ce5152 to your computer and use it in GitHub Desktop.
Rainbow colors on Google Slides
const COLORS = [
"#4495D7",
"#6D9F38",
"#E0A41A",
"#932810",
"#744893",
"#3674A4",
];
function randomizeColor() {
const presentation = SlidesApp.getActivePresentation();
const slides = presentation.getSlides();
for (const slide of slides) {
const elements = slide.getPageElements();
for (const element of elements) {
if (element.getPageElementType() != SlidesApp.PageElementType.SHAPE) {
continue;
}
const text = element.asShape().getText();
for (let i = 0; i < text.getLength() - 1; i++) {
const color = COLORS[i % COLORS.length];
// const color = COLORS[Math.floor(Math.random() * COLORS.length)];
text.getRange(i, i + 1).getTextStyle().setForegroundColor(color);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment