0.3.13 • Published 4 months ago

context-filter-polyfill v0.3.13

Weekly downloads
119
License
MIT
Repository
github
Last release
4 months ago

context-filter-polyfill

Build Status

https://davidenke.github.io/context-filter-polyfill/

Polyfills CanvasRenderingContext2d.filter capability of adopting CSS3 filters to canvas contexts at least partially.

Successfully tested on

  • macOS Safari
  • iOS Safari
  • Windows 10 IE11
  • Windows 10 Edge 16-18

Installation

Add the polyfill to your page via script tag from a CDN:

<head>
  <script src="https://cdn.jsdelivr.net/npm/context-filter-polyfill/dist/index.min.js"></script>
</head>

Or from npm:

npm install context-filter-polyfill

... and import it in your code:

import 'context-filter-polyfill';

Supported filters

See it in action

Just open the integration demo on Safari / iOS or IE11.

Strategy

The polyfill is applied by the following steps:

  1. monkey patching all properties of the CanvasRenderingContext2d
  2. monkey patching all getters and setters of the CanvasRenderingContext2d
  3. monkey patching all methods of the CanvasRenderingContext2d

These patches are proxying all changes to a offscreen canvas which applies the appropriate filter polyfills everytime a drawing function is called:

  • clearRect
  • drawImage
  • fill
  • fillRect
  • fillText
  • stroke
  • strokeRect
  • strokeText

The contents of the offscreen canvas are applied back to the original canvas and is then resetted.

0.3.9

4 months ago

0.3.13

4 months ago

0.3.12

4 months ago

0.3.11

4 months ago

0.3.10

4 months ago

0.3.8

4 months ago

0.3.7

4 months ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago