Source PostScript (gradientfill.pps)

Retour Texte non formaté
%% %%BeginProcSet: pst-grad.pro %% %! %% % PostScript prologue for pst-grad.tex. %% % Version 97, 93/05/12 %% % For distribution, see pstricks.tex. %% % %% % For the PSTricks gradient fillstyle. %% % %% % Based on some EPS files by leeweyr!bill@nuchat.sccsi.com (W. R. Lee). %% % %% % Syntax: %% % R0 G0 B0 R1 G1 B1 NumLines MidPoint Angle GradientFill %% %% modifie par jpv@melusine.eu.org (J. P. Vignault) le 22/05/2005 pour %% %% adaptation a jps2ps (http://melusine.eu.org/syracuse/bbgraf/) %% /GradientFill { %% 40 dict begin %% rotate %% /MidPoint exch def %% /NumLines exch def %% /LastBlue exch def %% /LastGreen exch def %% /LastRed exch def %% /FirstBlue exch def %% /FirstGreen exch def %% /FirstRed exch def %% % This avoids gaps due to rounding errors: %% clip %% pathbbox %leave llx,lly,urx,ury on stack %% /y exch def /x exch def %% 2 copy translate %% y sub neg /y exch def %% x sub neg /x exch def %% % This avoids gaps due to rounding errors: %% LastRed FirstRed add 2 div %% LastGreen FirstGreen add 2 div %% LastBlue FirstBlue add 2 div %% setrgbcolor %% fill %% /YSizePerLine y NumLines div def %% /CurrentY 0 def %% /MidLine NumLines 1 MidPoint sub mul abs cvi def %% MidLine NumLines 2 sub gt %% { /MidLine NumLines def } %% { MidLine 2 lt { /MidLine 0 def } if } %% ifelse %% MidLine 0 gt %% { %% /Red FirstRed def %% /Green FirstGreen def %% /Blue FirstBlue def %% /RedIncrement LastRed FirstRed sub MidLine 1 sub div def %% /GreenIncrement LastGreen FirstGreen sub MidLine 1 sub div def %% /BlueIncrement LastBlue FirstBlue sub MidLine 1 sub div def %% MidLine { GradientLoop } repeat %% } if %% MidLine NumLines lt %% { %% /Red LastRed def %% /Green LastGreen def %% /Blue LastBlue def %% /RedIncrement FirstRed LastRed sub NumLines MidLine sub 1 sub div def %% /GreenIncrement FirstGreen LastGreen sub NumLines MidLine sub 1 sub div def %% /BlueIncrement FirstBlue LastBlue sub NumLines MidLine sub 1 sub div def %% NumLines MidLine sub { GradientLoop } repeat %% } if %% end %% } def %% %% /GradientLoop { %% 0 CurrentY moveto %% x 0 rlineto %% 0 YSizePerLine rlineto %% x neg 0 rlineto %% closepath %% Red Green Blue setrgbcolor fill %% /CurrentY CurrentY YSizePerLine add def %% /Blue Blue BlueIncrement add def %% /Green Green GreenIncrement add def %% /Red Red RedIncrement add def %% } def %% % END pst-grad.pro %% %%EndProcSet %% %% /gradnumlines 300 def %% /gradangle 0 def %% /gradbegin {jaune} def %% /gradend {rouge} def %% /gradmidpoint 1 def %% %% /gradientfill { %% 3 dict begin %% gsave %% /gradmidpoint exch def %% /gradend exch def %% /gradbegin exch def %% gsave %% gradbegin %% currentrgbcolor %% grestore %% gsave %% gradend %% currentrgbcolor %% grestore %% gradnumlines gradmidpoint gradangle GradientFill %% grestore %% end %% } def % PostScript prologue for pst-grad.tex. % Version 1.04, 2004/06/23 (adding %GradientCircle style - D.G.) % prepared by Herbert Voss % For copying restrictions, see pstricks.tex. % For the PSTricks gradient fillstyle.% % Based on some EPS files by leeweyr!bill@nuchat.sccsi.com (W. R. Lee).% % Syntax:% D.G. modification begin - Apr. 9, %1998 %%%%%% R0 G0 B0 R1 G1 B1 NumLines MidPoint Angle GradientFill % ifGradientCircle GradientScale %GradientPosX GradientPosY % R0 G0 B0 R1 G1 B1 NumLines MidPoint %Angle GradientFill % D.G. modification end %% modifie par jpv@melusine.eu.org (J. P. Vignault) le 05/07/2006 pour %% adaptation a jps2ps (http://melusine.eu.org/syracuse/bbgraf/) %/tx@GradientDict 40 dict def %tx@GradientDict begin /GradientFill { rotate /MidPoint exch def /NumLines exch def /LastBlue exch def /LastGreen exch def /LastRed exch def /FirstBlue exch def /FirstGreen exch def /FirstRed exch def % D.G. modification begin - Apr. 9, 1998 /GradientPosY exch def /GradientPosX exch def /GradientScale exch def /ifGradientCircle exch def % D.G. modification end % This avoids gaps due to rounding errors: clip pathbbox %leave llx,lly,urx,ury on stack % D.G. modification begin - Apr. 10, 1998 4 copy /ury exch def /urx exch def /lly exch def /llx exch def % D.G. modification end /y exch def /x exch def % D.G. modification begin - Apr. 10, 1998 ifGradientCircle {0 GradientPosX eq {0 GradientPosX eq {2 copy translate} if} if} {2 copy translate} ifelse % D.G. modification end y sub neg /y exch def x sub neg /x exch def % This avoids gaps due to rounding errors: LastRed FirstRed add 2 div LastGreen FirstGreen add 2 div LastBlue FirstBlue add 2 div setrgbcolor % D.G. modification begin - Jul. 23, 1997 / Apr. 9, 1998 ifGradientCircle {/YSizePerLine y NumLines div def /CurrentY y 2 div def /MidLine NumLines 2 div 1 MidPoint sub mul abs cvi def} {fill /YSizePerLine y NumLines div def /CurrentY 0 def /MidLine NumLines 1 MidPoint sub mul abs cvi def} ifelse % DG modification end MidLine NumLines 2 sub gt { /MidLine NumLines def } { MidLine 2 lt { /MidLine 0 def } if } ifelse MidLine 0 gt { /Red FirstRed def /Green FirstGreen def /Blue FirstBlue def /RedIncrement LastRed FirstRed sub MidLine 1 sub div def /GreenIncrement LastGreen FirstGreen sub MidLine 1 sub div def /BlueIncrement LastBlue FirstBlue sub MidLine 1 sub div def MidLine { GradientLoop } repeat } if MidLine NumLines lt { /Red LastRed def /Green LastGreen def /Blue LastBlue def /RedIncrement FirstRed LastRed sub NumLines MidLine sub 1 sub div def /GreenIncrement FirstGreen LastGreen sub NumLines MidLine sub 1 sub div def /BlueIncrement FirstBlue LastBlue sub NumLines MidLine sub 1 sub div def NumLines MidLine sub { GradientLoop } repeat } if } def/GradientLoop { % D.G. modification begin - Jul. 23, 1997 / Apr. 9, 1998 ifGradientCircle {CurrentY 0 gt { % The default center used is the center of the bounding box of the object 0 GradientPosX eq {0 GradientPosX eq {/GradientPosX urx llx sub 2 div def /GradientPosY ury lly sub 2 div def} if} if GradientPosX GradientPosY CurrentY GradientScale mul 0 360 arc Red Green Blue setrgbcolor fill /CurrentY CurrentY YSizePerLine sub def /Blue Blue BlueIncrement add def /Green Green GreenIncrement add def /Red Red RedIncrement add def} if} {0 CurrentY moveto x 0 rlineto 0 YSizePerLine rlineto x neg 0 rlineto closepath Red Green Blue setrgbcolor fill /CurrentY CurrentY YSizePerLine add def /Blue Blue BlueIncrement add def /Green Green GreenIncrement add def /Red Red RedIncrement add def} ifelse% D.G. modification end }def % end % END pst-grad.pro /gradnumlines 300 def /gradangle 0 def /gradbegin {jaune} def /gradend {rouge} def /gradmidpoint 1 def /gradientcircle false def /gradientscale 1 def /gradientcircposx 0 def /gradientcircposy 0 def /gradientcirclefill { 10 dict begin 6 copy pop pop pop /gradientscale exch def /gradcircrelposy exch def /gradcircrelposx exch def /gradientcircle true def pathbbox %%%leave llx,lly,urx,ury on stack /ury exch def /urx exch def /lly exch def /llx exch def /gradientcircposx llx urx add 2 div gradcircrelposx add def /gradientcircposy lly ury add 2 div gradcircrelposy add def gradientfill pop pop pop end } def /gradientfill { 3 dict begin gsave /gradmidpoint exch def /gradend exch def /gradbegin exch def gradientcircle gradientscale gradientcircposx gradientcircposy gsave gradbegin currentrgbcolor grestore gsave gradend currentrgbcolor grestore gradnumlines gradmidpoint gradangle GradientFill grestore end } def