Polyfill canvas toBlob().
This commit is contained in:
parent
ad96e3488c
commit
ffd98de110
@ -1,6 +1,16 @@
|
|||||||
Polyfill =
|
Polyfill =
|
||||||
init: ->
|
init: ->
|
||||||
|
Polyfill.toBlob()
|
||||||
Polyfill.visibility()
|
Polyfill.visibility()
|
||||||
|
toBlob: ->
|
||||||
|
HTMLCanvasElement::toBlob or= (cb) ->
|
||||||
|
data = atob @toDataURL()[22..]
|
||||||
|
# DataUrl to Binary code from Aeosynth's 4chan X repo
|
||||||
|
l = data.length
|
||||||
|
ui8a = new Uint8Array l
|
||||||
|
for i in [0...l]
|
||||||
|
ui8a[i] = data.charCodeAt i
|
||||||
|
cb new Blob [ui8a], type: 'image/png'
|
||||||
visibility: ->
|
visibility: ->
|
||||||
# page visibility API
|
# page visibility API
|
||||||
return unless 'webkitHidden' of document
|
return unless 'webkitHidden' of document
|
||||||
|
|||||||
@ -595,21 +595,9 @@ QR =
|
|||||||
cv.width = img.width = width
|
cv.width = img.width = width
|
||||||
cv.getContext('2d').drawImage img, 0, 0, width, height
|
cv.getContext('2d').drawImage img, 0, 0, width, height
|
||||||
URL.revokeObjectURL fileURL
|
URL.revokeObjectURL fileURL
|
||||||
applyBlob = (blob) =>
|
cv.toBlob (blob) =>
|
||||||
@URL = URL.createObjectURL blob
|
@URL = URL.createObjectURL blob
|
||||||
@nodes.el.style.backgroundImage = "url(#{@URL})"
|
@nodes.el.style.backgroundImage = "url(#{@URL})"
|
||||||
if cv.toBlob
|
|
||||||
cv.toBlob applyBlob
|
|
||||||
return
|
|
||||||
data = atob cv.toDataURL().split(',')[1]
|
|
||||||
|
|
||||||
# DataUrl to Binary code from Aeosynth's 4chan X repo
|
|
||||||
l = data.length
|
|
||||||
ui8a = new Uint8Array l
|
|
||||||
for i in [0...l]
|
|
||||||
ui8a[i] = data.charCodeAt i
|
|
||||||
|
|
||||||
applyBlob new Blob [ui8a], type: 'image/png'
|
|
||||||
|
|
||||||
fileURL = URL.createObjectURL @file
|
fileURL = URL.createObjectURL @file
|
||||||
img.src = fileURL
|
img.src = fileURL
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user