Draw-Based Custom Shape. Full control: draw anything with the 2D context. The library has already applied position, rotation, flip, skew, scale and opacity — draw centered at 0, 0.
0, 0
defineShape("ring", { draw: (ctx, p, { thickness = 3 }) => { ctx.lineWidth = thickness; ctx.strokeStyle = p.fill; ctx.beginPath(); ctx.arc(0, 0, p.width / 2, 0, Math.PI * 2); ctx.stroke(); },}); Copy
defineShape("ring", { draw: (ctx, p, { thickness = 3 }) => { ctx.lineWidth = thickness; ctx.strokeStyle = p.fill; ctx.beginPath(); ctx.arc(0, 0, p.width / 2, 0, Math.PI * 2); ctx.stroke(); },});
Runs for every particle every frame — avoid allocations inside draw.
draw
Optional
Readonly
Height-to-Width Ratio of the Box.
1
Size When the Entry Sets None.
[12, 18]
Draw One Particle.
Draw-Based Custom Shape. Full control: draw anything with the 2D context. The library has already applied position, rotation, flip, skew, scale and opacity — draw centered at
0, 0.Example
Remarks
Runs for every particle every frame — avoid allocations inside
draw.