Ajustement pour une interface minimale

This commit is contained in:
2026-04-21 01:50:53 +02:00
parent 4a1c77121b
commit 13df9c0601
4 changed files with 88 additions and 25 deletions
+42 -20
View File
@@ -221,28 +221,50 @@ export class Glitcher {
this.ctx.texParameteri(this.ctx.TEXTURE_2D, this.ctx.TEXTURE_MIN_FILTER, this.ctx.LINEAR);
}
resize(width, height){
let computedStyle = window.getComputedStyle(this.canvas)
let maxWidth = parseFloat(computedStyle["max-width"])
let maxHeight = parseFloat(computedStyle["max-height"])
if(window.devicePixelRatio){
maxWidth *= window.devicePixelRatio
maxHeight *= window.devicePixelRatio
async toBlob(type, quality) {
this.resize(this.currentImage.width, this.currentImage.height, true)
this.render()
let blob = await new Promise((res, rej) => this.canvas.toBlob((imageBlob) => {
if(imageBlob){
res(imageBlob)
} else {
rej()
}
}, type, quality))
this.resize(this.currentImage.width, this.currentImage.height, false)
return blob
}
resize(width, height, force=false){
if(!force){
let computedStyle = window.getComputedStyle(this.canvas)
let maxWidth = parseFloat(computedStyle["max-width"])
let maxHeight = parseFloat(computedStyle["max-height"])
if(window.devicePixelRatio){
maxWidth *= window.devicePixelRatio
maxHeight *= window.devicePixelRatio
}
if(Number.isNaN(maxWidth)){
maxWidth = width
}
if(Number.isNaN(maxHeight)){
maxHeight = height
}
let resize = resizeToFit("contain", {width, height}, {width: maxWidth, height: maxHeight})
this.canvas.width = resize.width
this.canvas.height = resize.height
} else {
this.canvas.width = width
this.canvas.height = height
}
if(Number.isNaN(maxWidth)){
maxWidth = width
}
if(Number.isNaN(maxHeight)){
maxHeight = height
}
let resize = resizeToFit("contain", {width, height}, {width: maxWidth, height: maxHeight})
this.canvas.width = resize.width
this.canvas.height = resize.height
this.videoCanvas.width = this.canvas.width
this.videoCanvas.height = this.canvas.height
this.ctx.viewport(0, 0, this.canvas.width, this.canvas.height);