Skip to content

OffscreenCanvas when in worker contexts #35

Description

@MatthewSteel

Hi! I'm trying to use tiny-sdf in a web-worker, and document.createElement("canvas") isn't working because document isn't found on the global object.

I'm happy to make a PR that does something like

if (self.OffscreenCanvas) {
  this.canvas = new OffscreenCanvas(size, size);
} else {
  this.canvas = document.createElement("canvas");
  this.canvas.width = this.canvas.height = size;
}

or that reversed, or using some different kind of logical test. Looks like your eslint config doesn't love OffscreenCanvas, so I might need some help convincing it too.

Not super urgent, I think I can hack around this until it's fixed here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions