
    BPcO(                         d dl mZmZmZ d dlZd dlmZmZ d dlmZ d dl	m
Z 	 	 	 	 	 	 	 	 dd
Z G d dej                  Zedk    r e                                             dS dS )    )cospisinN)ClipPath	Rectangle)	math_eval)inkex_gettextsin(x)cos(x)TFc                    ,-./01 |rdt           z   z   dt           z  |z  } |k    r#t          j        t          d                     g S || z
  z  .|0.0 fd}|r||dz  z   ,|dz  -,-fd}|k    r#t          j        t          d                     g S ||z
  z  /|1/1fd}|rI|sG/.k     r! |d          }/.||z
  .z   ||z   |z
  .z  }n  |d          }./||z
  /z  ||z   |z
  /z  }t	          |	          }t	          |
          }||#|s!t          j        t          d	                    | z
  |d
z
  z  }|dz  }|dz  }g }|rdcxk    r|k    r>n n;|                    d| |d          gg           |                    d|dgg            dcxk    r|k    r?n n<|                    d |d          |gg           |                    dd| gg            } |           }|r(|t          |          z  }|t          |          z  }|}|}|s|rK |z   } ||          } |r(| t          |          z  }!| t          |          z  }"|!}|"} ||z
  |z  }#| |z
  |z  }$nd
}# |           }$|rN|                    d| |d          gg           |                    d ||           ||          gg           n+|                    d ||           ||          gg           t          t          |d
z
                      D ]}%|%d
z   |z   z   }||z
  }& ||          }  ||&          }'|rP| t          |          z  }!| t          |          z  }"|'t          |&          z  }(|'t          |&          z  })|!}|"} |(}&|)}'|s|r||&z
  |z  }*| |'z
  |z  }+nd
}* ||          }+|                    d |||#|z  z              |||$|z  z              |||*|z  z
             || |+|z  z
             ||           ||           gg           |}| }|*}#|+}$|r%|                    d||z    |d          gg           |S )N   zIx-interval cannot be zero. Please modify 'Start X value' or 'End X value'c                     | z
  z  z   S N )xscalexxoffxstarts    */usr/share/inkscape/extensions/funcplot.py<lambda>zdrawfunction.<locals>.<lambda>G   s    F
f,t3     g       @c                     | z  z   S r   r   )r   centerxpolar_scalexs    r   r   zdrawfunction.<locals>.<lambda>L   s    1|+g5 r   zhy-interval cannot be zero. Please modify 'Y value of rectangle's top' or 'Y value of rectangle's bottom'c                     | z
  z  z   S r   r   )yscaleyybottomyoffs    r   r   zdrawfunction.<locals>.<lambda>X   s    !v-4 r   r   zInvalid function specification   g      @gMbP?MlLC)r   inkexerrormsg_r   AbortExtensionappendr   r   rangeint)2r   xendr   ytopsampleswidthheightleftbottomfxfpxfponumtimes2pipolarisoscaledrawaxisendptscoordxcoordyxzeroyzeroffpstepthirddsax0y0xp0yp0x1y1xp1yp1dx0dy0ix2y2xp2yp2dx1dy1r   r   r   r   r   r   s2   ` `                                         @@@@@@r   drawfunctionrV   %   s   &  R&2v} ~~# 	
 	
 	
 	dVm$FD333333F 6$s{55555w5 	
 	
 	
 	tg~&FD444444F  6 6F??F1IIEFUlf,F5L5(F2DD F1IIEFv~/GVOe+v5D"A	3ByRZZ"1%E#F#FGGG 6Mgk*D3JE	B
A 
*a4HHcD&&)),-...HHcE1:&'''Q$HHcFF1IIv./000HHcAw<())) 
B	
6B 3r77l3r77l b[QrUU 	s2ww,Cs2ww,CBBBw"nBw"nbjj  2	#ffQii()***	#r

FF2JJ/01111	#r

FF2JJ/01113w{##$$ % %!et^f$"WQrUUQrUU 	s2ww,Cs2ww,Cs2ww,Cs2ww,CBBBB 	U 	7b.C7b.CCC"R&&C	F2u-..F2u-..F2u-..F2u-..F2JJF2JJ
	
 	
 	
  3	#uffQii01222Hr   c                       e Zd Zd Zd ZdS )FuncPlotc                    |                     d           |                     dt          dd           |                     dt          dd           |                     d	t          j        d
d           |                     dt          j        d
d           |                     dt          dd           |                     dt          dd           |                     dt          dd           |                     ddd           |                     dt          j        dd           |                     ddd           |                     dt          j        d
d            |                     d!t          j        dd"           |                     d#t          j        dd$           |                     d%t          j        d
d&           |                     d't          j        d
d(           d S ))Nz--tabz--xstartg        zStart x-value)typedefaulthelpz--xendg      ?zEnd x-valuez
--times2piFz* x-range by 2*piz--polarzUse polar coordsz	--ybottomzy-value of rect's bottomz--ytopzy-value of rectangle's topz	--samples   Samplesz--fofxr
   zf(x) for plotting)r[   r\   z--fponumTzNumerical 1st derivz--fpofxr   zf'(x) for plottingz--clipzClip with source rectz--removezRemove source rectz
--isoscalezIsotropic scalingz
--drawaxisz	Draw axisz--endptszAdd end points)add_argumentfloatr%   Booleanr+   )selfparss     r   add_argumentszFuncPlot.add_arguments   sV   '"""*5#OTTT(-PPPu}eBU 	 	
 	
 	
 	EM5?Q 	 	
 	
 	
 	eS7Q 	 	
 	
 	
 	5#4P 	 	
 	
 	
 	+CKKK(H;NOOOU]D?T 	 	
 	
 	
 	)X<PQQQ5=%>U 	 	
 	
 	
 	U]D?S 	 	
 	
 	
 	u}dAT 	 	
 	
 	
 	u}e+ 	 	
 	
 	
 	U]E@P 	 	
 	
 	
 	
 	
r   c                    d }| j         j                                        D ]}t          |t                    rrt          j                    }t          |                    d                    }t          |                    d                    }t          |                    d                    }t          |                    d                    }|j	        |_	        |j
        |_
        t          | j        j        | j        j        | j        j        | j        j        | j        j        |||||z   | j        j        | j        j        | j        j        | j        j        | j        j        | j        j        | j        j        | j        j                  |_        |                    d| j        j                   |                                                    |           | j        j        r| j         j                             tC                                }|"                                 |                    |#                                           |                    d|$                    d                     | j        j%        r'|                                %                    |           |!t          j&        tO          d	                    d S )
Nr   r   r/   r0   titlez	clip-pathr   )as_urlzPlease select a rectangle)(svg	selectionvalues
isinstancer   r%   PathElementr`   getstyle	transformrV   optionsr   r,   r   r-   r.   fofxfpofxr5   r6   r7   r8   r9   r:   pathset	getparentr)   clipdefsaddr   set_random_idcopyget_idremover(   r'   )rb   newpathnoder   r   whrv   s           r   effectzFuncPlot.effect   sK   H&--// -	2 -	2D$	** ,2+--$((3--(($((3--(($((7++,,$((8,,-- !%
$(N!  ,L'L%L(L%L(EL%L&L'L)L&L)L)L'#   & GT\%6777   ''000<$ D8=,,XZZ88D&&(((KK		,,,KKT[[[-B-BCCC<& 2NN$$++D111?&q)D'E'EFFF ?r   N)__name__
__module____qualname__rd   r   r   r   r   rX   rX      s8        $
 $
 $
L1G 1G 1G 1G 1Gr   rX   __main__)r
   r   TFFTTF)mathr   r   r   r%   r   r   inkex.utilsr   inkex.localizationr	   r'   rV   EffectExtensionrX   r   runr   r   r   <module>r      s  8            % % % % % % % % ! ! ! ! ! ! 1 1 1 1 1 1 
#h h h hVXG XG XG XG XGu$ XG XG XGv zHJJNN r   