File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
extensions-builtin/canvas-zoom-and-pan/javascript Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -482,8 +482,18 @@ onUiLoaded(async() => {
482482 if ( Math . abs ( delta ) < 1 ) {
483483 delta = deltaY > 0 ? - 1 : 1 ;
484484 }
485- let newValue = currentRadius + delta ;
486- input . value = Math . min ( Math . max ( newValue , 1 ) , maxValue ) ;
485+ const newValue = currentRadius + delta ;
486+ // allow increasing the brush size beyond what's limited by gradio up to 1/2 diagonal of the image
487+ if ( newValue > maxValue ) {
488+ const canvasImg = gradioApp ( ) . querySelector ( `${ elemId } img` ) ;
489+ if ( canvasImg ) {
490+ const maxDiameter = Math . sqrt ( canvasImg . naturalWidth ** 2 + canvasImg . naturalHeight ** 2 ) / 2 ;
491+ if ( newValue < maxDiameter ) {
492+ input . setAttribute ( "max" , newValue ) ;
493+ }
494+ }
495+ }
496+ input . value = Math . max ( newValue , 1 ) ;
487497 input . dispatchEvent ( new Event ( "change" ) ) ;
488498 }
489499 }
You can’t perform that action at this time.
0 commit comments