)Ej UdZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z mZmZmZmZmZmZmZmZmZmZmZmZdd lmZd d lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%d d l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1d d l2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:d dl;mZ>m?Z?d dl@mAZAmBZBmCZCmDZDe rddlEmFZFd dlGmHZHmIZId dlJmKZKmLZLmMZMe ZNeeOd<GddZPGddePZQGddeZReddZSGddZTeGddeZUd e!d!eVfd"ZWd e!d!eVfd#ZXd$e!d%e!d&e!d!eVfd'ZYGd(d)eZZGd*d+eZ[Gd,d-eZ\Gd.d/eZ]Gd0d1eZ^Gd2d3eZ_Gd4d5eZ`Gd6d7eZad8ebd9ebd:ebd;ebd N) OrderedDict)contextmanager)deepcopy) dataclass) EllipsisType) TYPE_CHECKINGAny GeneratorIterator NamedTupleOptionalProtocolSequence TypeAliasTypeVarUnioncastruntime_checkable)BasePen) Color DeviceCMYK DeviceGray DeviceRGBPoint Transform check_rangecolor_from_hex_stringforce_nodocument) BlendModeClippingPathIntersectionRuleCompositingOperationGradientSpreadMethod GradientUnitsIntersectionRule PathPaintRulePDFResourceType PDFStyleKeysStrokeCapStyleStrokeJoinStyle)GradientLinearGradient MeshShadingPatternRadialGradient SweepGradientshape_linear_gradientshape_radial_gradient)Name PDFObjectRawrender_pdf_primitive)FloatToleranceNumber NumberClass number_to_str) ttGlyphSet)CoreFontTTFFont)PDFFont PDFType3FontResourceCatalog InheritTypecJeZdZdZdZejdddfdeddeeefde d d e d e eee ff d Z d e ddd fdZ dddeezdd defdZddd e ddefdZddd e ddefdZde fdZdddd d ddefdZd e ddeezfdZdS) GradientPaintz"Fill/stroke paint using a gradient)gradientunitsgradient_transformapply_page_ctm skip_alpha spread_methodNTrD)r+r0rErFrrGrIc||_tj||_|pt j|_||_d|_|tj|n tj |_ dSNF) rDr$coercerEridentityrFrGrHr#PADrI)selfrDrErFrGrIs >C:\PYTHON\MyICR_Suite\python\Lib\site-packages\fpdf/drawing.py__init__zGradientPaint.__init__]sq! ")%00 "4"L 8J8L8L,( ! ' 6 6 6%) bbox BoundingBoxreturnc|jtjkrD|tdt |jdd|j|j|j}|j |zS|j S)zCReturn the final /Matrix for this gradient, given an optional bbox.Nz7GradientPaint requires bbox for objectBoundingBox unitsr)abcdef) rEr$OBJECT_BOUNDING_BOX RuntimeErrorrwidthheightx0y0rF)rOrS matrix_bboxs rP _matrix_forzGradientPaint._matrix_forpsp :: : :|"M$*Q$+DGK*[8 8&&rRresource_catalogr@matrixc |tj|dt||}||j|tj|d}|J|S)zVCreate a Pattern with the given matrix, register shading+pattern, return pattern name.N)addr'SHADINGr. set_matrixset_apply_page_ctmrGPATTERN)rOrerDrfpattern resource_ids rP_register_patternzGradientPaint._register_patterns} _4hEEE(##..v66""4#6777&**?+BGTRR &&&rRc|jtjkrtddddn|}||}||}||||}d|dSN?z /Pattern cs /z scnrEr$r]rT _get_gradient_with_spread_methodrdrorOrerS domain_bboxrDrf pattern_names rP emit_fillzGradientPaint.emit_fill z]>>> S#s + + +  88EE!!$''--.>&QQ 1|1111rRc|jtjkrtddddn|}||}||}||||}d|dSNrrrsz /Pattern CS /z SCNrtrvs rP emit_strokezGradientPaint.emit_strokerzrRcD|jo|j SN)rD has_alpharHrOs rPrzGradientPaint.has_alphas }&&((@-@@rRc||j|}|td|tj|dt ||}|d|tj |d}t|tsJ|S)Nz0Alpha gradient requested but no alpha ramp foundF) rDget_alpha_shading_objectr^rhr'rir.rjrkrl isinstancestr)rOrerfrS alpha_shading alpha_pattern pattern_ids rP_register_alpha_patternz%GradientPaint._register_alpha_patterns  >>tDD  QRR R_4mTJJJ ..99&AA ((///%))/*A=RVWW *c*****rRc t|jtr/|j|j_|J|j|S|jt jkr|jSt|jtr|jj\}}}}t|jdd}|V|jj }|jj }d|dfgtt||ddzd|dfgz} n|} |} |U|jtjkr@ ||j} n#t($r|} YnwxYwt+||||| |j| St|jt,r|jj\} } } }}}t|jdd}|V|jj }|jj }d|dfgtt||ddzd|dfgz} n|} |} |U|jtjkr@ ||j} n#t($r|} YnwxYwt/|||| | | | |j| S|jS) z Now that the bbox is known, we can construct a new gradient stop line to apply the spread method reflect or repeat. N raw_stopsrrrrrs)rIrS)fxfyfrrIrS)rrDr0rIget_shading_objectr#rNr,coordsgetattrcolorsboundslistziprEr$USER_SPACE_ON_USE transformedrFinverse ValueErrorr1r/r2)rOrSx1y1x2y2rrrstops spread_bboxrrrcxcyrs rPruz.GradientPaint._get_gradient_with_spread_methods dm] 3 3 :*.*>> S#s + + +  &&&!!$''33 fk  2|1111rRc|jtjkrtddddn|}|J||}||||}d|dSr|rrs rPr}z_AlphaGradientPaint.emit_strokerrRcdSrKrrs rPrz_AlphaGradientPaint.has_alpha-surRN) rrrr rryr}rrrrRrPrr s 2 1 29A-9P 2  2 2 2 2 2 1 29A-9P 2  2 2 2 24rRrc eZdZUdZeed<eed<eed<eed<ed&dZdefdZ ed e e ddfd Z d'd Z d eddfdZd(dedeeddfdZ d)dddeeefddfdZdeeeeeffdZdefdZdeeeefeeefeeefeeefffdZdededededeeeeff dZdededefd Zedefd!Zedefd"Zdefd#Zd edefd$Zde fd%Z!dS)*rTzSRepresents a bounding box, with utility methods for creating and manipulating them.rarbrrrUc|tdtdtdtdS)z\ Return an 'empty' bounding box with extreme values that collapse on merge. inf-inf)float)clss rPemptyzBoundingBox.empty9s2 s5<<uuV}}eFmmLLLrRcB|j|jko|j|jkS)z-Return True if the bounding box is not empty.)rarrbrrs rPis_validzBoundingBox.is_valid@sw$'!8dg&88rRpointscd|D}d|D}|t|t|t|t|S)zEGiven a list of points, create a bounding box that encloses them all.c6g|]}t|jSr)rx.0ps rP z+BoundingBox.from_points..G ) ) )QeACjj ) ) )rRc6g|]}t|jSr)ryrs rPrz+BoundingBox.from_points..HrrR)minmax)rrxsyss rP from_pointszBoundingBox.from_pointsDsX* )& ) ) ) ) )& ) ) )s3r77CGGSWWc"gg666rRotherc >|s|S|s|Stt|j|jt|j|jt |j|jt |j|jS)z0Expand this bounding box to include another one.)rrTrrarbrrrrOrs rPmergezBoundingBox.mergeKs}} L~~ K  " "  " "  " "  " "    rRtfc t|j|jt|j|jt|j|jt|j|jg}fd|D}t |S)z\ Return a new bounding box resulting from applying a transform to this one. cg|]}|zSrr)rptrs rPrz+BoundingBox.transformed..bs888"b2g888rR)rrarbrrrTr)rOrcornerstransformed_pointss ` rPrzBoundingBox.transformedXs $'47 # # $'47 # # $'47 # # $'47 # #   9888888&&'9:::rRNdxdycn||}t|j|z |j|z |j|z|j|zS)zJReturn a new bounding box expanded by the given amounts in each direction.)rTrarbrrrOrrs rPexpandedzBoundingBox.expandedes8 :B47R<2tw|TWr\RRRrRrsrsstyle GraphicsStyle row_normsc|tjtjtjfvr|St |jtrt|jdkr|S|j t |j trdn|j }|dkr|Sd|z}|\}}| ||z||zS)zDExpand this bbox to include stroke coverage, given a graphics style.rrNrs?) resolve_paint_ruler&STROKESTROKE_FILL_NONZEROSTROKE_FILL_EVENODDrstroke_opacityr9r stroke_widthrAr)rOrrwrnxnys rPexpanded_to_strokezBoundingBox.expanded_to_strokeks ''))   -  -.   K e*K 8 8 U)**c11 !)Z8JK-X-X) D# 88K !GB}}QVQV,,,rRc6|j|j|j|jfS)z"Convert bounding box to a 4-tuple.rarbrrrs rPto_tuplezBoundingBox.to_tuples$'4733rRc dt|jdt|jdt|jdt|jd S)z+Convert bounding box to a PDF array string.[ ])r:rarbrrrs rP to_pdf_arrayzBoundingBox.to_pdf_arraysXw=))wwM$',B,Bww]SWSZE[E[ww^klpls^t^twwwwrRcn|j|jf|j|jf|j|jf|j|jffS)z9Clockwise corners (x,y): (x0,y0),(x1,y0),(x1,y1),(x0,y1).rrs rPrzBoundingBox.cornerss>Wdg  Wdg  Wdg  Wdg    rRrrc*||z ||z }}tj||}|dkrdS||z ||z } }g} |D]-\} } | |z | |z }} | | |z|| zz.t | t | |fS)z Project bbox corners onto the axis from (x1,y1) to (x2,y2). Returns (tmin, tmax, L) where: - L is the axis length - t are distances along the axis with t=0 at (x1,y1) rr)rrrrrr)mathhypotrappendrr)rOrrrrvxvyLuxuytsXYrrs rPproject_interval_on_axisz$BoundingBox.project_interval_on_axissr'R"WB Jr2   88 =aaBLLNN ) )DAq"fBB IIb2gR' ( ( ( (2wwB""rRrrcbtfd|DS)z7Max Euclidean distance from (cx,cy) to any bbox corner.c3TK|]"\}}tj|z |z V#dSr)rr)rrrrrs rP z4BoundingBox.max_distance_to_point..s;KK&1a4:a"fa"f--KKKKKKrR)rr)rOrrs ``rPmax_distance_to_pointz!BoundingBox.max_distance_to_points2KKKKKDLLNNKKKKKKrRc |j|jz S)z%Return the width of the bounding box.)rrars rPr_zBoundingBox.widthw  rRc |j|jz S)z&Return the height of the bounding box.)rrbrs rPr`zBoundingBox.heightrrRc Hd|jd|jd|jd|jd S)Nz BoundingBox(z, )rrs rP__str__zBoundingBox.__str__s3IdgIIIIDGIItwIIIIrRc(t|tsdStj|j|jo\tj|j|jo=tj|j|jotj|j|jSrK)rrTr7equalrarbrrrs rP__eq__zBoundingBox.__eq__s%-- 5  %( 3 3 8$TWeh77 8$TWeh77 8$TWeh77  rRc tt|jdt|jdt|jdt|jdfS)N)hashroundrarbrrrs rP__hash__zBoundingBox.__hash__sUdgq!!dgq!!dgq!!dgq!!     rR)rUrT)rrTrUrTr)r)"rrrrr__annotations__ classmethodrrrrrrrrrr rtuplerrrrrrrpropertyr_r`r objectr intrrrRrPrTrT1s#]] III III III IIIMMM[M 9$99997e7777[7      ;i ;M ; ; ; ;SS5ShuoSSSSSHR--$-16ue|1D- ----@4%ueU :;4444xcxxxx  eUl eUl eUl eUl      ##"#(-#38# ueU" #####(LL5LULLLL!u!!!X!!!!!X!JJJJJ F t      #       rRrTGSr)boundceZdZUdZdZeedeDzZdZ dZ ej j ej j ej j ejj fZ gdeDRZ eiejedhejedejhejedejhejeddejhejeddejhejiZeeeezefed < e d=d Z!d>dZ"de#dee$e%fd e#fdZ&dede%d dffd Z'e(d e)e*zfdZ+e+j,de)e*zd dffd Z+e(d ee*zdzfdZ-e-j,dee*zezdzd dffd Z-e(d e)e*zfdZ.e.j,de)e*zd dffd Z.e(d ee*zfdZ/e/j,dee*zezd dffd Z/e(d e0e1ze*zezdzfdZ2e2j,d e0e1zeze*zdzd dffd! Z2e(d e3e*zdzfd"Z4e4j,de3e*zdzd dffd# Z4e(d e0e1ze*zdzfd$Z5e5j,d e0e1zeze*zdzd dffd% Z5e(d e3e*zdzfd&Z6e6j,de3e*zdzd dffd' Z6e(d e7e*zfd(Z8e8j,de7eze*zd dffd) Z8e(d e3e*zdzfd*Z9e9j,d+e3e*zdzd dffd, Z9e(d e:e*zfd-Z;e;j,de:eze*zd dffd. Z;e(d ee>j,de?e*zd dffd2 Z>e(d e@e*ee3dfzfd3ZAeAj,dde*ze?zeBe?zd dffd4 ZAe(d e*e3zfd5ZCeCj,de*e?zd dffd6 ZCe(d eDe*d7d8ffd9ZEeEj,deDe*d7d8fd dffd: ZEd e@eFfd;ZGeHd efd<ZIxZJS)?ra A class representing various style attributes that determine drawing appearance. This class uses the convention that the global Python singleton ellipsis (`...`) is exclusively used to represent values that are inherited from the parent style. This is to disambiguate the value None which is used for several values to signal an explicitly disabled style. An example of this is the fill/stroke color styles, which use None as hints to the auto paint style detection code. )_allow_transparency _auto_close _fill_color_intersection_rule _paint_rule _stroke_color_stroke_dash_pattern_stroke_dash_phasec#@K|]}|tju|jVdSrr(STROKE_DASH_PATTERNvaluerks rPrzGraphicsStyle.s@'' L4 4 4  5 4 4 4 ''rR.) paint_ruleallow_transparency auto_closeintersection_rule fill_color fill_opacity stroke_colorr blend_moderstroke_cap_stylestroke_join_stylestroke_miter_limitstroke_dash_patternstroke_dash_phase soft_maskc#@K|]}|tju|jVdSrr%r(s rPrzGraphicsStyle. s1 U Ua1L4T+T+T!'+T+T+T+T U UrRstrokefill_PAINT_RULE_LOOKUPparentchildrUc t|}|jD]:}t||}||jurt ||t||;|S)aA Merge parent and child into a single GraphicsStyle. The result contains the properties of the parent as overridden by any properties explicitly set on the child. If both the parent and the child specify to inherit a given property, that property will preserve the inherit value. )rrrINHERITsetattr)rr<r=newpropcvals rPrzGraphicsStyle.merge2s^uooM : :D3%%Ds{""T764#8#8999 rRNcF|jD]}t|||jdSr)rr@r?)rOkeys rPrQzGraphicsStyle.__init__Cs4> - -C D#t| , , , , - -rRrOmemoc &|j}||}|jD]2}t||t |||j3|jD]2}t||t |||j3|Sr) __class____new___PRIVATE_SLOTSr __setattr__rr?PDF_STYLE_KEYS)rOrFrrAsrEs rP __deepcopy__zGraphicsStyle.__deepcopy__Gsnkk## F FA   sAwtQ 'D'D E E E E% J JC   sCsCK)H)H I I I I rRnamer'c t||dS#t$r }t|jd|d|d}~wwxYw)Nz does not have style "z " (a typo?))superrKAttributeErrorrH)rOrOr'r[rHs rPrKzGraphicsStyle.__setattr__Rsr  GG  e , , , , ,    >JJJJJ  s"' AA  Acxt|d|j}||jur|jStt|SNrrr?rr)rOr+s rPr+z GraphicsStyle.allow_transparency\s=$T+@$,OO  - -< D,---rRrAcHtd|SrT)rQrKrOrArHs rPr+z GraphicsStyle.allow_transparencycsww""#8#>>>rRcrt|d|j}||jus||Stt|S)z*The paint rule to use for this path/group.r )rr?rr&)rOr*s rPr*zGraphicsStyle.paint_rulejs?T=$,??  % %); M:...rRcB|.tdtjdSt |t r$td|dStdtj|dS)Nr )rQrKr& DONT_PAINTrrArLrWs rPr*zGraphicsStyle.paint_rulers ; GG   }/G H H H H H [ ) ) J GG   s 3 3 3 3 3 GG   }/CC/H/H I I I I IrRcnt|d|j}||jur|Stt|S)zEIf True, unclosed paths will be automatically closed before stroking.rrU)rOr,s rPr,zGraphicsStyle.auto_close{s:T=$,??  % % D*%%%rRc|dd|jhvrtd|td|dS)NTFz/auto_close must be a bool or self.INHERIT, not r)r? TypeErrorrQrKrWs rPr,zGraphicsStyle.auto_closesN tUDL1 1 1ScSSTT T M3/////rRcnt|d|j}||jur|Stt|S)z2The desired intersection rule for this path/group.r)rr?rr%)rOr-s rPr-zGraphicsStyle.intersection_rules>$D*> MM  , ,$ $$&7888rRct|tr$td|dStdt j|dS)Nr)rrArQrKr%rLrWs rPr-zGraphicsStyle.intersection_rulesf c; ' ' T GG   4c : : : : : GG   46F6Mc6R6R S S S S SrRct|d|j}||jus||St|ttt t fsJ|S)z The desired fill color for this path/group. When setting this property, if the color specifies an opacity value, that will be used to set the fill_opacity property as well. rrr?rrrrrC)rOr.s rPr.zGraphicsStyle.fill_colorsaT=$,??  % %);  J MJ     rRcolorct|trt|}t|ttt t frZtd|t|dd#t|t s|j |_ dSdSdS| ||j ur$td|dSt|d)NrrW" doesn't look like a drawing color)rrrrrrrCrQrKrrWr/r?r]rOrbrHs rPr.zGraphicsStyle.fill_colors eS ! ! 1)%00E eiZO P P J GG   u 5 5 5uc4((4Z}>>4%*G!!!5444 m$,!6!6 GG   u 5 5 5 5 5uHHHII IrRct|tjj|j}||jus||St t |S)z-The desired fill opacity for this path/group.)rr( FILL_ALPHAr'r?rr)rOr/s rPr/zGraphicsStyle.fill_opacitysEt\%<%BDLQQ 4< ' '<+? E<(((rRc|d|jhvr&t|tsJt|t t jj|dSr) r?rr9rrQrKr(rgr'rWs rPr/zGraphicsStyle.fill_opacitys_ tT\* * *c;// / //     L393?????rRct|d|j}||jus||St|ttt t fsJ|S)z The desired stroke color for this path/group. When setting this property, if the color specifies an opacity value, that will be used to set the fill_opacity property as well. r!ra)rOr0s rPr0zGraphicsStyle.stroke_colorsat_dlCC 4< ' '<+?  9j*mL     rRct|trt|}t|ttt t frmtd|t|dd!t|t s |j |_ |j |j ur d|_ dSdS| ||j ur$td|dSt|d)Nr!rWrrd)rrrrrrrCrQrKrrWrrr?r]res rPr0zGraphicsStyle.stroke_colors eS ! ! 1)%00E eiZO P P J GG   7 7 7uc4((4Z}>>4',g# DL00$%!!!10m$,!6!6 GG   7 7 7 7 7uHHHII IrRct|tjj|j}||jus||St |t sJt|S)z/The desired stroke opacity for this path/group.)rr( STROKE_ALPHAr'r?rr9r)rOrs rPrzGraphicsStyle.stroke_opacitysY!|'@'F UU T\ ) )^-C! !.+66666^$$$rRc|d|jfvr&t|tsJt|t t jj|dSr) r?rr9rrQrKr(rlr'rWs rPrzGraphicsStyle.stroke_opacitys_ tT\* * *c;// / //     L5;SAAAAArRct|tjj|j}||jur|St t |S)z+The desired blend mode for this path/group.)rr( BLEND_MODEr'r?rr )rOr1s rPr1zGraphicsStyle.blend_modes@T<#:#@$,OO  % % Iz***rRc(t|tr3ttjj|dSttjjtj|jdSr) rrArQrKr(ror'r rLrOr'rHs rPr1zGraphicsStyle.blend_mode sz e[ ) )  GG   7 =u E E E E E GG  '-y/?/F/F/L     rRct|tjj|j}||jus||St |t sJt|S)z-The desired stroke width for this path/group.)rr( STROKE_WIDTHr'r?rr9r)rOrs rPrzGraphicsStyle.stroke_widthsYt\%>%DdlSS 4< ' '<+? , 44444\"""rRr_c|d|jfvr4t|tstdt |t tjj |dS)Nz#stroke_width must be a number, not ) r?rr9r]typerQrKr(rsr')rOr_rHs rPrzGraphicsStyle.stroke_widthsg t|, , ,Z{5S5S ,O$u++OOPP P L5;UCCCCCrRct|tjj|j}||jur|St t |S)z1The desired stroke cap style for this path/group.)rr(STROKE_CAP_STYLEr'r?rr))rOr2s rPr2zGraphicsStyle.stroke_cap_style"sI# ,/5t|   t| + +# #N$4555rRct|tr3ttjj|dSttjjtj|dSr) rrArQrKr(rwr'r)rLrqs rPr2zGraphicsStyle.stroke_cap_style,sw e[ ) )  GG   = CU K K K K K GG  -3^5J55Q5Q     rRct|tjj|j}||jur|St t |S)z2The desired stroke join style for this path/group.)rr(STROKE_JOIN_STYLEr'r?rr*)rOr3s rPr3zGraphicsStyle.stroke_join_style5sI$ ,06     , ,$ $O%6777rRct|tr3ttjj|dSttjjtj|dSr) rrArQrKr(rzr'r*rLrqs rPr3zGraphicsStyle.stroke_join_style?sw e[ ) )  GG   > De L L L L L GG  .4o6LU6S6S     rRct|tjj|j}||jur|St |t sJt|S)z3The desired stroke miter limit for this path/group.)rr(STROKE_MITER_LIMITr'r?rr9r)rOr4s rPr4z GraphicsStyle.stroke_miter_limitHs^% ,17    - -% %,k:::::'(((rRc||just|tr3tt jj|dSt|d)Nz is not a number) r?rr9rQrKr(r}r'r]rqs rPr4z GraphicsStyle.stroke_miter_limitSs\ T\ ! !j &D&D ! GG   ? Eu M M M M Mu66677 7rRct|d|j}||jur|Stttdf|S)z4The desired stroke dash pattern for this path/group.r".)rr?rrr)rOr5s rPr5z!GraphicsStyle.stroke_dash_patternZsF&d,BDLQQ $, . .& &E%*%':;;;rRcJ|d}nt|tr|j}nt|trt |f}nt|t t tfrtd|d g}|D]M}t|t t tfrt| t |Nn)#ttf$rtd|ddwxYwg|R}t d|dS)Nrzstroke_dash_pattern z( must be a number or sequence of numbersr") rrAr?r9rrbytes bytearrayr]rrrQrK)rOr'resultaccumitemrHs rPr5z!GraphicsStyle.stroke_dash_patternbsP =FF { + + \FF { + + Ell_FF UI6 7 7 XuXXX  %'!..D!$eY(?@@('LLt----.z*   \5\\\ uYYF 2F;;;;;s AC&C9ct|d|j}||jur|St|tsJt |S)zAThe desired stroke dash pattern phase offset for this path/group.r#)rr?rr9r)rOr6s rPr6zGraphicsStyle.stroke_dash_phasesR$D*> MM  , ,$ $+[99999&'''rRc||just|tr"td|St |d)Nr#z( isn't a number or GraphicsStyle.INHERIT)r?rr9rQrKr]rqs rPr6zGraphicsStyle.stroke_dash_phasesQ DL Juk$B$B 77&&';UCC C5JJJKKKrR PaintSoftMask ImageSoftMaskct|tjj|j}||jur|St t ttf|Sr) rr( SOFT_MASKr'r?rrrr)rOpaint_soft_masks rPr7zGraphicsStyle.soft_masksH!$ (>(DdlSS dl * *" "E-67IIIrRc||just|ttfr1t t jj|St|d)Nz> isn't a PaintSoftMask, ImageSoftMask or GraphicsStyle.INHERIT) r?rrrrQrKr(rr'r]rqs rPr7zGraphicsStyle.soft_masksd DL Ju}m6T$U$U 77&&|'='CUKK K T T T   rRct}|jD](}t|||j}||jur||||<)|jr.|j|jur |j|jg|t jj<|j dur|j D] }||vr||= |rGtd}td||<| |dt|SdS)z Convert this style object to a PDF dictionary with appropriate style keys. Only explicitly specified values are emitted. NFType ExtGState)last)rrLrr?r5r6r(r&r'r+TRANSPARENCY_KEYSr3 move_to_endr6)rOrrEr' type_names rP serializezGraphicsStyle.serializes #.--& $ $CD#t|44ET\))0A$s   # (@ (T(T(&>F<39 :  "e + +- $ $&==s  0V I $[ 1 1F9    yu  5 5 5'// /trRc*|jtjurt}|j}|j||d|j}|Wt|j tr|j n tj }|d|| |j t|}n#t$rtj}YnwxYw|St|jt s|j tjS|jS)z Resolve `PathPaintRule.AUTO` to a real paint rule based on this style. Returns: the resolved `PathPaintRule`. Nr9r:)r*r&AUTOsetr0rrhr.rr-r%NONZEROr; frozensetKeyErrorrrA)rOwantr0r.r-r*s rPrz GraphicsStyle.resolve_paint_rules ?m0 0 003D,L ,1I"""J%"$"8:JKK2D**)1"    *+++ ?,0,CIdOO,T  ? ? ?+>  ?  do{ 3 3 5t7N!4 4s(CCC)r<rr=rrUrrUN)KrrrrrJrr(rr?MERGE_PROPERTIESrgr'rlrorrrLrr&rZrr%r FILL_NONZEROEVENODD FILL_EVENODDrrr;dictrrrrrQrrr rNrKrrrAr+setterr*r,r-rrCr.rr/r0rr r1rr)r2r*r3r4r8r r5rr6rr7r5rrr __classcell__rHs@rPrrsQ  N'''''""IG]$V %!'%$  S U U< U U UNU  " }/ 8*}3 6+3455}7Q 6+3455}7Q v/7 8   , v/7 8   , RYs-='=> MN   :[ ---- 2 T#s(^     CD.D;$6...X. ?d[&8?T?????? /MK7$>///X/Jmk9C?$FJ4JJJJJJ&D;.&&&X&0d[00T000000 9#3k#A999X9T%5 %Cc%ITdTTTTTT EM1K?#EL   X J]*S0;>EJ JJJJJJ&)ek1D8)))X)@ 3d :@t@@@@@@  em3kADH   X J]*S0;>EJ JJJJJJ*% 3d :%%%X%B%+"5"<BBBBBBB +I 3+++X+ C+ =$#ek1D8###X#D%+"5"<DDDDDDD 6.;">666X6ns&:[&HT8?[#@888X8'<{'Jt)EK$7)))X)8(<8888888 RelativeMove doesn't draw anything, so it has no bounding box.rrs rPrzRelativeMove.bounding_boxTs  ""EDGO33rRrr@rrrc^|j|jz}t|t||fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is the resolved `Move` )rrrrrOrrrrpoints rPrzRelativeMove.renderXs..#dg-E""DKK66rRNrrrRrPrrCs III& "5"""X"4%4E+u2D,E44447,77 7  7 sJ% & 777777rRrceZdZUdZeed< edefdZdedee effdZ e ddd e d e d edeee eff d Zd S)Linez A path line element. This draws a straight line from the end point of the previous path element to the point specified by `pt`. See: `PaintedPath.line_to` rrUc|jSrrrs rPrzLine.end_pointrrRrcRt||jg|jfS)zICompute the bounding box of a line from the start point to the end point.rTrrrs rPrzLine.bounding_boxs$&&tw'788$'AArRrr@rrrc0t|j||fSr)rrrs rPrz Line.renders,DG$$dM99rRNrrrRrPrrss III/ 5XB%BE+u2D,EBBBB:,:: :  : sJ% & ::::::rRrceZdZUdZeed< edefdZdedee effdZ e ddd e d e d edeee eff d Zd S) RelativeLinead A path line element with an endpoint relative to the end of the previous element. This draws a straight line from the end point of the previous path element to the point specified by `last_item.end_point + pt`. The absolute coordinates of the end point are resolved during the rendering process. See: `PaintedPath.line_relative` rrUctrrrs rPrzRelativeLine.end_pointrrRrc^t|||jzg||jzfS)zVCompute the bounding box of a relative line from the start point to the new end point.rrs rPrzRelativeLine.bounding_boxs,&&utw'?@@%$'/QQrRrr@rrrc^|j|jz}t|t||fS) Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is the resolved `Line`. )rrrrrs rPrzRelativeLine.renders..#dg-E""DKK>>rRNrrrRrPrrs IIII "5"""X"R%RE+u2D,ERRRR?,?? ?  ? sJ% & ??????rRrceZdZUdZeed< edefdZdede e effdZ e ddd e d ed ede eeeff d Zd S)HorizontalLinez A path line element that takes its ordinate from the end of the previous element. See: `PaintedPath.horizontal_line_to` rrUctrrrs rPrzHorizontalLine.end_pointrrRrctt|j|j}t||g|fS)zPCompute the bounding box of a horizontal line from the start point to the new x.rrrrrTr)rOrrs rPrzHorizontalLine.bounding_boxs8E$&MM57++&&s|44c99rRrr@rrrctt|jt|jj}t |t ||fSrrr)rrrrrrrrOrrrrrs rPrzHorizontalLine.rendersG.E$&MMU93F3H-I-IJJJ I&&YFFrRNrrrrr8rrrrrrTrrrrrrrrRrPrrs III: "5"""X":%:E+u2D,E:::: G,GG G  G sJ% & GGGGGGrRrceZdZUdZeed< edefdZdede e effdZ e ddd e d ed ede eeeff d Zd S)RelativeHorizontalLinez A path line element that takes its ordinate from the end of the previous element and computes its abscissa offset from the end of that element. See: `PaintedPath.horizontal_line_relative` rrUctrrrs rPrz RelativeHorizontalLine.end_pointrrRrctt|jt|jz|j}t||g}||fS)z7Compute the bounding box of a relative horizontal line.rrOrrrSs rPrz#RelativeHorizontalLine.bounding_boxsIE%'NNU46]]2EG<<&&s|44SyrRrr@rrrct|jjt|jz|jj}t |t ||fSrrrrrrrrrs rPrzRelativeHorizontalLine.rendersS.!#eDFmm3y7J7L   I&&YFFrRNrrrRrPrrIII "5"""X"%E+u2D,E G,GG G  G sJ% & GGGGGGrRrceZdZUdZeed< edefdZdede e effdZ e ddd e d ed ede eeeff d Zd S) VerticalLinez A path line element that takes its abscissa from the end of the previous element. See: `PaintedPath.vertical_line_to` rrUctrrrs rPrzVerticalLine.end_point@rrRrct|jt|j}t||g}||fS)z/Compute the bounding box of this vertical line.rrrrrTrrs rPrzVerticalLine.bounding_boxDs<EGU46]]++&&s|44SyrRrr@rrrct|jjt|j}t |t ||fSrrrs rPrzVerticalLine.renderJs?.I/1U46]]CCC I&&YFFrRNrrrRrPrr6s III8 "5"""X"%E+u2D,E G,GG G  G sJ% & GGGGGGrRrceZdZUdZeed< edefdZdede e effdZ e ddd e d ed ede eeeff d Zd S)RelativeVerticalLinez A path line element that takes its abscissa from the end of the previous element and computes its ordinate offset from the end of that element. See: `PaintedPath.vertical_line_relative` rrUctrrrs rPrzRelativeVerticalLine.end_pointsrrRrct|jt|jt|jz}t||g}||fS)z8Compute the bounding box of this relative vertical line.rrs rPrz!RelativeVerticalLine.bounding_boxwsIEGU57^^eDFmm;<<&&s|44SyrRrr@rrrct|jj|jjt |jz}t |t ||fSr)rrrrrrrrs rPrzRelativeVerticalLine.render}sS.!#y':'.* 8 8 8#A++++ 8 8 8rRc*g|]}t|gRSrr)rrpys rPrz,BezierCurve.bounding_box..rrR) rrrrrrrTrr) rOrtxtyrrrSrrs @@rPrzBezierCurve.bounding_boxsgtwy$')TXZ 8gtwy$')TXZ 8V2B7 7V2B7 7 8 8 8 8R 8 8 8 8 8 8 8R 8 8 83r77CGGSWWc"gg>>TX~rRrr@rrrcHt|j|j|j||fSr)rrrrrs rPrzBezierCurve.renders#,TWdgtx88$ MMrRNrrrRrPrrs III* III+ JJJ  5X%E+u2D,E N,NN N  N sJ% & NNNNNNrRrceZdZUdZeed< eed< eed< edefdZdedee effdZ e d d d e d e d edeee eff dZdS)RelativeBezierCurveu A cubic Bézier curve path element whose points are specified relative to the end point of the previous path element. See: `PaintedPath.curve_relative` rrrrUctrrrs rPrzRelativeBezierCurve.end_pointrrRrc |||jz||jz ||jz ddgtjj j jz}ddgtjj j jz} fd|D} fd|D}t t|t|t|t|}| fS)u Compute the bounding box of this relative cubic Bézier curve. Args: start (Point): The starting point of the curve (i.e., the end of the previous path element). Returns: A tuple containing: - BoundingBox: the axis-aligned bounding box containing the entire curve. - Point: the end point of the curve. rrc g|]]}t|tjtjtjtj^Sr)rrrrrrrrrs rPrz4RelativeBezierCurve.bounding_box..)[    "!U24[[%++uRT{{ERTRVKK X X   rRc g|]]}t|tjtjtjtj^Sr)rrrr's rPrz4RelativeBezierCurve.bounding_box..-r(rR) rrrrrrrTrr) rOrrr rrrSrrrrs @@@@rPrz RelativeBezierCurve.bounding_boxs TW_ TW_ TX V224rtRTJJ JV224rtRTJJ J                     3r77CGGSWWc"gg>>RxrRrr@rrrc|j}||jz}||jz}||jz}t |||t ||||fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is the resolved `BezierCurve`. rrr)rrrrrr) rOrrrr last_pointrrrs rPrzRelativeBezierCurve.render5s`.( $' ! $' !48# "b# & & 2"# . . .   rRNrrrRrPr#r#s III III JJJQ "5"""X"%E+u2D,EB  ,        sJ% &        rRr#ceZdZUdZeed< eed< edefdZdedefdZ dede e effd Z e d d d ed edede eeeff dZdS)QuadraticBezierCurveu A quadratic Bézier curve path element. This draws a Bézier curve parameterized by the end point of the previous path element, one off-curve control point, and an end point. See: `PaintedPath.quadratic_curve_to` ctrlrrUc|jSrrrs rPrzQuadraticBezierCurve.end_pointhrrR start_pointc\|j}|j}t|jd|j|jz zdz z|jd|j|jz zdz z}t|jd|j|jz zdz z|jd|j|jz zdz z}t |||S)Nr rr)r/rrrrr)rOr1r/rrrs rPto_cubic_curvez#QuadraticBezierCurve.to_cubic_curvemsyhma46KM#9:Q>>ma46KM#9:Q>>   ea46CE>*Q..ea46CE>*Q..    5%---rRrcV||}||S)u]Compute the bounding box of this quadratic Bézier curve by converting it to a cubic Bézier.)r3r)rOrcubics rPrz!QuadraticBezierCurve.bounding_box|s)##E**!!%(((rRrr@rrrct||j||||d||fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is `self`. r)r3rrrs rPrzQuadraticBezierCurve.rendersK,    3 4 4 ; ;!5)]        rRN)rrrrrrrrrr3rrTrrrrrrrrRrPr.r.Ys  KKK$ JJJ  5X .% .K . . . .)%)E+u2D,E))))  ,      sJ% &       rRr.ceZdZUdZeed< eed< edefdZdedee effdZ e dd d e d e d edeee eff d ZdS)RelativeQuadraticBezierCurveu A quadratic Bézier curve path element whose points are specified relative to the end point of the previous path element. See: `PaintedPath.quadratic_curve_relative` r/rrUctrrrs rPrz&RelativeQuadraticBezierCurve.end_pointrrRrcr||jz}||jz}t|||S)uBCompute the bounding box of this relative quadratic Bézier curve.r/r)r/rr.r)rOrr/rs rPrz)RelativeQuadraticBezierCurve.bounding_boxs;ty dh#3777DDUKKKrRrr@rrrc|j}||jz}||jz}t||}|||||S)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is the resolved `QuadraticBezierCurve`. r;)rr/rr.r) rOrrrrr,r/rabsolutes rPrz#RelativeQuadraticBezierCurve.rendersO,( DI%48#'Ts;;;0%MRRRrRNrrrRrPr8r8s KKKU JJJQ "5"""X"L%LE+u2D,ELLLL S,SS S  S sJ% & SSSSSSrRr8c:eZdZUdZeed< eed< eed< eed< eed< edefdZ e e d e de eeeefd d ffd Zd edeefd ZdedeeeffdZe ddded ededeeeeff dZd S)Arcz An elliptical arc path element. The arc is drawn from the end of the current path element to its specified end point using a number of parameters to determine how it is constructed. See: `PaintedPath.arc_to` radiirotationlargesweeprrUc|jSrrrs rPrz Arc.end_pointrrR sweep_angleNc#Kt|}|}tjdz }tj||z }||z }tj|}tj|}dtj|dz z}td|}t|||zz|||zz } t||} t|D]0} ||z } tj | } || z| | z| | zfV||z}1dS)up A generator that subdivides a swept angle into segments no larger than a quarter turn. Any sweep that is larger than a quarter turn is subdivided into as many equally sized segments as necessary to prevent any individual segment from being larger than a quarter turn. This is used for approximating a circular curve segment using cubic Bézier curves. This computes the parameters used for the Bézier approximation up front, as well as the transform necessary to place the segment in the correct position. Args: sweep_angle (float): the angle to subdivide. Yields: A tuple of (ctrl1, ctrl2, end) representing the control and end points of the cubic Bézier curve approximating the segment as a unit circle centered at the origin. r gUUUUUU?r rN) rrpiceilcossintanrrangerrA)rE sweep_left quarterturnchunks sweep_segmentcos_tsin_tkapparrr_offset transforms rPsubdivide_sweepzArc.subdivide_sweeps4+&&  gk ;455#f, ''''!2333aeeem+UUU]-BCCE5!!v ( (A :-F!*622I)#UY%6iG G G G - 'JJ  ( (rRrc |j}tj|j }tj|j}|j|jz dz|z}|j|jz dz|j|jz dzz}|dkr't|dz|jz|dz|jz}|j|j k|j|j kz }|j|jzdz}|j|jzdz} |j|jzdz} |tj t|| z | z d| | zz zt|j|jz|jz |j |jz|jz z} | |z|j|jzdzz} t|j| jz |jz |j| jz |jz } t|j | jz |jz |j | jz |jz }tdd | }| |}|j dur|dkr|tjz}n|j dur|dkr|tjz }|dk|dkz }tjd|||j|j|j| j| j}g}||D]3\}}}|t+||z||z||z4|S) z Approximate this arc with a sequence of `BezierCurve`. Args: last_item: the previous path element (used for its end point) Returns: a list of `BezierCurve`. rr rrrFT)r@rrArrrrrrBrCrsqrtrangletauscalingrotatescale translaterWrr)rOrr@reverseforwardprimelam_dasignrxry2rxpy2rypx2 centerprimecenterarcstartarcendtheta deltatheta sweep_signfinal_tfcurvesrrrs rP_approximate_arczArc._approximate_arc"sN $dm^44$T]33%0C77B'EG#)UWuw->1,DD A::VS[EG3 uw7NOOOE dj(TZ4:-EF57"q(57"q(57"q( ieeme3Q7755=IJJ K'EG#eg-7(UW$uw.  'Y-@48-Ks,RSw&%'1w&%'1   x+-'572x+-'572    a !!(++^^F++ J%  j1nn $( "JJjD  zA~~ $( "J Ao*q.9  Z 0 0 0 VE]] U57EG $ $ VDM " " Yvx * * %'!%!5!5j!A!A   E5# MMEH,eh.>hOO     rRrct}t|}||D]6}||j\}}||}|}7||jfS)z Compute the bounding box of this arc by approximating it with a series of Bezier curves and aggregating their bounding boxes. )rTrrrrrrrr)rOrrSprevcurve segment_bboxrTs rPrzArc.bounding_boxksz   "";;**400  E#00@@OL!::l++DDDTX~rRrr@rrc ||}|sd|fSdfdt|g|dd|D|dfS) Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is a resolved `BezierCurve`. rc3ZK|]%\}}||dV&dSrNr)rrtrurrrs rPrzArc.render..sSD% .t]KKANrRNr)rrjoinr)rOrrrrrqs `` ` rPrz Arc.renderzs,&&y11 0y-/ / HH#& '@F3B3K'@&#I#I   2J    rR)rrrrrrr8rrr staticmethodrrr rrWrrrrrrTrrrrrrRrPr?r?s LLLV KKKT KKKF JJJ# 5X-(-( 5u,-tT9 :-(-(-(\-(^G*Gk9JGGGGR % E+u2D,E    ! ,! !  !  ! sJ% & ! ! ! ! ! ! rRr?ceZdZUdZeed< eed< eed< eed< eed< edefdZ d ede e effd Z e d d d ededede eeeff dZdS) RelativeArcz An elliptical arc path element. The arc is drawn from the end of the current path element to its specified end point using a number of parameters to determine how it is constructed. See: `PaintedPath.arc_relative` r@rArBrCrrUctrrrs rPrzRelativeArc.end_pointrrRrc||jz}t|j|j|j|j|}||S)zHCompute the bounding box of the resolved arc from the given start point.r@rArBrCr)rr?r@rArBrCr)rOrrarcs rPrzRelativeArc.bounding_boxsODH$ *]**    &&&rRrr@rrrct|j|j|j|j|j|jz||||S)rx)r?r@rArBrCrrrrs rPrzRelativeArc.rendersN, J M J J  $( *   &"E9m D D  ErRN)rrrrrrr8rrrrrTrrrrrrrrRrPrrs LLLV KKKT KKKF JJJT "5"""X" '% 'E+u2D,E ' ' ' 'E,EE E  E sJ% & EEEEEErRrceZdZUdZeed< eed< edefdZdedee effdZ e dd d e d e d edeee eff d ZdS) RectanglezA pdf primitive rectangle.orgsizerUc|jS)z+The end point of a rectangle is the origin.rrs rPrzRectangle.end_pointrrRrc |jj|jj}}t|t|jjz}t|t|jjz}t t||t||t||t||g}||jfS)z+Compute the bounding box of this rectangle.)rrrrrrTrr)rOrrarbrrrSs rPrzRectangle.bounding_boxsTXZB 2YYty{++ + 2YYty{++ +&&b" b" b" b"    TX~rRrr@rrrc|jd|jdt|j|fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is a `Line` back to the rectangle's origin. rz re)rrrrrs rPrzRectangle.rendersJ0x  : :49#3#3#5#5 : : : NN   rRNrrrRrPrrs$$ JJJ/ KKK0 5X %E+u2D,E  ,      sJ% &       rRrceZdZUdZeed< eed< eed< edefdZdee fdZ dede e effd Z ed d d ed e dede ee eff dZdS)RoundedRectanglezM A rectangle with rounded corners. See: `PaintedPath.rectangle` rr corner_radiirUc|jSrrrs rPrzRoundedRectangle.end_point/s xrRc g}|jjdkr|jjdkrn|jjdks|jjdkry|t |j|t |j|jz|tnO|jjdks|jjdkr/|t|j|jn|j\}}|j\}}|j\}}|jjdk|jjdkz }|jjdk|jjdkz } t|t|kr |jj}t|t|kr |jj}|t|z}| t|z}t||} |t t||z||t t||z|z ||t| dddt||z||z|t t||z||z|z |t| dddt||z|z ||z|t t||z||z|t| dddt|||z|z |t t|||z|t| dddt||z||t|SNrFT) rrrrrrrCloserrrrr?) rOitemsrrrhrxry sign_width sign_heightarc_rads rP _decomposezRoundedRectangle._decompose3sf"$ IK1  49;!#3#3 ikQDIK1$4$4 LLdh ( ( ( LLdh233 4 4 4 LL ! ! ! !!Q&&D,=,?1,D,D LL48TY77 8 8 8 88DAq9DAq&FB)+*ty{Q?J9;!+ a@K2wwQY[2wwQY[c"gg%Bs2ww&BBmmG LLeAFA..// 0 0 0 LLeAEBJ2233 4 4 4 LLWaeAE1r66J6JKK L L L LLeAE1q52:6677 8 8 8 LLWaeAEBJA6N6NOO P P P LLeAFAE2233 4 4 4 LLWaeAq1urz6J6JKK L L L LLeAq2v..// 0 0 0 LLWaeAFA6F6FGG H H H LL ! ! ! rRrct}|}|D]/}||\}}||}0||jfS)z Compute the bounding box of this rounded rectangle by decomposing into primitives and merging their individual bounding boxes. )rTrrrrrrOrrS current_pointrrXs rPrzRoundedRectangle.bounding_box\sh   "" OO%% ! !D#00?? A}::a==DDTX~rRrr@rrrc|}|sd||fSg}|D]3}|||||\}}}||4d|t |j|fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is a resolved `Line`. ryr)rrrr|rr rOrrrr components render_listrrendereds rPrzRoundedRectangle.renderjs,__&&  0y-/ /!#  ) )D15!5)]22 .Hi   x ( ( ( (xx $$d48nnmCCrRNrrrrrrrrrrrrrTrrrrrrrRrPrr!s# JJJ/ KKK0- 5X'D,''''R % E+u2D,E    !D,!D!D !D  !D sJ% & !D!D!D!D!D!DrRrceZdZUdZeed< eed< edefdZdee fdZ dede e effdZ ed d d ed e d ede ee eff dZdS)Ellipsez5 An ellipse. See: `PaintedPath.ellipse` r@rjrUctrrrs rPrzEllipse.end_pointrrRc g}t|jj}t|jj}|j\}}t ||}|dkr7|dkr0|tt ||z||t|dddt |||z|t|dddt ||z ||t|dddt |||z |t|dddt ||z||t|Sr) rr@rrrjrrrr?r)rOrrrrrrs rPrzEllipse._decomposesW"$      BB-- !GG"'' LLeBGR0011 2 2 2 LLWaeBR6H6HII J J J LLWaeBGR6H6HII J J J LLWaeBR6H6HII J J J LLWaeBGR6H6HII J J J LL ! ! ! rRrct}|}|D]/}||\}}||}0||jfS)z Compute the bounding box of this ellipse by decomposing it and merging the bounding boxes of its components. )rTrrrrrjrs rPrzEllipse.bounding_boxsi   "" OO%% ! !D#00?? A}::a==DDT[  rRrr@rrrc|}|sd||fSg}|D]3}|||||\}}}||4d|t |j|fS)a Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is a resolved `Move` to the center of the ellipse. ryr)rrrr|rrjrs rPrzEllipse.renders,__&&  0y-/ /!#  ) )D15!5)]22 .Hi   x ( ( ( (xx $$d4;&7&7FFrRNrrrRrPrrs LLL+ MMM@ "5"""X"D,* !% !E+u2D,E ! ! ! !!G,!G!G !G  !G sJ% & !G!G!G!G!G!GrRrceZdZUeed<eed<eed<eed<dZeed<dZeed<dZe eed <dZ e eed <dZ e e ed <dZ e eed <dS) TextRuntextfamilyemphasisrrrrrNabs_xabs_yrV run_style)rrrrrrrrrr rrVrrrrrRrPrrs III KKKMMM KKKBOOOBOOO!E8E?!!!!E8E?!!!%)Ix "))))-Ix &-----rRrc2eZdZUdZeed<eed<eedfed<dZe ed<e de fd Z dee eeeefeffd Zd e eeeefdefd Zde ded e ffdZeddddddde dee de ff dZdS)Textz SVG-like text renderable. Stores the anchor position (x, y) and one or more TextRuns that include relative positioning offsets. Accurate glyph positioning is resolved during rendering once font metrics are available. rr. text_runsr text_anchorrUctrrrs rPrzText.end_point rrRcg}|j}|j}|}|}|jD]}|j|j}|j|j}||jz }||jz }d|jztdt|j z}| |||ft||}t|||z}||z }||z }||fS)z Produce an approximate layout for bounding-box estimation. Returns: A tuple of (per-run layout list, total width estimate). Each layout entry is (x, y, width) in user space. Nrr) rrrrrrrrrlenrrr) rO positionspen_xpen_y max_rightmin_leftrun approx_width total_widths rP_approximate_layoutzText._approximate_layout s79  > " "Cy$ y$  SVOE SVOE>C3sx==,A,AAL   eUL9 : : :8U++HIu|';<.) s)??sy$??????rRc3&K|] }|dV dSr{rrposs rPrz&Text._anchor_offset.., s&00sCF000000rRc38K|]}|d|dzVdS)rr Nrrs rPrz&Text._anchor_offset..- s.99CFSVO999999rRmiddle@r)anyrrrrr)rOrmin_xmax_xs rP_anchor_offsetzText._anchor_offset$ s 3 ????? ? ? 300i0000099y99999  x ' '6UU]c11 1  u $ $6E> !v~rRrTc|jst|fS|\}}||}t d}t d}t d}t d}t ||jD]k\\} } } } | |z} d| jz}d| jz}t|| }t|| | z}t|| |z }t|| |z}l|t dkrt|fS|}|}|}|}t t||t||g|fS)a  Compute a conservative bbox for the text. Font metrics are not available at this stage so the layout relies on approximate glyph widths proportional to the run font size. The actual layout is computed precisely in render(). rr皙?皙?) rrTrrrrrrrrrr)rOrrrT anchor_offsetrrmin_ymax_yrun_xrun_y run_widthradj_xascdescrarrbrs rPrzText.bounding_box5 su~ .$$&&- -//11 1++I66 e f e f .1)T^.L.L - - * %UE9sM)E.C>Du%%Euy011Eus{++Eut|,,EE E%LL $$&&- -    &&b" uR}}'EFFMMrRrr@rrrrrc  |jsd||fSg}|j}|j}|}|} |jD]} || j| j} | | j| jd\} } | j | j }| j | j }|| j z }|| j z }t||}t| || z} |||| | | f|| z }t!d|D}|r?|s=|jdkr|j|| zdz z }n#|jdkr |j| z }n |j|z }nd}g}dt$jf}|D]\}}} } } | j t$|| jn|}|}|t.jt.jfvrd}n0|t.jurd }n|t.jt.jfvrd }nd }g}| jB|}||}|%|t=|d |j}|j }tB"tG||z|d | jzz tG||z| z|d| jzzg}||vrtI|tJr*||&||n]tI|tNtPtPfsJ||)*||vrtI|tJr*||+||n]tI|tNtPtPfsJ||),|j-}|j.}tI|t^sJ||vr6|t=|dta|dz|1dd| j2dta| jdta|ddta||zdta|d| 3| jdg| j dg|zdgz}|1|d4|||fS)z Emit PDF text operators: BT Tf Tr (map from GraphicsStyle->PathPaintRule) 1 0 0 1 x y Tm (escaped-text) Tj ET ryNc34K|]\}}}}}|jduVdSrr)rrTrs rPrzText.render.. s3OO_Q1c139D0OOOOOOrRrrrrrrrr r gsrrr dBTz/Fz Tfz Trz 1 0 0 -1 z TmETqQ)5rrrget_font_from_familyrrget_text_widthrrrrrrrrrrrrr?rrrr&rrrrrregister_graphics_styler6r.r0rTrrrrCryrrrlowerr}upperr5r6r9r:extendi encode_textr|)rOrrrrlayoutrrrrrfontrTr_ has_absoluterops NO_EMIT_SETrreffective_styleruletrrun_ops merged_stylestyle_dict_namer.r0run_bbox dash_pattern dash_phases rPrz Text.render[ s$~ 0y-/ /  >  C$99#*clSSD**38SXtDDHAuy$ y$  SVOE SVOEu%%Euu}--E MM5%T: ; ; ; UNEEOOOOOOO  , 8++ $%%-3)> > !U** $ $ M]23 .4V V *E5%d=,##E3=999 #5577D 2M4NOOO---11!#G}(. "3"K"K ###.NN&:?&K&K#P#P#PQQQ)4 +8 &22em3US38^5KLLem3e;US38^=STT[00!*m<<G&001BHMM *&Y (J    z';';'='='C'C'E'EFFF{22!, >>I(445FQQ *(:y)*L    |'='='?'?'E'E'G'GHHH+? ); !*k:::::{22NN,\::;mJ77;;;< NN>>>-"9"9>>>$R((---` em.C D D``}UZG[G[```$$SX..    }(%'/SE1 JJw    xx}}i66rRN)rrrrrrrrrrrrrrrrrrrrrRrPrrs HHH HHHWc\""""K "5"""X"&U4eUE6I0J+KU+R%S&&&&>U5%3F-G(HU"$N%$NE-2F,G$N$N$N$NLR7,R7R7 R7  R7 sL%' ( R7R7R7R7R7R7rRrceZdZdZedefdZdedeeeffdZ e ddde d e d edee e eff d Zd S) ImplicitClosezw A path close element that is conditionally rendered depending on the value of `GraphicsStyle.auto_close`. rUctrrrs rPrzImplicitClose.end_point rrRrc8t|fSzAReturn an empty bounding box; Close does not affect the geometry.rTrrs rPrzImplicitClose.bounding_box   ""E))rRrr@rrrc$|jrd||fSd||fS)  Render this path element to its PDF representation. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command Returns: a tuple of `(str, new_last_item)`, where `new_last_item` is whatever the old last_item was. rry)r,rs rPrzImplicitClose.render s).   1 =0 09m++rRNrrrrrrrrrTrrrrrrrrRrPrr s "5"""X"*%*E+u2D,E**** ,,,, ,  , sJ% & ,,,,,,rRrceZdZdZedefdZdedeeeffdZ e ddde d e d edee e eff d Zd S) rz A path close element. Instructs the renderer to draw a straight line from the end of the last path element to the start of the current path. See: `PaintedPath.close` rUc"tddS)z5The end point of a Close is undefined; return (0, 0).r)rrs rPrzClose.end_point( sQ{{rRrc8t|fSrrrs rPrzClose.bounding_box. rrRrr@rrrc&dt||fS)rr)rrs rPrz Close.render3 s.D''66rRNrrrRrPrr s5X *%*E+u2D,E**** 7,77 7  7 sJ% & 777777rRrrmove relative_moveline relative_line)rhorizontal_linerelative_horizontal_line)r vertical_linerelative_vertical_liner+ bezier_curverelative_bezier_curver;quadratic_bezier_curverelative_quadratic_bezier_curveFrr relative_arc)rr rectangle)rrrrounded_rectangle)r@rjellipseryz Sans serif(@rrrr)rrrrimplicit_closecloseceZdZdZdZddZ ddedd eddfd Ze d e d e d e de de eee eff dZddd e d e de de def dZdS)DrawingContextz Base context for a drawing in a PDF This context is not stylable and is mainly responsible for transforming path drawing coordinates into user coordinates (i.e. it ensures that the output drawing is correctly scaled).  _subitemsrUNcg|_dSrrrs rPrQzDrawingContext.__init__ s TVrRTr)GraphicsContext PaintedPathPaintCompositeclonect|tttfst |d|rt |}|j|dS)a Append an item to this drawing context Args: item (GraphicsContext, PaintedPath): the item to be appended. clone (bool): if true (the default), the item will be copied before being appended. This prevents modifications to a referenced object from "retroactively" altering its style/shape and should be disabled with caution. z# doesn't belong in a DrawingContextN)rr!r"r#r]rrrrOrr$s rPadd_itemzDrawingContext.add_item sd $+~ NOO JtHHHII I  "D>>D d#####rRr first_pointr_r`c2d|_tj|_tj|_t|}tj dd d|dz  | |\}}d|g}|||fS)NTrrrrr r) r,r&rr*r%rr-rrr]aboutr_r)rr(r_r`rscale_renderedrs rP_setup_render_prereqsz$DrawingContext._setup_render_prereqs s (-"2": $[ 1 1  R ( ( ( UQ&1*U % % U5\\ VI   " N+ E9,,rRrr@starting_stylecL|jsdS|||||\}}}|jD]5} | ||||\} }}| r|| 6t |dkrdSt |jts4|jjdkr$| |j|j_| |} | t |j trJt |j trJ| dt| d| dt|j dt|j dz|d d|S) a  Render the drawing context to PDF format. Args: resource_registry (ResourceCatalog): the parent document's graphics state registry. first_point (Point): the starting point to use if the first path element is a relative element. scale (Number): the scale factor to convert from PDF pt units into the document's semantic units (e.g. mm or in). height (Number): the page height. This is used to remap the coordinates to be from the top-left corner of the page (matching fpdf's behavior) instead of the PDF native behavior of bottom-left. starting_style (GraphicsStyle): the base style for this drawing context, derived from the document's current style defaults. Returns: A string composed of the PDF representation of all the paths and groups in this context (an empty string is returned if there are no paths or groups) ryr rNrrrrr)rr,rrrrr7rA object_idregister_soft_maskrr5r6insertr6r:r|) rOrr(r_r`r-rrrrrrs rPrzDrawingContext.render s8~ 2(,(B(B K) ) % UIN - -D/3{{!5)[00 ,Hi -""8,,, {  q 25?K88 )Q..(9(L(L))EO %,CCEJJ  &!%";[II I II!%"9;GG G GG   q%9/%J%J"O"O"O P P P   $U%>??@mE$;<<@@@A    3xx $$$rRrT)rrrrrrQrrr'r}rrrrrrrr,rrrRrPrrw s/IWWWW $$FG$$  $$$$0--+0-9>-HM- tCy-3 4---\-&C%,C%C% C%  C% & C% C%C%C%C%C%C%rRrPPr"ceZdZdZdZdadededdfdZd ed ee e fdefd Z e de fd Ze deefd ZejdeddfdZe deezfdZejdeddfdZe deezdzfdZejdeddfdZe dedfdZejdedddfdZdbdZe dcdededfdZedededfd Zdcd!ed"eddfd#Zddd$Z dade!de!d%e!d&e!d'e!d(e!ddfd)Z"d*e!d+e!d,e!ddfd-Z#d*e!d+e!d'e!d(e!ddf d.Z$de!de!ddfd/Z%de!de!ddfd0Z&de!de!ddfd1Z'd2e!d3e!ddfd4Z(de!ddfd5Z)d2e!ddfd6Z*de!ddfd7Z+d3e!ddfd8Z,d9e!d:e!d;e!de!ddfd?Z-d@e!dAe!dBe!dCe!dDe!dEe!ddfdFZ.d9e!d:e!d;e!de + L L L"&"8D !%D  ''E':::::rRc8|jdSr)r6remove_last_itemrs rPremove_last_path_elementz$PaintedPath.remove_last_path_elementz s //11111rRrrrrc ||ttt |t |tt |t |tt |t |dd|_||||S)a Append a rectangle as a closed subpath to the current path. If the width or the height are 0, the rectangle will be collapsed to a line (unless they're both 0, in which case it's collapsed to nothing). Args: x (Number): the abscissa of the starting corner of the rectangle. y (Number): the ordinate of the starting corner of the rectangle. w (Number): the width of the rectangle (if 0, the rectangle will be rendered as a vertical line). h (Number): the height of the rectangle (if 0, the rectangle will be rendered as a horizontal line). rx (Number): the x-radius of the rectangle rounded corner (if 0 the corners will not be rounded). ry (Number): the y-radius of the rectangle rounded corner (if 0 the corners will not be rounded). Returns: The path, to allow chaining method calls. Fr^T)_insert_implicit_close_if_openr_rrrr7move_to)rOrrrrrrs rPrzPaintedPath.rectangle} s2 ++---  eAhha))eAhha))eBiir++         Q rRrrrc2|||||S)a[ Append a circle as a closed subpath to the current path. Args: cx (Number): the abscissa of the circle's center point. cy (Number): the ordinate of the circle's center point. r (Number): the radius of the circle. Returns: The path, to allow chaining method calls. )r)rOrrrs rPcirclezPaintedPath.circle s||BAq)))rRc R||ttt |t |tt |t |dd|_||||S)a Append an ellipse as a closed subpath to the current path. Args: cx (Number): the abscissa of the ellipse's center point. cy (Number): the ordinate of the ellipse's center point. rx (Number): the x-radius of the ellipse. ry (Number): the y-radius of the ellipse. Returns: The path, to allow chaining method calls. Fr^T)rdr_rrrr7re)rOrrrrs rPrzPaintedPath.ellipse s ++---  E%))U2YY//uRyy%))1L1L M M      R rRc|ttt|t||_|S)a Start a new subpath or move the path starting point. If no path elements have been added yet, this will change the path starting point. If path elements have been added, this will insert an implicit close in order to start a new subpath. Args: x (Number): abscissa of the (sub)path starting point. y (Number): ordinate of the (sub)path starting point. Returns: The path, to allow chaining method calls. )rdrrrr9r;s rPrezPaintedPath.move_to sA ++---!%a%((";";<< rRc||j4d|_|j|jd|j|_t tt|t||_|S)a Start a new subpath or move the path start point relative to the previous point. If no path elements have been added yet, this will change the path starting point. If path elements have been added, this will insert an implicit close in order to start a new subpath. This will overwrite an absolute move_to as long as no non-move path items have been appended. The relative position is resolved from the previous item when the path is being rendered, or from 0, 0 if it is the first item. Args: x (Number): abscissa of the (sub)path starting point relative to the previous point. y (Number): ordinate of the (sub)path starting point relative to the previous point. NFr^) rdr9r7r6r'r8rrrr;s rP move_relativezPaintedPath.move_relative s{ ++---   ) DL  " + +D,>e + L L L"&"8D )%a%((*C*CDD rRc |ttt|t|d|S)z Append a straight line to this path. Args: x (Number): abscissa the line's end point. y (Number): ordinate of the line's end point. Returns: The path, to allow chaining method calls. Fr^)r_rrrr;s rPline_tozPaintedPath.line_to s@ d5q588#<#<==UKKK rRrrc |ttt|t|d|S)a Append a straight line whose end is computed as an offset from the end of the previous path element. Args: x (Number): abscissa the line's end point relative to the end point of the previous path element. y (Number): ordinate of the line's end point relative to the end point of the previous path element. Returns: The path, to allow chaining method calls. Fr^)r_rrrrs rP line_relativezPaintedPath.line_relative s@ l5rE"II+F+FGGuUUU rRch|tt|d|S)a. Append a straight horizontal line to the given abscissa. The ordinate is retrieved from the end point of the previous path element. Args: x (Number): abscissa of the line's end point. Returns: The path, to allow chaining method calls. Fr^)r_rr)rOrs rPhorizontal_line_tozPaintedPath.horizontal_line_to s0 nU1XX66eDDD rRch|tt|d|S)a Append a straight horizontal line to the given offset from the previous path element. The ordinate is retrieved from the end point of the previous path element. Args: x (Number): abscissa of the line's end point relative to the end point of the previous path element. Returns: The path, to allow chaining method calls. Fr^)r_rr)rOrs rPhorizontal_line_relativez$PaintedPath.horizontal_line_relative! s1 4U2YY??uMMM rRch|tt|d|S)a, Append a straight vertical line to the given ordinate. The abscissa is retrieved from the end point of the previous path element. Args: y (Number): ordinate of the line's end point. Returns: The path, to allow chaining method calls. Fr^)r_rr)rOrs rPvertical_line_tozPaintedPath.vertical_line_to1 s0 l58844EBBB rRch|tt|d|S)a Append a straight vertical line to the given offset from the previous path element. The abscissa is retrieved from the end point of the previous path element. Args: y (Number): ordinate of the line's end point relative to the end point of the previous path element. Returns: The path, to allow chaining method calls. Fr^)r_rr)rOrs rPvertical_line_relativez"PaintedPath.vertical_line_relative? s1 2599==UKKK rRrrrrx3y3cNtt|t|}tt|t|}tt|t|} |t||| d|S)u Append a cubic Bézier curve to this path. Args: x1 (Number): abscissa of the first control point y1 (Number): ordinate of the first control point x2 (Number): abscissa of the second control point y2 (Number): ordinate of the second control point x3 (Number): abscissa of the end point y3 (Number): ordinate of the end point Returns: The path, to allow chaining method calls. Fr^)rrr_r) rOrrrrrxryrrrs rPcurve_tozPaintedPath.curve_toO s"eBiir++eBiir++E"IIuRyy)) k%<>rRrr)rUr!r2r)rryrr)%%%X%& &$&&&&9x7999X9@.)A@d@@@@&&&&" : : : # $ : : :^ :x 7N^;;Z;;;;;;&2222XY%%%"%'-%28%>D%NT% %%%%N * *V * *= * * * *&f&f.F}&v&]0  F }    F}" F }    6m & ]    M $*06<BHNT 0( (( (  (  (( ((((T$*06< ( &-3:@ 08 8 8 8  8  8 8 8 8888t9 9 9 9  9  9 9 9 9999@'"'' ' ' '  '  ''' ''''R!!!!    7;   /3 {E! "    ?,?? ?  ? sJ% & ??????rRc deZdZdZdZddededdffd Zd d d ed ed e de e ee ff dZ xZ S)rLa3 The PaintedPath API but to be used to create clipping paths. .. warning:: Unless you really know what you're doing, changing attributes of the clipping path style is likely to produce unexpected results. This is because the clipping path styles override implicit style inheritance of the `PaintedPath` it applies to. For example, `clippath.style.stroke_width = 2` can unexpectedly override `paintpath.style.stroke_width = GraphicsStyle.INHERIT` and cause the painted path to be rendered with a stroke of 2 instead of what it would have normally inherited. Because a `ClippingPath` can be painted like a normal `PaintedPath`, it would be overly restrictive to remove the ability to style it, so instead this warning is here. rrrrrUNctt|t|tj|_dS)Nr)rQrQrr&rZr*)rOrrrHs rPrQzClippingPath.__init__ s: 588uQxx000'2rRrr@rrrc|j||||d\}}}t||j}t j}t|jtst |jj }| }| |j | |j d|||fS)NF _push_stackr)r5rrrrr!rrr-rArOrrr'r|) rOrrrrrrr-r*s rPrzClippingPath.render s$  ' 9 9     :     %**5$*==  ) 0 ,8+FF  <.3! "4466 ,2333:+,,,xx $$i>>rRr)rrrrrr8rQrrrrrrrrs@rPrLrL s"I33&33333333)?,)?)? )?  )? sJ% & )?)?)?)?)?)?)?)?rRrLGCr!ceZdZdZdZd$dZdedeee fdefdZ e de e fd Zejd e e ddfd Ze de efd Zejd e eddfdZ d%deededdfdeddfdZd$dZd&dZe d%dddededededeeeeeff dZ d'dede ed ed!edee eff d"Z! d%dddededededeeeeff d#Z"dS)(r!uw Page-level container that collects drawable items and renders them into a PDF content stream. Converts model coordinates to PDF user space by applying the provided `scale` and a vertical flip so (0, 0) is the top-left of the page. Wraps output in a saved graphics state (`q … Q`) and registers any required resources (graphics state dictionaries, soft masks, dash pattern). Child items are typically `GraphicsContext`, `PaintedPath`, or `PaintComposite` objects added via `add_item()`. By default, items are deep-copied on insert to avoid later mutations affecting the emitted stream. )r path_items _transform_clipping_pathrUNcVt|_g|_d|_d|_dSr)rrrrrrs rPrQzGraphicsContext.__init__ s0$1OO   046:rRrOrFc|}t|j||_t|j||_t|j||_t|j||_|Sr)rHrrrrVrrOrr=s rPrNzGraphicsContext.__deepcopy__ sf!! D11 $T_d;;$T^T:: ();T B B rRc|jSrrrs rPrVzGraphicsContext.transform s rRrc||_dSrrrCs rPrVzGraphicsContext.transforms rRc|jS)z-The `ClippingPath` for this graphics context.rrs rPrOzGraphicsContext.clipping_paths ""rRrPc||_dSrrrRs rPrOzGraphicsContext.clipping_path s)rRTrr#PaintBlendCompositer$c\|rt|}|j|dS)a Add a path element to this graphics context. Args: item: the path element to add. May be a primitive element or another `GraphicsContext` or a `PaintedPath`. clone (bool): if true (the default), the item will be copied before being appended. This prevents modifications to a referenced object from "retroactively" altering its style/shape and should be disabled with caution. N)rrrr&s rPr'zGraphicsContext.add_items3,  "D>>D t$$$$$rRc|jd=dS)Nr)rrs rPraz GraphicsContext.remove_last_item+s OB   rR other_contextcD|j|jdS)z:Copy another `GraphicsContext`'s path items into this one.N)rr)rOrs rPrzGraphicsContext.merge.s! }788888rRrr@rrrrc g}jr|j|j}d|jf}j|jjjkr t j|j_|j} |j} d} | |jks | |jkr*jurt | _| _| | f} tj ts4j j dkr$ j j _ dttztzt zdzddffd } tjtr+j dt$jfvr| jjnDtjtr*j dt$jfvr| jj} | %|t-| djj}jj}d}t|tst|tr#jdd}||vrt|tr*|||n`t|t2t4zt6zsJ||||vrt|tr*|||n]t|t2t4t6fsJ||| _t| d t@sJ|t-| dd tC| d d zj"8j"#||\}}}|r||jD]5}|#||\}}|r||6j$4|%dj$#|d|r+|%dd |d ||fS)a Build a list composed of all all the individual elements rendered. This is used by `PaintedPath` and `ClippingPath` to reuse the `GraphicsContext` rendering process while still being able to inject some path specific items (e.g. the painting directive) before the render is collapsed into a single string. Args: resource_registry (ResourceCatalog): the owner's graphics state dictionary registry. style (GraphicsStyle): the current resolved graphics style last_item: the previous path element. initial_point: last position set by a "M" or "m" command _push_stack (bool): if True, wrap the resulting render list in a push/pop graphics stack directive pair. Returns: `tuple[list[str], last_item]` where `last_item` is the past path element in this `GraphicsContext` Nr paint_objrUc t|tsdS|sdS  jddd}t }||j|j|j |j t|j |j |j}|j|_||j_d|j_d|j_t&j|j_t-}||dt1|dd|j}jdurdS jurt5 j|_jj_dS)NF)rrrr)rFr^T)invertuse_luminosityrf)rrCrrrr"rrarbr_r`rrDrErFrGr.r0rr&rr*r!r'rr+rr7r0r/) rbbox_for_units mask_rect alpha_paintmask_gcsm emit_stylerrrOs rP_attach_alpha_mask_if_neededzGGraphicsContext.build_render_list.._attach_alpha_mask_if_neededvs")];;F **,,F!%!2!2!*&+ % "3""  "(MM ##"%"%"(") 2&O'0'C .7-E *-8 */3 ,/0 ,-:-G *)++  % 888# #'$7 0E99F++!)$*!5!5J') $1B1U1U(22 $...rRrFrrrrrrr)&rrHrrr?r+rr5r6rr7rAr/r0rCrrr.rr0rrr6rryrrrrrr}rr9r:rOrrVr1)rOrrrrrrrrrr emit_dashrrr.r0rrendered_cpathrT__rrrs`` ` @rPrz!GraphicsContext.build_render_list2sc<"$ ?g ( ?00 CCL!56KJ.$*2OOO%dj11 0<0O - (;L%7JI 999!888++!)*!5!5J1= ./9 ,):6 z3[AA (2a771B1U1U(22 $. 5 (50;>DtK5 5 5 5 5 5 5 5 5 5 r*/?? F$}/D(EEE,,TZ-BCCCCJ3]CC F$}/D(EEE,,TZ-DEEE/GG SSO*""&:?&K&K#P#P#PQQQ.J:2L!N*m44  m99 "&!2!2!u"3""",,j-88G&&",,->OO&j: 3JY3VXXXXX&&z';';'='='C'C'E'EFFF;..lM::I&&$001BNSS&lZY4WXXXXX&&|'='='?'?'E'E'G'GHHH$!)A, <<<<<""(1669- ! 55999: !-(,(:(A(A%|Y ))%2"7&&~666 1 159[[%|Y 662)]1&&x000~)""1dn&;&;I&F&Fq&IJJJ (""1c***""3'''I}44rRrrrc tj dddtdttdtdt t tttff  fd  ||| \}}}}|} |rB|r |j ||j n|j } | | ||f} | |fS) z Compute bbox of all path items. We: 1) recurse with accumulated CTM, 2) merge child bboxes already transformed to this level, 3) at the end, expand once for stroke using the worst-case CTM row norms. ctxr!r ambient_styleaccum_tfrUct}||jpz}s}|r |j||jn|j}|\}}|jD]} t| ttfrt| trK| |||\} } } } || }| }t|| }t|| }t| drB| |\}} |||}| }||||fS)Nr)rTrrVrHrrrrrr#rr!rhasattrrr)rrrrrSrrmax_nxmax_nyr child_bboxrcnxcny item_bboxrMrwalks rPrz*GraphicsContext.bounding_box..walk sl $$&&DS]6h7B ! '--mSYGGGY   \\^^NFF . .d^5H$IJJdO44 .6:dm\2773J 3 ::j11D$-M --F --FFT>22.+/+<+<]+K+K(Iy::i&;&;B&?&?@@D$-M6 6rR)r) rrMrr rrrTrrHrrr) rOrrrr geom_bboxend_ptrr final_bboxrrMrs ` @@rPrzGraphicsContext.bounding_boxs %''# 7"# 7 # 7$M2# 7 # 7 ;ue3 4 # 7# 7# 7# 7# 7# 7# 7# 7L%)DueX$F$F! 62r  =BQ%%eTZ888tz #55B86J6!!rRcn||||||\}}}d|||fS)Nrr)rr|)rOrrrrrrs rPrzGraphicsContext.render@sP150F0F    # 1G1 1 - Y xx $$i>>rRrr2)rr!rUN)NTT)#rrrrrrQrrrr rNrr rrVrrLrOrrr"rr'rarrrrrrrrrTrrrrRrPr!r! s  HI ; ; ; ;2T#s(^8I.XHY/D#x 5###X#*,)?*D****%%     !  # %% %%%%6    9999! H5H5,H5H5 H5  H5  H5 tCy*e+ ,H5H5H5H5Z*."& A"A"A" &A" A"  A" {E! " A"A"A"A"R! ??,?? ?  ?  ? sJ% &??????rRceZdZdZdZddejfdeee fde de defdZ d e fd Z d eeeeeffd Z dd ee efdee efdeeeefd e fdZddd e fdZedeee fd eee ffdZede ezd ee fdZe ddee deee fde dddedd df dZd S)ru Wraps a vector path as a PDF soft mask (SMask) that can be attached to a graphics state. The provided `mask_path` is deep-copied and forced to render as an opaque grayscale fill (white, alpha=1, nonzero rule, transparency disabled). During rendering, the mask’s content stream is generated and its resource dictionary is collected so it can be embedded as a Form XObject and referenced from an ExtGState. ) mask_pathr resourcesrr/rfFrrrrfct||_||_||_t |_d|_||_|js?tj |jj _ d|jj _ d|jj _ dSdS)Nrr#ffffff)rrrrrrr/rfr&rrr*r/r.)rOrrrrfs rPrQzPaintSoftMask.__init__hs"),," $2;>55!' " 8.;.HDN +01DN -.7DN + + +  8 8rRrUcP|jrdnd}|jrdnd}d|d|jd|dS) NzH /TR <>ryz /Luminosityz/Alphaz<>)rrr/)rOr mask_types rPrzPaintSoftMask.serialize|sR{  V V &*%8FMMh @y@@dn@@"@@@@rRc|jtdd\}}|SNr)rrrr)rOrrTs rPget_bounding_boxzPaintSoftMask.get_bounding_boxs5.55eAqkkBB a$$&&&rRNgfxstate_objs_per_namepattern_objs_per_name_img_objs_per_indexc i}|jD]?\}}||jt|@g}d|vrw|dro|t ddzdfdt|dDzdzd|vrw|dro|t ddzdfdt|dDzdzdd|zdzS)zMBuild the resource dictionary for this soft mask, resolving GS & Pattern ids.r<.scG}}..00[[3I'3R3U[[[rRrr.c3|K|]6}t|d|jdV7dSrr)rpat_namers rPrz8PaintSoftMask.get_resource_dictionary..sc H~~//11\\4I(4S4V\\\rR) r setdefaultr'rrhrr3rr|r)rOrrrresources_registered resource_typernpartss `` rPget_resource_dictionaryz%PaintSoftMask.get_resource_dictionarys57*.. Y Y &M; + +M,? G G K KK X X X X . . .3G 3T . LL[!!++--''#)*>{*K#L#L      , , ,1Ei1P , LLY))++''$*+? +J$K$K     bggenn$t++rRrr@c |j|ttt ddt dd\}}}|||_|SNr)rrr)rrrrr scan_streamrrOrstreamrTs rPrzPaintSoftMask.rendersh~,, //5A;;''1++ -  1 +66v>> rRnodecdtddffd t|}t|tr|n|}||S)u Return a deep-copied version of *node* whose appearance encodes only its geometric coverage: every shape is converted to an **opaque white fill** (nonzero rule), with **no stroke**, no soft mask, and inherited blend mode. The transform/clipping/structure of the original node is preserved; only paint-related attributes are normalized. This is intended for building the “B” term of soft-mask expressions (coverage), where inside = 1 and outside = 0. gcrUNc tj|j_d|j_d|j_d|j_tj|j_ tj|j_ |j D]}t|tr |#t|trftj|j_d|j_d|j_d|j_tj|j_ tj|j_ dS)Nrr)r&rrr*r.r/r0rr?r1r7rrr!r")rr= _force_whites rPrz2PaintSoftMask.coverage_white.._force_whites"/">%1++>GGJD LDDdjj.>.>E ""]] UXuxelCCC/5Dii9 ! $  6!*!5AG  =!*!3AG  OOA    Sd ; ; ; IIh  22266  rRr)rrrrrrrMrr"r!rrQrrrrrrr4r rrrr}rrrrrrRrPrrSsN  I$.I.00 88o5688 8  8888(A3AAAA'%ueU(B"C''''?C $,$, $S)^ 4$, $CN3$,&d3 >&:; $, $,$,$,$,L(9c*K01* {O+ ,***\*X0 +0 / "000\0d04 ?? O $? o- .? ? $ ? m, ? ???[???rRrc eZdZdZdZdedeeeeefdeddfdZ de fd Z deeeeeffd Z d d de fd Z ddee efdee efdeeeefde fdZdS)rz Soft mask backed by a grayscale image XObject. The grayscale image is drawn into a transparency group; the group's luminance is used as the mask values.  image_indexrSrfr/rrSrfrUNc>||_||_||_d|_dSrr)rOrrSrfs rPrQzImageSoftMask.__init__fs% '  rRcd|jdS)Nz<>)r/rs rPrzImageSoftMask.serializeqsB %%!%c9n!5%!%S)^ 4%%T#y.%9: % %%%%%%rRrrc#\Kt|trU|V|}|jD]3}t|ttfrt |Ed{V4dS|V|jD]3}t|ttfrt |Ed{V4dSr)rr"rTrr!r)rroot_gcchs rPrrs$ $$ + ++--$ + +B" <== +&r??******* + + / + +B" <== +&r??******* + +rRct|D]m}t|trVdD]S}t|j|}t|t r'|jr |jrd|_TndS)N)r.r0T) rrr"rrrCrDrrH)rrattrcols rP_disable_auto_alphar3s   .. a % % .6 . .agt,,c=11.|. (>(>(@(@.)-..rRct|trWt}t|j|_|j|_|j|_d|jD|_|Stt}t| }t |d|t |d|t |d|j t |d|t |d|j|S)Nchg|]/}t|ttfrt|n|0Sr)rr!r"r)rr/s rPrz#clone_structure..sN   b?K"@AA###    rRr5r6r7r8r9)rr!rrrVrOrr"rIrrTrrKr7r9)rrAroots rPrrs6$(( TZ((   .  o       k * *C 44466 7 7D s4d;;; s/666  Y  s,d333    JrRc4eZdZedGddZejeddfejeddfejeddeddfej eddeddfej eddfej eddfej edddfej edddfejedddeddfejedddeddfejedddedddfejei Zdeezdeezdefd Zed eeefd eeefd ed ddeezf dZdedeeeffdZd ddedededeeeeff dZ dS)r#T)frozenc>eZdZUeed<eeed<dZeed<dS)PaintComposite._Stepdraw mask_fromFrN)rrrrrr rrrrRrP_Stepr:s; C=   rRr=sourceNbackdrop operationc||_||_||_|j|jvrt d|jjddS)NzCompositing mode 'z' is not yet supported.)r?r>mode_MODESrr')rOr?r>r@s rPrQzPaintComposite.__init__sT !   9DK ' '%MTY_MMM  ( 'rRpathr<rrr@rUct|}t|}t|}|t dddd}|t dddd} || } t||||| } | |j_ t||S)NrFr)r) rrrrrrrrrr7r3) rrDr<rrrr rbb_prrrs rP _with_maskzPaintComposite._with_masks TNN  + +A . .  ( ( 3 3~~eAqkkU~CCAF~~eAqkkU~CCAFjj&&  " " q&+#  ArRwhichc*|dkr|jn|jS)Nr>)r>r?)rOrHs rP_pickzPaintComposite._pick s#x//t{{T]BrRrrrc|j|j}|sd||fSg}|D]}||j}|j5||||j|j|}|||||\} }}|| d |||fS)Nryr) rCrBrJr;r<rGrrrr|) rOrrrrstepsrstrrMs rPrzPaintComposite.render#s DI& 0y-/ /  B::bg&&D|'$**R\22BI?P+/++!5)]++ 'Ay- LLOOOOxx =88rR)!rrrrr=r"SOURCE DESTINATION SOURCE_OVERDESTINATION_OVER SOURCE_INDESTINATION_IN SOURCE_OUTDESTINATION_OUT SOURCE_ATOPDESTINATION_ATOPXORCLEARrrCr"r!rQrrrrGrrJrrrrrrRrPr#r#sYd #eeHd&;&;%=(55T+B+B*D( E*d # # E(D ! !+  - E(D ! ! E*d # #0  &x)D)D(F+eeJ.I.I-K'%%*d*K*K)M,uuZ4/P/P.R( E*h - - E(J ' '+  - E(J - - E*h ' '0   E(J - - E*h - -#  "EEGG7F< / o- (    K01o56  -   & [.C3C5o)E#FCCCC9,99 9  9 sJ% & 999999rRr#c eZdZdZdededdfdZdddefd Zde e e e e ffd Z d e ee fd e ee fd e ee fde eedfde ee fddf dZdS) BlendGroup)context base_stylerr\r]rUNcb||_t||_t|_dSr)r\rr]rr)rOr\r]s rPrQzBlendGroup.__init__?s' ":..;>55rRrr@c |j||jtt ddt dd\}}}|||_|Sr)r\rr]rrrrrs rPrzBlendGroup.renderDsf|** /5A;;''1++ +  1 +66v>> rRc|jtdd|jd\}}|sdS|S)NrTr)rrrrrrrr)r\rrr]rr)rOrSrTs rPrzBlendGroup.get_bounding_boxNsY,++ !QKKt$,  a}} (''}}rRrrshading_objs_per_namefont_objs_per_index)r>r?r'rc^i}|jD]G\}}||tt |Hg} |t j} | rjdfdt| D} | r:| td d| d|t j } | rjdfdt| D} | r:| td d| d|t j} | rjdfdt| D} | r:| td  d| d|t j}|rjdfd t|D} | r:| td  d| d|t j}|rjdfd t|D} | r:| td  d| d| rdd| zdzndS)Nryc3K|]:}|vt|d|jdV;dSrr)rrOrs rPrz5BlendGroup.get_resource_dictionary..fsg!!111::''))QQ,B4,H,KQQQ1111!!rRrrrc3K|]:}|vt|d|jdV;dSrr)rrOrs rPrz5BlendGroup.get_resource_dictionary..pg!!000::''))PP,A$,G,JPPP0000!!rRr.c3K|]:}|vt|d|jdV;dSrr)rrOras rPrz5BlendGroup.get_resource_dictionary..zrfrRShadingc3K|]W}t|vtd|dt|jdVXdS)FrrNrr3rr)ridxrbs rPrz5BlendGroup.get_resource_dictionary..sy!!s88222 C ??,,..WW1DSXX1N1QWWW2222!!rRFontc3K|]W}t|vtd|dt|jdVXdS)r*rrNrk)rrlr's rPrz5BlendGroup.get_resource_dictionary..sy!!s88111 C ??,,..VV1CCHH1M1PVVV1111!!rRr)z<<>>)rrrrhrgetr' EXT_G_STATEr|rrr3rrlriFONTX_OBJECT)rOrrrarbr'rrtypernr ext_g_states serializedpatternsshadingsfontsxobjectss ````` rPrz"BlendGroup.get_resource_dictionaryVsAC"&. P P E; + +E355 9 9 = =c+>N>N O O O O+//0KLL  Q!!!!"<00!!!J  Q [ 1 1 ; ; = =OOOOOPPP'++O,CDD  O!!!!"8,,!!!J  O Y 9 9 ; ;MMzMMMNNN'++O,CDD  O!!!!"8,,!!!J  O Y 9 9 ; ;MMzMMMNNN$(()=>>  L!!!!!%==!!!J  L V 6 6 8 8JJJJJJKKK'++O,DEE  O!!!!!(++!!!J  O Y 9 9 ; ;MMzMMMNNN/4@tbggenn$t++&@rR)rrrrr!rrQrrrrrrr4rrrrrRrPr[r[<s/6IAA]AtAAAA (9c%ueU(B"C@A $S)^ 4@A $CN3@A $CN3 @A "#u-F'G"GH @A !i0 @A @A@A@A@A@A@ArRr[c xeZdZdZdeezdeezdeddfdZdd d ede fd Z dd d ed e de de ee e ff dZdS)rr?r>r1 _form_indexr?r>r1rUNc>||_||_||_d|_dSrr{)rOr?r>r1s rPrQzPaintBlendComposite.__init__s) BJ ?E %/*.rRrr@r]c|j|jSt}|j}|j}t |tt fsJt |tt fsJ|j|j_|jjdurtj |j_| |d| |d|}t||}| ||_d|_d|_|jS)NFr^)r|r!r?r>rr"r1rr+rr?r'r[register_blend_form)rOrr]group backdrop_node source_noder blend_groups rP_ensure_form_indexz&PaintBlendComposite._ensure_form_indexs   '# #!! k -/;)GHHHHH+'EFFFFF'+ $   /5 8 83@3HK  0 }E222 {%000$ 88 ,@@MM  rRrrrcD|||}d|d}|||fS)Nzq /Ir#)r)rOrrrr form_indexrs rPrzPaintBlendComposite.renders7,,->FF +*+++M11rR)rrrrr!r"r rQrrrrrrrrrrRrPrrsCI /!K/ / +- / /  / / / / !2 @M     6 2, 2 2 2  2 sJ% & 2 2 2 2 2 2rRrc:eZdZ ddeezdedddffd ZdeeefddfdZ deeefddfd Z d eeefd eeefd eeefddfd Z d eeefd eeefddfdZ dededede de deeefddfdZddZxZS)PathPenNpdf_pathglyphSetr;rUcv||_d|_d|_t|dS)NF)r)rlast_was_line_to first_is_moverQrQ)rOrrrHs rPrQzPathPen.__init__s=5= &+-1 (+++++rRrcR|jj|d|_|j d|_dSdS)NFT)rrerrrOrs rP_moveTozPathPen._moveTos; r"" %   %!%D    & %rRcR|jj|d|_|j d|_dSdS)NTF)rrmrrrs rP_lineTozPathPen._lineTos; r"" $   %!&D    & %rRpt1pt2pt3c |j|d|d|d|d|d|dd|_|j d|_dSdS)Nrr)rrrrrxryF)rr{rr)rOrrrs rP _curveToOnezPathPen._curveToOnesq 1v#a&SVA3q6c!f    !&   %!&D    & %rRc|j|d|d|d|dd|_|j d|_dSdS)Nrr)rrrrF)rrrr)rOrrs rP _qCurveToOnezPathPen._qCurveToOnesY ((CFs1v#a&SQRV(TTT %   %!&D    & %rRrrrArrCrc |j||||||d|dd|_|j d|_dSdS)Nrr)rrrArrrrF)rrrr)rOrrrArrCrs rParcToz PathPen.arcTosi  !f!f    !&   %!&D    & %rRcx|jr|j|jdSr)rrrbrrs rP _closePathzPathPen._closePaths=   5 M 2 2 4 4 4 rRrr)rrrrLr"r rQrrrrrrrrrrrs@rPrrs  , ,, ,   ,  , , , , , ,&%u -&$&&&& '%u -'$'''' ' 5%<  '5%<  '5%< '  ' ' ' ''eUl 3'%u :M'RV'''' ' ' ' '  '  '5%< ' '''',rRrceZdZdZddZdS) GlyphPathPenz;A pen that can be used to draw glyphs into a `PaintedPath`.rUNc8|jdS)z The difference between GlyphPathPen and PathPen is that GlyphPathPen does not remove the last path element before closing the path. This last line back to start point is necessary for correctly rendering glyphs. N)rrrs rPrzGlyphPathPen._closePaths rRr)rrrrrrrRrPrrs.EErRr)r)rr collectionsr contextlibrcopyr dataclassesrtypesrtypingrr r r r r rrrrrrrfontTools.pens.basePenrdrawing_primitivesrrrrrrrrrenumsr r!r"r#r$r%r&r'r(r)r*rmr+r,r-r.r/r0r1r2syntaxr3r4r5r6utilr7r8r9r:fontTools.ttLibr;rxr<r=outputr>r?r@rArrCrrTrrrrrrrrrrrrrrrrrrrrr#r.r8r?rrrrrrrrrr r r r r rrrrrrrrrrrrrrrr3r"rLrr!rrrr3rr#r[rrrrrRrPrs ######%%%%%%!!!!!! +*****                                                                    ?>>>>>>>>>>>DDDDDDDDDDDD?******((((((((>>>>>>>>>>% Y%%%yyyyyyyyx!!!!!-!!!Hj j j j j *j j j Z WT)))PPPPPPPPf&&&&&&&&(UsUsAAuA5ASAAAA+4+4+4+4+4:+4+4+4\-7-7-7-7-7:-7-7-7`,:,:,:,:,::,:,:,:^.?.?.?.?.?:.?.?.?b+G+G+G+G+GZ+G+G+G\2G2G2G2G2GZ2G2G2Gj,G,G,G,G,G:,G,G,G^2G2G2G2G2G:2G2G2Gj    " (- 38      >C #).5: %[.<N<N<N<N<N*<N<N<N~Y Y Y Y Y *Y Y Y xC C C C C :C C C L3S3S3S3S3S:3S3S3SlG G G G G *G G G TCECECECECE*CECECEL9 9 9 9 9 9 9 9 xkDkDkDkDkDzkDkDkD\UGUGUGUGUGjUGUGUGp . . . . .j . . .z7z7z7z7z7:z7z7z7z*,*,*,*,*,J*,*,*,Z,7,7,7,7,7J,7,7,7^' tuuQ{{+++D*+++ , a < < )= U1a[[eeAqkk***J3O2N U1a[[eeAqkk333#ZceAqkkAU%UU1a[[C +{eAqkkAU%UU1a[[   L*&I%%1++EE!QKKHHHIzHHH$4$4 E!QKKeeAqkka %%%z"'a EE!QKKHHHGZHHHt 7<"4PPPRD* "/NJ000E:}%}%}%}%}%}%}%}%@ WT'''J ?J ?J ?J ?J ?J ?J ?J ?ZK?K?K?K?K?;K?K?K?\ WT*+++x?x?x?x?x?x?x?x?v FFFFFFFFR4%4%4%4%4%4%4%4%n+ K '+ o +,++++".eK$@A.d....  K ' {"    Ff9f9f9f9f9f9f9f9RZAZAZAZAZAZAZAZAz2222222222222222jGGGGGgGGGT     7     rR