Skip to content

シェイプカタログ ​

このカタログでは、particles.shape.type の代表的な値を一覧化し、particles.shape.options でシェイプ固有の制御が追加される場面を示します。

ソースフォルダー:

よく使うシェイプタイプ ​

  • circle (デフォルト、追加のシェイプオプションなし)
  • square / edge (追加のシェイプオプションなし)
  • triangle (追加のシェイプオプションなし)
  • line (追加のシェイプオプションなし)
  • polygon (options.polygon.sides)
  • star (options.star.sides, options.star.inset)
  • text (options.text.value, font, weight, style, close)
  • emoji (options.emoji.value)
  • image / images (options.image.src, name, width, height, replaceColor, close)
  • gif / gifs (options.gif.src, name, width, height, loopCount)
  • ribbon (options.ribbon.angle, count, drag, mass, oscillationDistance, oscillationSpeed, particleDist, velocityInherit)

エイリアスとバンドルに関するメモ ​

  • square と edge は同じシェイプのエイリアスです。
  • character と char は同じオプショングループのエイリアスです。
  • image と images は同じオプションオブジェクトを使います。
  • 高度なシェイプの多くは @tsparticles/slim (または @tsparticles/all) か専用シェイプパッケージが必要です。

Start/Pause コントロールと編集可能な JSON で素早く試すには /playground/shapes を使ってください。

クイック例 ​

Polygon ​

ts
particles: {
  shape: {
    type: "polygon",
    options: {
      polygon: {
        sides: 6,
      },
    },
  },
}

Emoji ​

ts
particles: {
  shape: {
    type: "emoji",
    options: {
      emoji: {
        value: ["😀", "🎉", "✨"],
        font: "Apple Color Emoji",
        padding: 0,
      },
    },
  },
}

Text ​

ts
particles: {
  shape: {
    type: "text",
    options: {
      text: {
        value: ["TS", "DOCS"],
        font: "Verdana",
        weight: "700",
        style: "",
      },
    },
  },
}

Image ​

ts
particles: {
  shape: {
    type: "image",
    options: {
      image: {
        src: "https://particles.js.org/images/hdr/fruits/strawberry.png",
        name: "strawberry",
        width: 64,
        height: 64,
        replaceColor: false,
      },
    },
  },
}