对于应用程序脚本,我正在try 打印填充文本框的十六进制代码.

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());
  • 运行此修改后的脚本时,可以将形状的 colored颜色 检索为十六进制值.

  • 或者,下面的修改如何?

    • 从…起

        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());
          }
        });
      

参考文献:

Javascript相关问答推荐

为什么我达到了时间限制!?LeetCode链接列表循环(已解决,但需要解释!)

窗口.getComputedStyle()在MutationObserver中不起作用

在React中获取数据后,如何避免不必要的组件闪现1秒?

在Angular中将样式应用于innerHTML

拖放仅通过 Select 上传

MongoDB中的引用

使用LocaleCompare()进行排序时,首先使用大写字母

如何在ASP.NET JavaScript中使用Google Charts API仅对绘制为负方向的条形图移动堆叠条形图标签位置

使用Google API无法进行Web抓取

提交链接到AJAX数据结果的表单

将内容大小设置为剩余可用空间,但如果需要,可在div上显示滚动条

一个实体一刀VS每个实体多刀S

OnClick更改Json数组JSX中的图像源

我正在试着做一个TicTacToe Ai来和我玩.但是,我试着在第一个方块被点击时出现一个X,然后在第二个方块之后出现一个O

为什么我不能使用其同级元素调用和更新子元素?

用Reaction-RT-Chart创建实时条形图

使用Library chart.js在一个带有两个y轴的图表中绘制两个数据集

在HTML中使用meta标记来指定定制元数据以用于使用JavaScript进行检索是不是一个坏主意?

与find()方法一起使用时,Mongoose中的$or运算符没有提供所有必需的数据

使用JAVASCRIPT-使用If和Else If多次判断条件-使用JAVASRIPT对象及其属性