PowerPoint.ShapeFill class

図形オブジェクトの塗りつぶしの書式設定を表します。

Extends

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml

// Changes the transparency of every geometric shape in the slide.
await PowerPoint.run(async (context) => {
  // Get the type of shape for every shape in the collection.
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  shapes.load("type");
  await context.sync();

  // Change the shape transparency to be halfway transparent.
  shapes.items.forEach((shape) => {
    if (shape.type === PowerPoint.ShapeType.geometricShape) {
      shape.fill.transparency = 0.5;
    }
  });
  await context.sync();
});

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

foregroundColor

#RRGGBB 形式 ("FFA500" など) または名前付き HTML カラー ("オレンジ" など) で、HTML カラー形式で図形塗りつぶしの前景色を表します。

transparency

塗りつぶしの透明度の割合を、0.0 (不透明) から 1.0 (クリア) までの値として指定します。 図形の種類が透過性をサポートしていない場合、または図形の塗りつぶしの透過性が一貫性がない場合 (グラデーション塗りつぶしの種類など) に null を返します。

type

図形の塗りつぶしの種類を返します。 詳細については、「 PowerPoint.ShapeFillType 」を参照してください。

メソッド

clear()

この図形の塗りつぶしの書式設定をクリアします。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

setSolidColor(color)

図形の塗りつぶしの書式設定を均一な色に設定します。 これにより、塗りつぶしの種類が Solidに変更されます。

toJSON()

API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.ShapeFill オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.ShapeFillData として型指定) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

foregroundColor

#RRGGBB 形式 ("FFA500" など) または名前付き HTML カラー ("オレンジ" など) で、HTML カラー形式で図形塗りつぶしの前景色を表します。

foregroundColor: string;

プロパティ値

string

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Creates random shapes on the selected slide.
await PowerPoint.run(async (context) => {
  let finalTable = "";
  const currentSlide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
  const maxNewShapeWidth = 200;
  const maxNewShapeHeight = 200;
  const minNewShapeWidth = 50;
  const minNewShapeHeight = 50;
  for (let i = 0; i < 20; i++) {
    const rectangle: PowerPoint.Shape = currentSlide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle);
    rectangle.height = getRandomBetween(minNewShapeWidth, maxNewShapeWidth);
    rectangle.width = getRandomBetween(minNewShapeHeight, maxNewShapeHeight);
    rectangle.left = getRandomBetween(0, slideWidth - rectangle.width);
    rectangle.top = getRandomBetween(0, slideHeight - rectangle.height);
    rectangle.fill.foregroundColor = generateRandomHexColor();
  }
  finalTable += "Done<br>";
  $("#slide-tags").empty();
  $("#slide-tags").append(finalTable);
});

transparency

塗りつぶしの透明度の割合を、0.0 (不透明) から 1.0 (クリア) までの値として指定します。 図形の種類が透過性をサポートしていない場合、または図形の塗りつぶしの透過性が一貫性がない場合 (グラデーション塗りつぶしの種類など) に null を返します。

transparency: number;

プロパティ値

number

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml

// Changes the transparency of every geometric shape in the slide.
await PowerPoint.run(async (context) => {
  // Get the type of shape for every shape in the collection.
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  shapes.load("type");
  await context.sync();

  // Change the shape transparency to be halfway transparent.
  shapes.items.forEach((shape) => {
    if (shape.type === PowerPoint.ShapeType.geometricShape) {
      shape.fill.transparency = 0.5;
    }
  });
  await context.sync();
});

type

図形の塗りつぶしの種類を返します。 詳細については、「 PowerPoint.ShapeFillType 」を参照してください。

readonly type: PowerPoint.ShapeFillType | "NoFill" | "Solid" | "Gradient" | "Pattern" | "PictureAndTexture" | "SlideBackground";

プロパティ値

PowerPoint.ShapeFillType | "NoFill" | "Solid" | "Gradient" | "Pattern" | "PictureAndTexture" | "SlideBackground"

注釈

[ API セット: PowerPointApi 1.4 ]

メソッドの詳細

clear()

この図形の塗りつぶしの書式設定をクリアします。

clear(): void;

戻り値

void

注釈

[ API セット: PowerPointApi 1.4 ]

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: PowerPoint.Interfaces.ShapeFillLoadOptions): PowerPoint.ShapeFill;

パラメーター

options
PowerPoint.Interfaces.ShapeFillLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): PowerPoint.ShapeFill;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): PowerPoint.ShapeFill;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

setSolidColor(color)

図形の塗りつぶしの書式設定を均一な色に設定します。 これにより、塗りつぶしの種類が Solidに変更されます。

setSolidColor(color: string): void;

パラメーター

color

string

塗りつぶしの色を HTML の色形式で指定する文字列で、#RRGGBB 形式 ("FFA500" など) または名前付き HTML の色 ("オレンジ" など) として指定します。

戻り値

void

注釈

[ API セット: PowerPointApi 1.4 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml

// Changes the selected shapes fill color to red.
await PowerPoint.run(async (context) => {
  const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  shapes.items.map((shape) => {
    shape.fill.setSolidColor("red");
  });
  await context.sync();
});

toJSON()

API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.ShapeFill オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.ShapeFillData として型指定) を返します。

toJSON(): PowerPoint.Interfaces.ShapeFillData;

戻り値