Fluid型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The liquid: its particles and how it behaves.
インポート
import type { Fluid } from "@johnmorrisdotca/karakuri/physics";
定義
interface Fluid {
particles: Particle[];
radius: number;
gravity: number;
damping: number;
iterations: number;
reacts: boolean;
}
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
particles | Particle[] | |
radius | number | A particle's radius, which is also how far apart two settle (twice this). |
gravity | number | |
damping | number | How much of its speed a particle keeps each step. |
iterations | number | |
reacts | boolean | Whether water and lava turn each other to stone where they touch. |
例
import { createFluid, fillRect } from "@johnmorrisdotca/karakuri/physics";
import type { Fluid } from "@johnmorrisdotca/karakuri/physics";
const fluid=createFluid({radius:2,gravity:0,iterations:1,reacts:false});
fillRect(fluid,"water",0,0,8,8);
const value: Fluid = fluid;
console.log(value);{
particles: [
{ x: 2, y: 2, px: 2, py: 2, kind: 'water' },
{ x: 6.1, y: 2, px: 6.1, py: 2, kind: 'water' },
{ x: 4.05, y: 6.1, px: 4.05, py: 6.1, kind: 'water' }
],
radius: 2,
gravity: 0,
damping: 0.995,
iterations: 1,
reacts: false
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。