0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google スライドのプレゼンテーションに進行状況バーを表示する

Posted at

image.png

プレゼンテーションのスライドの下部に進行状況バーを追加します。
公式サイトがとてもわかりやすいです。

記事内容は以上です。

以下はソースコードとドキュメントを読んだログを記載します。

読みログ

onOpen

  SlidesApp.getUi().createAddonMenu()
      .addItem('Show progress bar', 'createBars')
      .addItem('Hide progress bar', 'deleteBars')
      .addToUi();

アドオンボタン追加がとてもわかりやすくてGAS好き。

createBars

function createBars() {
  deleteBars(); // Delete any existing progress bars
  ...

実行ごとに全部作り直すの好き。GASで時間トリガーの処理とかもよくこの書き方見る。

      const bar = slides[i].insertShape(SlidesApp.ShapeType.RECTANGLE, x, y,
          barWidth, BAR_HEIGHT);
      bar.getBorder().setTransparent();
      bar.setLinkUrl(BAR_ID);

バー追加部分
insertShape(shapeType, left, top, width, height)
shapeType がかなり多い。テキストボックス、長方形、矢印...、以下参照。

setLinkUrl で URL に ID を載せている。このスクリプトでの生成物のキーにしている。公式でハック的な使い方しているの面白さ感じる。
色を変えるときはこの場所で行う。例: bar.getFill().setSolidFill(255, 0, 0, 0.8);

insertImage を使えばテクスチャ的にできるかと考えたが、画像の一部切り抜きに使えそうなメソッドがなさそうで断念。Transform でスケーリングはできた。

Slides

親子関係理解

PageElement の実体には Group, Image, Line, Shape, SheetsChart(スプレッドシートから図の埋め込み), Table, Video, WordArt がある。それぞれクラスごとの操作ができる。

スクリプトから十分な操作ができそう。他のスクリプトも考えてみたい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?