npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

p5.offscreencanvas

v0.0.1

Published

a library for manipulating OffscreenCanvas with p5

Downloads

13

Readme

p5.OffscreenCanvas

A library for manipulating OffscreenCanvas with p5

Usage

Download the p5.OffscreenCanvas.js file in dist folder and put it in your project.

Important it should be loaded after p5, your index.html file should look something like this

...
<script src="path/to/p5"></script>
<script src="path/to/p5.OffscreenCanvas"></script>
<script src="path/to/sketch"></script>
...

This little wrapper provides a new function createOffscreenCanvas, which return a p5.Graphics-like object. It can be used to draw things off screen with the OffscreenCanvas Object instead of creating a new canvas in the dom tree. The OffscreenCanvas object can be also use in worker thread. This library also overwrite the image function for the 2D renderer to allow it to display ImageBitmap and OffscreenCanvas object.

See files in the example folder for more information.

Worker template

There is also a template for using this library with worker (worker-templ.js) in dist folder. You can use it to start your project with web worker. You can find more about how to do it in the code comments.

API

createOffscreenCanvas

Type: function

Arguments: width, height, [renderer = P2D]

Create a new wrapper object (of class OC) of a OffscreenCanvas object with the given width and height.

OC.reset

Type: function

Argument: none

Reset the offscreen canvas context matrix.

OC.remove

Type: function

Argument: none

Remove this offscreen canvas from the p5 instance.

OC.currentFrame

Type: function

Argument: none

Return: a ImageBitmap object

Return a bitmap image of the current render of the offscreen render this action will transfer all content in the canvas to the ImageBitmap object.

OC.currentBlob

Type: function

Arguments:

{object} options: an object containing the options, see https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob

{function} callback: an callback to handle the promise

Return: A Promise returning a Blob object if a callback is not specified, else undefined.

Create a Blob object representing the image contained in the canvas

OC.currentCanvas

Type: function

Argument: none

Return: The OffscreenCanvas Object

Return the transferable OffscreenCanvas object.

OC.loadCanvas

Type: function

Argument:

{OffscreenCanvas} comingCanvas

Load a transferable OffscreenCanvas object. This action will create a new renderer if the loaded canvas' drawing context is different from the current one. Else the drawing context properties (e.g. fill and stroke color in 2d context) are also loaded. This action will not copy the OffscreenCanvas object.