1
0
Fork 0
mirror of https://github.com/voltbonn/profile-picture-generator.git synced 2024-12-22 15:55:08 +00:00

renamed offscreenCanvas to canvas

and renamed offscreenCanvas_ctx to ctx
This commit is contained in:
thomasrosen 2021-01-22 08:39:49 +01:00
parent 041805a9d5
commit f1cccb6879

View file

@ -28,11 +28,11 @@ function App() {
reader.onload = reader_event => {
const img = new Image()
img.onload = function () {
const offscreenCanvas = document.createElement('canvas')
offscreenCanvas.width = frameSize
offscreenCanvas.height = frameSize
const canvas = document.createElement('canvas')
canvas.width = frameSize
canvas.height = frameSize
const offscreenCanvas_ctx = offscreenCanvas.getContext('2d', { alpha: true })
const ctx = canvas.getContext('2d', { alpha: true })
let width, height;
if (img.width < img.height) {
@ -43,7 +43,7 @@ function App() {
width = (img.width / img.height) * frameSize
}
offscreenCanvas_ctx.drawImage(
ctx.drawImage(
img,
(frameSize - width) / 2,
(frameSize - height) / 2,
@ -51,7 +51,7 @@ function App() {
height,
)
const pngUrl = offscreenCanvas.toDataURL()
const pngUrl = canvas.toDataURL()
setPhoto(pngUrl)
}
img.src = reader_event.target.result