ó
    öµj$  ã                   óü  • S r SSKrSrSrSrS rSS jr\S:X  aÑ  SSKr\R                  R                  \R                  R                  \R                  R                  \5      S	S
5      5      r\R                  " \SS9  / SQr\" \S5       H[  u  ru  rr\R                  R                  \S\ S35      r\" \SSS9 r\R1                  \" \\5      5        SSS5        \" S\5        M]     gg! , (       d  f       N= f)a¸  Two-pan balance scale SVG generator for AGS Math instruments.

generate(left_value, right_value) -> str  (self-contained SVG)

Tilt formula:
  The beam tilts toward the heavier side. Tilt angle (deg) is proportional
  to the signed difference (left - right):

      tilt = clamp(K * (left - right), -MAX, +MAX)

  with K = 3.0 deg per unit and MAX = 15 deg. Positive tilt lowers the LEFT
  pan (heavier-left dips down). When left == right the beam is level (0 deg).

  Sign convention for SVG (y grows downward): the beam is rotated about the
  central fulcrum by `tilt` degrees. The left end goes DOWN when left heavier.
  In screen rotation terms, rotating by +tilt (clockwise) raises the left and
  lowers the right, so we apply a rotation of -tilt to dip the heavier side.

The pans hang from the beam ends and move up/down with the tilt, but the pan
faces stay horizontal (they are not rotated, only translated to the rotated
beam-end positions).
é    Nzƒ<style>svg{--crimson:#960000;--gold:#BF9237;--lime:#88C808;--steel:#4A6488;--cream:#FAF5EE;--ink:#2A2A2A;--border:#D0ACAC;}</style>g      @g      .@c                 ó,   • [        U[        X 5      5      $ )N)ÚmaxÚmin)ÚvÚloÚhis      Ú>C:\allgifted\mathapi11v2\tools/svg_generators/balance_scale.pyÚ_clampr
   "   s   € Üˆr”3�r“:ÓÐó    c                 ó¬  • [        U 5      [        U5      -
  n[        [        U-  [        * [        5      nUS-  nSnSn/ n	U	R	                  SU SU SU SU S3	5        U	R	                  [
        5        U	R	                  S	US
-
   SUS
-
   S35        US-
  n
U	R	                  SUS
-
   SU SX§-
   S35        U	R	                  SUS-
   SU
 S35        [        R                  " U* 5      nXh* [        R                  " U5      -  -   nXx* [        R                  " U5      -  -   nXh[        R                  " U5      -  -   nXx[        R                  " U5      -  -   nU	R	                  SUS SUS SUS SUS S3	5        U	R	                  SUS-
   SUS-    SUS-    SUS-    SU SUS
-
   S35        SnSnXÍ4Xï44 Hµ  u  nnUU-   nU	R	                  SUS SUS SUUS-  -
  S SUS S3	5        U	R	                  SUS SUS SUUS-  -   S SUS S3	5        U	R	                  S UUS-  -
  S SUS S!US SUS"-   S SUUS-  -   S SUS S#35        U	R	                  S$US S%US S&US-  S S'35        M·     U	R	                  S(US SUU-   S-   S S)U  S*35        U	R	                  S(US SUU-   S-   S S)U S*35        U	R	                  S+5        S,R                  U	5      $ )-Né   éZ   éx   z/<svg xmlns="http://www.w3.org/2000/svg" width="z
" height="z" viewBox="0 0 Ú z">z<rect x="3" y="3" width="é   zG" rx="18" ry="18" fill="none" stroke="var(--border)" stroke-width="4"/>é   z	<rect x="z" y="z" width="12" height="z" fill="var(--ink)"/>é2   z4" width="100" height="14" rx="6" fill="var(--ink)"/>z
<line x1="z.2fz" y1="z" x2="z" y2="zA" stroke="var(--steel)" stroke-width="8" stroke-linecap="round"/>z<polygon points="é   Ú,é   éF   éP   z*" stroke="var(--steel)" stroke-width="2"/>z<path d="M z Q é   z? Z" fill="var(--gold)" stroke="var(--ink)" stroke-width="1.5"/>z<ellipse cx="z" cy="z" rx="zD" ry="5" fill="var(--gold)" stroke="var(--ink)" stroke-width="1.5"/>z	<text x="zd" font-family="sans-serif" font-size="20" font-weight="bold" fill="var(--ink)" text-anchor="middle">z</text>z</svg>Ú
)Úfloatr
   ÚK_DEG_PER_UNITÚMAX_TILTÚappendÚSTYLEÚmathÚradiansÚcosÚsinÚjoin)Ú
left_valueÚright_valueÚwidthÚheightÚdiffÚtiltÚcxÚfyÚarmÚpartsÚbase_yÚaÚlxÚlyÚrxÚryÚpan_dropÚpan_wÚexÚeyÚpys                        r	   Úgenerater:   &   së  € Ü�Óœu [Ó1Ñ1€DÜ”. 4Ñ'¬(¨´HÓ=€Dà	�‰€BØ	€BØ
€CØ€EØ	‡L�LØ
9¸%¸À
È6È(ð SØ�w˜a ˜x rð	+ôð 
‡L�L”Ôð 
‡L�LØ
# E¨!¡G 9¨J°v¸a±x°jð A@ð 	Aôð �b‰[€FØ	‡L�LØ
�B�q‘D�6˜˜r˜dÐ"7¸¹	°{ð Cð 	ôð 
‡L�LØ
�B�r‘E�7˜% ˜xð (ð 	ôô 	�Š�d�UÓ€Aà	ˆt”t—x’x “{Ñ"Ñ	"€BØ	ˆt”t—x’x “{Ñ"Ñ	"€BØ	”d—h’h˜q“kÑ!Ñ	!€BØ	”d—h’h˜q“kÑ!Ñ	!€Bð 
‡L�LØ
�R˜�H˜F 2 c (¨&°°C°¸¸rÀ#¸hð GJð 	Kôð 
‡L�LØ
˜B˜r™E˜7 ! B r¡E 7¨!¨B¨r©E¨7°!°B°r±E°7¸!¸B¸4¸qÀÀAÁÀð Gð 	ôð €HØ€EØ�X ˜xÓ(‰ˆˆRØ�(‰]ˆà�‰Ø˜˜C˜  r¨# h¨f°R¸¸a¹±ZÀÐ4DÀFÈ2ÈcÈ(ð S7ð 8ô	
ð 	�‰Ø˜˜C˜  r¨# h¨f°R¸¸a¹±ZÀÐ4DÀFÈ2ÈcÈ(ð S7ð 8ô	
ð
 	�‰Ø˜"˜U 1™W™* SÐ)¨¨2¨c¨(ð 3Ø�C�˜˜"˜R™% ˜ A b¨¨q©¡j°Ð%5°Q°r¸#°hð ?JðKô	
ð
 	�‰Ø˜B˜s˜8 6¨"¨S¨°¸¸a¹À°}ð EJð Kö	
ñ# )ð. 
‡L�LØ
�B�s�8˜5  H¡¨R¡°Ð 4ð 5 à *˜|¨7ð	4ôð
 
‡L�LØ
�B�s�8˜5  H¡¨R¡°Ð 4ð 5 à +˜}¨Gð	5ôð 
‡L�L�ÔØ�9‰9�UÓÐr   Ú__main__z..ÚsamplesT)Úexist_ok))é   r>   )é   é   )r   é	   é   Úbalance_scale_z.svgÚwzutf-8)ÚencodingÚwrote)r>   r>   ih  i@  )Ú__doc__r    r   r   r   r
   r:   Ú__name__ÚosÚpathÚabspathr$   ÚdirnameÚ__file__ÚoutÚmakedirsr<   Ú	enumerateÚiÚlÚrÚpÚopenÚfÚwriteÚprint© r   r	   Ú<module>rZ      sõ   ðñó, ðOð ð
 €Ø€òô\ð~ ˆzÓÛØ
�'‰'�/‰/˜"Ÿ'™'Ÿ,™, r§w¡w§¡°xÓ'@À$È	ÓRÓ
S€CØ‡K‚K�˜dÒ#Ú&€GÙ˜w¨Ö*‰	ˆ‰6ˆAˆqØ�G‰G�L‰L˜ ¨q¨c°Ð6Ó7ˆÙ�!�S 7Ò+¨qØ�G‰G‘H˜Q “NÔ#÷ ,áˆg�qÖò	 +ð ÷ ,Õ+ús   Â=C-Ã-
C;	