Skip to content

Feature request: allow effects like backdrop-filter, using the current canvas content as the backdrop root #79

@progers

Description

@progers

Maybe this should work?

<canvas id="canvas" width="200" height="200" layoutsubtree>
  <div id="child" style="width: 100px; height: 100px; backdrop-filter: blur(1px);">
    hello world
  </div>
</canvas>

<script>
  canvas.onpaint = () => {
    const ctx = canvas.getContext('2d');
    ctx.reset();

    // draw stripes
    for (let y = 0; y < canvas.height; y++) {
      ctx.fillStyle = (y % 2 === 0) ? 'black' : 'white';
      ctx.fillRect(0, y, canvas.width, 1);
    }

    // draw #child into the canvas.
    ctx.drawElementImage(child, 50, 50);
  }
  canvas.requestPaint();
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions