Skip to content

consider adding path shape type #81

@catdad

Description

@catdad

Example code (limited to more modern browsers):

function path(context, x, y, scaleX, scaleY, rotation, path) {
  context.save();
  context.translate(x, y);
  context.rotate(rotation);
  context.scale(scaleX, scaleY);
  context.fill(new Path2D(path));
  context.restore();
}
...
path(context, fetti.x + fetti.wobble, fetti.y + fetti.wobble, Math.abs(x2 - x1) * 0.2, Math.abs(y2 - y1) * 0.2, Math.PI / 10 * fetti.wobble, fetti.shape.path);
...
confetti({
    particleCount: 100,
    shapes: ['circle', { type: 'path', path: 'M1 1 h 8 v 8 h -8 Z' }]
});

A path will probably need to provide a width and height or a scale factor, so that the resulting path can be scaled appropriately.

This code has very poor performance. Any acceptable solution will need to solve that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA neat new idea for this projecthelp wantedIssue could use a contributor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions