对于Apps脚本,我试图打印文本框填充的十六进制代码。任何想法。到达.getSolidFill()
后就卡住了。这一行不适合我:shape.getFill().getSolidFill().getColor().asRgbColor().asHexString())
function adjustFillColor() {
// // Open the presentation and get the slides in it.
let deck = SlidesApp.openById(masterDeckID);
let slides = deck.getSlides();
let masterSlide = slides[1];
let slide = masterSlide.duplicate();
slide.getShapes().forEach(shape => { // Iterate through every shape in the slide
if (shape.getFill().getSolidFill()!== null){
shape.getFill().setSolidFill("#000000");
}
});
};
在您的脚本中,如何修改以下内容?
:
console.log("Color String: " +shape.getFill().getSolidFill());
:
console.log("Color String: " + shape.getFill().getSolidFill().getColor().asRgbColor().asHexString());
当这个修改后的脚本运行时,您可以检索形状的颜色作为HEX值。
或者,以下修改如何?
从slide.getShapes().forEach(shape => { if (shape.getFill().getSolidFill()!== null) console.log("Color String: " +shape.getFill().getSolidFill());
masterSlide.getShapes().forEach(shape => { var solidFill = shape.getFill().getSolidFill(); var color = solidFill && solidFill.getColor(); var rgbColor = color && color.getColorType() == SlidesApp.ColorType.RGB ? color.asRgbColor() : null; if (solidFill && color && rgbColor) { console.log("Color String: " + rgbColor.asHexString()); } });
引用:
- getSolidFill ()
- 色鬼()
- asRgbColor ()
- asHexString ()