Created
February 15, 2023 18:21
-
-
Save marlonandrade/04634daad1fccd9b0a0c74adb1ce5152 to your computer and use it in GitHub Desktop.
Rainbow colors on Google Slides
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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