mardi 4 avril 2017

Mosaïques en spirale : une animation

Une application de :
 http://pstricks.blogspot.fr/2017/03/mosaiques-en-spirale.html





\documentclass{article}
\usepackage[paperwidth=10.4cm,paperheight=10.4cm,hmargin={0cm,0cm},vmargin={0cm,0cm},dvips]{geometry}
\usepackage{pstricks,multido}
% manuel.luque27@gmail.com
\makeatletter
\pst@addfams{pst-spiralmosaic}
\define@key[psset]{pst-spiralmosaic}{R0}{\edef\psk@pstSpiralMosaicRadius{#1 }}
\define@key[psset]{pst-spiralmosaic}{k}{\edef\psk@pstSpiralMosaicK{#1 }}
\define@key[psset]{pst-spiralmosaic}{n}{\edef\psk@pstSpiralMosaicN{#1 }}
\define@key[psset]{pst-spiralmosaic}{backgroundcolor}{\pst@getcolor{#1}\psbackgroundcolor}
\define@key[psset]{pst-spiralmosaic}{colorA}{\pst@getcolor{#1}\pscolorA}
\define@key[psset]{pst-spiralmosaic}{colorB}{\pst@getcolor{#1}\pscolorB}
\psset{R0=5,k=2,n=10,backgroundcolor=blue,colorA=green,colorB=yellow}
%
\def\psSpiralMosaic{\def\pst@par{}\pst@object{psSpiralMosaic}}
\def\psSpiralMosaic@i{%
    \begin@SpecialObj
\addto@pscode{
 /cm  {\pst@number\psunit mul} bind def
 /backgroundcolor {\pst@usecolor\psbackgroundcolor } def
 /colorA {\pst@usecolor\pscolorA } def
 /colorB {\pst@usecolor\pscolorB } def
 /R0 \psk@pstSpiralMosaicRadius def
 /k@ \psk@pstSpiralMosaicK  def
 /n@ \psk@pstSpiralMosaicN cvi def
n@ 2 mod 0 ne {/n@ n@ 1 add def} if
gsave
newpath
R0 cm 0 moveto
0 0 R0 cm 0 360 arc
closepath
backgroundcolor
fill
grestore
newpath
R0 cm 0 moveto
0 0 R0 cm 0 360 arc
closepath
clip
/t01 {r_0 360 mul n@ div neg} def
/t02 {r_0 1 add 360 mul n@ div neg} def
/RadiusA {n@ 360 div t mul r_0 add } def
/RadiusB {n@ 360 div t mul r_0 1 add add } def
/spiraleA {
RadiusA t cos mul cm RadiusA t sin mul cm moveto
t01 2 k@ 360 mul {/t exch def
RadiusA t     cos mul cm RadiusA t     sin mul cm lineto
 } for
} def
/spiraleB {
RadiusA t cos mul cm RadiusA t sin mul cm moveto
t01 -2 k@ -360 mul {/t exch def
RadiusA t cos mul cm RadiusA t sin mul cm lineto
 } for
} def
%
-3 2 n@ {/r_0 exch def
%
 gsave
% 2 spirales tournant a droite
newpath
/t t01 def
spiraleA
/t t02 def
k@ 360 mul -2 t02 {/t exch def
RadiusB t     cos mul cm RadiusB t     sin mul cm lineto
 } for
closepath
clip
%
1 2 n@ {/r_0 exch def
% 2 spirales tournant a gauche
newpath
/t t01 def
spiraleB
/t t02 def
k@ -360 mul 2 t02 {/t exch def
RadiusB t cos mul cm RadiusB t sin mul cm lineto
 } for
closepath
colorA
fill
} for
grestore
} for
%%%%%%%%%%%%%%%%%%%%%%%%%
-2 2 n@ {/r_0 exch def
gsave
newpath
/t t01 def
RadiusA t cos mul cm RadiusA t sin mul cm moveto
t01 2 k@ 360 mul {/t exch def
RadiusA t     cos mul cm RadiusA t     sin mul cm lineto
 } for
/t t02 def
k@ 360 mul -2 t02 {/t exch def
RadiusB t     cos mul cm RadiusB t     sin mul cm lineto
 } for
closepath
clip
%
0 2 n@ {/r_0 exch def
newpath
/t t01 def
RadiusA t cos mul cm RadiusA t sin mul cm moveto
t01 -2  k@ -360 mul {/t exch def
RadiusA t cos mul cm RadiusA t sin mul cm lineto
 } for
/t t02 def
k@ -360 mul 2 t02 {/t exch def
RadiusB t cos mul cm RadiusB t sin mul cm lineto
 } for
closepath
colorB
fill
} for
grestore
} for
\ifx\pslinestyle\@none\else
gsave
-3 1 n@ {/r_0 exch def
newpath
/t t01 def
spiraleA
\pst@usecolor\pslinecolor
\pst@number\pslinewidth SLW
stroke
newpath
/t t01 def
spiraleB
\pst@usecolor\pslinecolor
\pst@number\pslinewidth SLW
stroke
} for
grestore
\fi
 }%
\showpointsfalse
\end@SpecialObj
}
\makeatother
\title{Disque de mosaïque en spirale}
\author{manuel.luque27@gmail.com}
\date{27 mars 2017}
\begin{document}
%\maketitle
\begin{center}
\def\mosaic{\psSpiralMosaic[n=2,k=4,linestyle=solid,backgroundcolor=white,colorA=red,colorB=blue]}%
\def\anneauA{%
\psclip{\pscustom[linestyle=none]{\psarc(0,0){1}{0}{360}}}
\mosaic
\endpsclip}%
\def\anneauB{%
\psclip{\pscustom[linestyle=none]{\psarc(0,0){1}{0}{360}\psarcn(0,0){2}{360}{0}}}
\mosaic
\endpsclip}%
\def\anneauC{%
\psclip{\pscustom[linestyle=none]{\psarc(0,0){2}{0}{360}\psarcn(0,0){3}{360}{0}}}
\mosaic
\endpsclip}%
\def\anneauD{%
\psclip{\pscustom[linestyle=none]{\psarc(0,0){3}{0}{360}\psarcn(0,0){4}{360}{0}}}
\mosaic
\endpsclip}%
\def\anneauE{%
\psclip{\pscustom[linestyle=none]{\psarc(0,0){4}{0}{360}\psarcn(0,0){5}{360}{0}}}
\mosaic
\endpsclip}%
\multido{\i=0+-2}{180}{%
\begin{pspicture}(-5.2,-5.2)(5.2,5.2)
\psframe*(-5.2,-5.2)(5.2,5.2)
\rput{\i}{\anneauA}
\rput{!\i\space neg}{\anneauB}
\rput{\i}{\anneauC}
\rput{!\i\space neg}{\anneauD}
\rput{!\i}{\anneauE}
\multido{\I=1+1}{5}{\pscircle{\I}}
\end{pspicture}\newpage}
\end{center}
\end{document} 


Aucun commentaire:

Enregistrer un commentaire