File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -645,6 +645,23 @@ class ResolutionMasterCanvas {
645645 ctx . stroke ( ) ;
646646 }
647647
648+ static gcd ( a , b ) {
649+ a = Math . abs ( Math . floor ( Number ( a ) ) ) || 1 ;
650+ b = Math . abs ( Math . floor ( Number ( b ) ) ) || 1 ;
651+
652+ while ( b !== 0 ) {
653+ const t = a % b ;
654+ a = b ;
655+ b = t ;
656+ }
657+ return a ;
658+ }
659+
660+ static aspectRatioString ( w , h ) {
661+ const g = ResolutionMasterCanvas . gcd ( w , h ) ;
662+ return `${ w / g } :${ h / g } ` ;
663+ }
664+
648665 drawInfoText ( ctx , y ) {
649666 const node = this . node ;
650667 if ( this . widthWidget && this . heightWidget ) {
@@ -653,21 +670,7 @@ class ResolutionMasterCanvas {
653670 const mp = ( ( width * height ) / 1000000 ) . toFixed ( 2 ) ;
654671 const pResolution = this . getClosestPResolution ( width , height ) ;
655672
656- function gcd ( a , b ) {
657- while ( b !== 0 ) {
658- const t = a % b ;
659- a = b ;
660- b = t ;
661- }
662- return a ;
663- }
664-
665- function aspectRatioString ( w , h ) {
666- const g = gcd ( w , h ) ;
667- return `${ w / g } :${ h / g } ` ;
668- }
669-
670- const aspectRatio = aspectRatioString ( width , height ) ;
673+ const aspectRatio = ResolutionMasterCanvas . aspectRatioString ( width , height ) ;
671674
672675 ctx . fillStyle = "#bbb" ;
673676 ctx . font = "12px Arial" ;
You can’t perform that action at this time.
0 commit comments