From 72d114ac7460672984a2e414a69afc7b7ba50818 Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 1 Aug 2024 14:32:20 -0500 Subject: [PATCH] feat: shapes --- app/particles/emitter.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/particles/emitter.js b/app/particles/emitter.js index 7f8e115..bb3a192 100644 --- a/app/particles/emitter.js +++ b/app/particles/emitter.js @@ -1,6 +1,7 @@ import K from 'kefir'; import * as easings from '@/util/easing.js'; +import {TAU} from '@/util/math.js'; export default class Emitter { constructor(ecs) { @@ -11,6 +12,18 @@ export default class Emitter { const allocated = this.ecs.get(await this.ecs.create(entity)); if (shape) { switch (shape.type) { + case 'circle': { + const r = Math.random() * TAU; + allocated.Position.x += Math.cos(r) * shape.payload.radius; + allocated.Position.y += Math.sin(r) * shape.payload.radius; + break; + } + case 'filledCircle': { + const r = Math.random() * TAU; + allocated.Position.x += Math.cos(r) * Math.random() * shape.payload.radius; + allocated.Position.y += Math.sin(r) * Math.random() * shape.payload.radius; + break; + } case 'filledRect': { allocated.Position.x += Math.random() * shape.payload.width - (shape.payload.width / 2); allocated.Position.y += Math.random() * shape.payload.height - (shape.payload.height / 2);