1616from tqdm import tqdm
1717
1818from .commons import config_path_option , verbosity_option
19- from .config import Config , PresentationConfig , SlideConfig , SlideType
19+ from .config import DEFAULT_CONFIG , Config , PresentationConfig , SlideConfig , SlideType
2020from .defaults import FOLDER_PATH
2121from .manim import logger
2222
3333 "keep" : Qt .KeepAspectRatio ,
3434}
3535
36+ RESIZE_MODES = {
37+ "fast" : Qt .FastTransformation ,
38+ "smooth" : Qt .SmoothTransformation ,
39+ }
40+
3641
3742@unique
3843class State (IntEnum ):
@@ -284,7 +289,7 @@ class Display(QThread):
284289 def __init__ (
285290 self ,
286291 presentations ,
287- config : Config = Config () ,
292+ config : Config = DEFAULT_CONFIG ,
288293 start_paused = False ,
289294 skip_all = False ,
290295 record_to = None ,
@@ -517,18 +522,20 @@ class App(QWidget):
517522 def __init__ (
518523 self ,
519524 * args ,
520- config : Config = Config () ,
525+ config : Config = DEFAULT_CONFIG ,
521526 fullscreen : bool = False ,
522527 resolution : Tuple [int , int ] = (1980 , 1080 ),
523528 hide_mouse : bool = False ,
524529 aspect_ratio : Qt .AspectRatioMode = Qt .IgnoreAspectRatio ,
530+ resize_mode : Qt .TransformationMode = Qt .SmoothTransformation ,
525531 ** kwargs ,
526532 ):
527533 super ().__init__ ()
528534
529535 self .setWindowTitle (WINDOW_NAME )
530536 self .display_width , self .display_height = resolution
531537 self .aspect_ratio = aspect_ratio
538+ self .resize_mode = resize_mode
532539 self .hide_mouse = hide_mouse
533540 self .config = config
534541 if self .hide_mouse :
@@ -584,7 +591,9 @@ def closeAll(self):
584591 self .deleteLater ()
585592
586593 def resizeEvent (self , event ):
587- self .pixmap = self .pixmap .scaled (self .width (), self .height (), self .aspect_ratio )
594+ self .pixmap = self .pixmap .scaled (
595+ self .width (), self .height (), self .aspect_ratio , self .resize_mode
596+ )
588597 self .label .setPixmap (self .pixmap )
589598 self .label .resize (self .width (), self .height ())
590599
@@ -615,6 +624,7 @@ def convert_cv_qt(self, cv_img):
615624 self .width (),
616625 self .height (),
617626 self .aspect_ratio ,
627+ self .resize_mode ,
618628 )
619629 return QPixmap .fromImage (p )
620630
@@ -708,6 +718,13 @@ def _list_scenes(folder) -> List[str]:
708718 help = "Set the aspect ratio mode to be used when rescaling video." ,
709719 show_default = True ,
710720)
721+ @click .option (
722+ "--resize-mode" ,
723+ type = click .Choice (RESIZE_MODES .keys (), case_sensitive = False ),
724+ default = "smooth" ,
725+ help = "Set the resize (i.e., transformation) mode to be used when rescaling video." ,
726+ show_default = True ,
727+ )
711728@click .help_option ("-h" , "--help" )
712729@verbosity_option
713730def present (
@@ -722,6 +739,7 @@ def present(
722739 exit_after_last_slide ,
723740 hide_mouse ,
724741 aspect_ratio ,
742+ resize_mode ,
725743) -> None :
726744 """
727745 Present SCENE(s), one at a time, in order.
@@ -813,6 +831,7 @@ def value_proc(value: str) -> List[str]:
813831 exit_after_last_slide = exit_after_last_slide ,
814832 hide_mouse = hide_mouse ,
815833 aspect_ratio = ASPECT_RATIO_MODES [aspect_ratio ],
834+ resize_mode = RESIZE_MODES [resize_mode ],
816835 )
817836 a .show ()
818837 sys .exit (app .exec_ ())
0 commit comments