MCPcopy Create free account
hub / github.com/codecombat/codecombat / imageToPortrait

Function imageToPortrait

app/views/editor/thang/ThangTypeEditView.js:1002–1012  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

1000})())
1001
1002var imageToPortrait = function (img) {
1003 const canvas = document.createElement('canvas')
1004 canvas.width = 100
1005 canvas.height = 100
1006 const ctx = canvas.getContext('2d')
1007 const scaleX = 100 / img.width
1008 const scaleY = 100 / img.height
1009 ctx.scale(scaleX, scaleY)
1010 ctx.drawImage(img, 0, 0)
1011 return canvas.toDataURL('image/png')
1012}
1013
1014function __guard__ (value, transform) {
1015 return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined

Callers 1

saveNewThangTypeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected