
    4j*                        S r SSKrSrS rS rS$S jrS%S jrS&S jr\S	:X  G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       HU  u  rr\	R                  R                  \S\ S35      r\" \SSS9 r\R1                  \" \S95        SSS5        \" S\5        MW     SSS.SSS.SSS.SSS.S S!S./r\	R                  R                  \S"5      r\" \SSS9 r\R1                  \" \S#95        SSS5        \" S\5        gg! , (       d  f       N~= f! , (       d  f       N*= f)'a  Semicircular protractor SVG generator for AGS Math instruments.

generate(angle, size) -> str  (self-contained SVG)

  - Cream semicircle face with an ink outline.
  - Steel-blue degree ticks around the arc; minors every 10 deg,
    longer majors with numeric labels every 30 deg.
  - Gold horizontal baseline through the centre.
  - Crimson ray from the centre at the given `angle` (0-180, measured
    anticlockwise from the right-hand baseline, standard protractor).
  - D0ACAC rounded border frame; CSS-var style block.
    Nz<style>svg{--crimson:#960000;--gold:#BF9237;--lime:#88C808;--steel:#4A6488;--cream:#FAF5EE;--ink:#2A2A2A;--border:#D0ACAC;}</style>c                     [         R                  " U5      nX[         R                  " U5      -  -   X[         R                  " U5      -  -
  4$ )z?Point at `deg` measured anticlockwise from the +x (right) axis.)mathradianscossin)cxcyrdegas        ;C:\allgifted\mathapi11v2\tools\svg_generators\protractor.py_ptr      s9    SADHHQK$((1+o!555    c                 @   U n[        U S-  5      nUS-  nUS-
  n[        US-  S-
  US-
  5      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        [	        X4US5      u  px[	        X4US5      u  pUR                  SU	S SU
S SUS SUS SUS SUS S35        [        SSS5       H  nUS-  S:H  nU(       a  SOSn[	        X4X[5      u  p[	        X4X]-
  U5      u  nnUR                  SUS SUS SUS SUS SU(       a  SOS S35        U(       d  Mm  [	        X4US-
  U5      u  nnUR                  S US S!US S"U S#35        M     UR                  SU	S SUS SUS SUS S$3	5        XcXEX4$ )%zBuild the cream protractor face (frame, semicircle, ticks, baseline).

Returns (parts, cx, cy, R, width, height) so callers can append rays
before closing the </svg>.
gףp=
?         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"/>r      z<path d="M .2fz A z 0 0 1 zV Z" fill="var(--cream)" stroke="var(--ink)" stroke-width="3" stroke-linejoin="round"/>   
      	   
<line x1="" y1="" x2="" y2="z&" stroke="var(--steel)" stroke-width="g@g333333?z"/>	<text x="" y="zo" font-family="sans-serif" font-size="12" fill="var(--steel)" text-anchor="middle" dominant-baseline="central"></text>zB" stroke="var(--gold)" stroke-width="3.5" stroke-linecap="round"/>)intminappendSTYLEr   range)sizewidthheightr   r	   Rpartslxlyrxryr   is_majortlenx1y1x2y2lxplyps                       r   _facer9      sG    EF	B	"BEAINBG$AE	LL
9%
6( Swaxr	+ 
LL 
LL
#E!G9Jvaxj A@ 	A AFBC FB	LL
bXQr#hc!C!C3xqC Q$ 	% QR "HMr1RQ$RQXs+BCr#hfRHF2c( K3:B32LCQ	
 821r63/HCLLC9E#c 3//2e7< !$ 
LL
RHF2c(&Cr#h GK 	L
 bU**r   c                     [        XUS-
  U5      u  pgU R                  SUS SUS SUS SUS S3	5        Ub7  US	:w  a0  [        XUS
-   U5      u  pU R                  SUS SU	S SU S35        ggg)zEAppend a crimson ray from centre at `angle`, with optional rim label.   r   r   r   r   r   zE" stroke="var(--crimson)" stroke-width="3.5" stroke-linecap="round"/>N    r    r!   z" font-family="sans-serif" font-size="14" font-weight="bold" fill="var(--crimson)" text-anchor="middle" dominant-baseline="central">r"   )r   r%   )
r,   r   r	   r+   anglelabelexeyr-   r.   s
             r   _rayrB   X   s    Q&FB	LL
RHF2c(&Cr#h GN 	O Ub[RQVU+3xuRH -@@EwgO	
 )r   c           	          [        S[        S[        U 5      5      5      n [        U5      u  p#pEpg[	        X#XEU 5        UR                  SUS SUS S35        UR                  S5        SR                  U5      $ )	N             f@<circle cx="r   " cy="" r="5" fill="var(--crimson)"/></svg>
)maxr$   floatr9   rB   r%   join)r>   r(   r,   r   r	   r+   r)   r*   s           r   generaterN   i   sr    Se-.E&+Dk#Ere 	B5!	LL<3xvbX5TUV	LL99Ur   c                 `   U =(       d    / n U SS n [        U5      u  p#pEpgU  HN  n[        S[        S[        UR	                  SS5      5      5      5      n	[        X#XEXR	                  S5      5        MP     UR                  SUS	 S
US	 S35        UR                  S5        SR                  U5      $ )zDraw the protractor once with multiple labelled crimson rays.

rays : list of dicts {"angle": float (0-180), "label": str}. Up to 6.
Backward-compatible companion to generate(angle=..).
Nr   rD   rE   r>   r   r?   rF   r   rG   rH   rI   rJ   )r9   rK   r$   rL   getrB   r%   rM   )
raysr(   r,   r   r	   r+   r)   r*   entryangs
             r   generate_raysrT   w   s     :2D8D&+Dk#Ere#s5%		'1(=">?@UsIIg$67 
 
LL<3xvbX5TUV	LL99Ur   __main__z..samplesT)exist_ok)-   Z         protractor_z.svgwzutf-8)encoding)r>   wroter   A)r>   r?   K   Bn   C   D   Ezprotractor_rays_1.svg)rQ   )N)rX   T  )Nri   )__doc__r   r&   r   r9   rB   rN   rT   __name__ospathabspathrM   dirname__file__outmakedirsrV   	enumerateirS   popenfwriteprintrQ    r   r   <module>r{      sq   O 6:+z
", z
''//"'',,rwwx'@$	R
SCKKd#GGQ'3GGLLA3d34!S7+qGGH3'( ,gq	 ( s#s#$$$D 	S12A	aw	'1	4() 
(	'1+  ,+ 
(	's   E)E#
E 	#
E1