Skip to content

Instantly share code, notes, and snippets.

View Kaiido's full-sized avatar

Tristan Fraipont Kaiido

  • Seoul
  • 22:01 (UTC +09:00)
View GitHub Profile
@Kaiido
Kaiido / getSupportedCanvasFilters.js
Last active October 8, 2021 05:12
Get all supported CanvasFilter filters
/**
* MIT License - Copyright (c) 2021 Kaiido
*
* A method that returns a Set of all the SVG filters
* that are supported as CanvasFilter by the current UA.
* See https://github.com/whatwg/html/pull/6763#discussion_r691322778
*
**/
function getSupportedCanvasFilters() {
@Kaiido
Kaiido / drawImage-clipper.js
Created January 31, 2021 03:21
Safari drawImage out-of-bounds fixer
/**
* MIT License - Copyright (c) 2021 Kaiido
*
* A monkey-patch for Safari's drawImage.
*
* This browser doesn't handle well using the cropping abilities of drawImage
* with out-of-bounds values.
* (see https://stackoverflow.com/questions/35500999/cropping-with-drawimage-not-working-in-safari)
* This script takes care of detecting when the monkey-patch is needed,
* and does redefine the cropping parameters so they fall inside the source's boundaries.