
    +j                     B   U d dl Z d dlmZ d dlmZ d dlmZmZ  G d dee          Z	e	j
        de	j        de	j        d	e	j        d
e	j        de	j        de	j        de	j        diZee	eeef         f         ed<    G d dej                  Z G d de          ZdefdZdS )    N)Enum)override)ComfyExtensionioc                   .    e Zd ZdZdZdZdZdZdZdZ	dZ
d	S )
AspectRatioz1:1 (Square)z2:3 (Portrait Photo)z3:2 (Photo)z3:4 (Portrait Standard)z4:3 (Standard)z9:16 (Portrait Widescreen)z16:9 (Widescreen)z21:9 (Ultrawide)N)__name__
__module____qualname__SQUAREPHOTO_VPHOTO_H
STANDARD_V
STANDARD_HWIDESCREEN_VWIDESCREEN_HULTRAWIDE_H     =/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_resolution.pyr   r      s6        F$GG*J!J/L&L$KKKr   r   )   r   )      )r   r   )r      )r   r   )	      )r   r   )   r   ASPECT_RATIOSc            	       Z    e Zd ZdZed             Zedededede	j
        fd            ZdS )	ResolutionSelectorzBCalculate width and height from aspect ratio and megapixel target.c                    t          j        ddddt           j                            dt          t          j        d          t           j                            dd	d
dd
d          t           j                            ddddddd          gt           j                            dd          t           j                            dd          g          S )Nr    zResolution Selector	utilitieszwCalculate width and height from aspect ratio and megapixel target. Useful for setting up Empty Latent Image dimensions.aspect_ratioz+The aspect ratio for the output dimensions.)optionsdefaulttooltip
megapixelsg      ?g?g      0@u9   Target total megapixels. 1.0 MP ≈ 1024x1024 for square.)r%   minmaxstepr&   multiple      r   zANearest multiple of the result to set the selected resolution to.T)idr%   r(   r)   r*   r&   advancedwidthz?Calculated width in pixels multiplied by the selected multiple.)r&   heightz@Calculated height in pixels multiplied by the selected multiple.)node_iddisplay_namecategorydescriptioninputsoutputs)	r   SchemaComboInputr   r   FloatIntOutput)clss    r   define_schemaz ResolutionSelector.define_schema!   s    y(.  R"''.I	     W    !_!   4 %f    &h   	=&
 &
 &
 &	
r   r#   r'   r+   returnc                     t           |         \  }}|dz  dz  }t          j        |||z  z            }t          ||z  |z            |z  }t          ||z  |z            |z  }	t	          j        ||	          S )Ni   )r   mathsqrtroundr   
NodeOutput)
r>   r#   r'   r+   w_ratioh_ratiototal_pixelsscaler0   r1   s
             r   executezResolutionSelector.executeK   s    (6!D(4/	,'G*;<==go011H<w122X=}UF+++r   N)r	   r
   r   __doc__classmethodr?   strfloatintr   rE   rJ   r   r   r   r    r       sr        LL'
 '
 ['
R ,3 ,E ,S ,R] , , , [, , ,r   r    c                   L    e Zd Zedeeej                          fd            ZdS )ResolutionExtensionr@   c                    K   t           gS N)r    )selfs    r   get_node_listz!ResolutionExtension.get_node_listV   s       
 	
r   N)	r	   r
   r   r   listtyper   	ComfyNoderU   r   r   r   rQ   rQ   U   sE        
T$r|*<%= 
 
 
 X
 
 
r   rQ   r@   c                  "   K   t                      S rS   )rQ   r   r   r   comfy_entrypointrZ   ]   s         r   )rB   enumr   typing_extensionsr   comfy_api.latestr   r   rM   r   r   r   r   r   r   r   r   r   r   dicttuplerO   __annotations__rX   r    rQ   rZ   r   r   r   <module>ra      sa          & & & & & & / / / / / / / /% % % % %#t % % % FFggW	5tKsCx01 	 	 	4, 4, 4, 4, 4, 4, 4, 4,n
 
 
 
 
. 
 
 
! 3 ! ! ! ! ! !r   