Skip to content

Instantly share code, notes, and snippets.

View dhwrwm's full-sized avatar
🏠
Working from home

Dhwrwm Basumatary dhwrwm

🏠
Working from home
  • Guwahati
View GitHub Profile
@dmail
dmail / object-fit-cover-video.js
Created October 5, 2015 06:50
object-fit:cover polyfill on video element using canvas
// http://stackoverflow.com/questions/21961839/simulation-background-size-cover-in-canvas
function drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) {
if (arguments.length === 2) {
x = y = 0;
w = ctx.canvas.width;
h = ctx.canvas.height;
}
// default offset is center
offsetX = typeof offsetX === "number" ? offsetX : 0.5;