为 psSolid 对象的每个面添加颜色

为 psSolid 对象的每个面添加颜色

在以下 MWE 中,如何为每个面指定一种颜色?

\documentclass{minimal}
\usepackage{pst-solides3d}

\begin{document}
\begin{pspicture}(0,0)(3,4)
\psset{Decran=50,viewpoint=25 8 -5}
\psSolid[object=new,
  sommets=
     0         0        0
     0.343561  1.05737  1
    -0.899454  0.653491 1
    -0.899454 -0.653491 1
     0.343561 -1.05737  1
     1.11179   0        1,
  faces={%
    [0 1 5]
    [0 5 4]
    [0 4 3]
    [0 3 2]
    [0 2 1]
    [1 2 3 4 5]},
    file=pyramid, action=writesolid]%
\psSolid[object=datfile, file=pyramid, action=draw**]
\end{pspicture}
\end{document}

提前致谢。

答案1

给每张脸添加颜色的一种方法如下:

\documentclass{minimal}
\usepackage{pst-solides3d}

\begin{document}
\begin{pspicture}(0,0)(3,4)
\psset{Decran=50,viewpoint=25 8 -5}

%%%
%%% This \psSolid part should be uncommented when compiling the document
%%% for the first time to save sommets and faces in files
%%% pyramid-sommets.dat
%%% pyramid-faces.dat
%%% 
%%% Once pyramid-sommets.dat and pyramid-faces.dat exists, 
%%% there is no reason to execute this part again.
%%%
% \psSolid[object=new,
%   sommets=
%      0 0 0
%      0.343561  1.05737  1
%     -0.899454  0.653491 1
%     -0.899454 -0.653491 1
%      0.343561 -1.05737  1
%      1.11179   0        1,
%   faces={%
%     [0 1 5]
%     [0 5 4]
%     [0 4 3]
%     [0 3 2]
%     [0 2 1]
%     [1 2 3 4 5]},
%     file=pyramid, action=writesolid]%


\pstVerb{/mycolor1 {0.8 0.6 0.2 setrgbcolor} def
%         /somename {0..1 0..1 0..1 setrgbcolor} def
        }%
\psSolid[object=datfile, file=pyramid, action=draw**,
  fcol=0 (red) 1 (mycolor1) 4 (OliveGreen)]
\end{pspicture}
\end{document}

例子

笔记:

  1. 有一个文件 pyramid-couleurs.dat,其中包含每个面的 RGB 颜色。但是,我尝试使用它没有成功。这可能是一个错误,导致文件无法读取(或无法正确读取,我不知道)。

  2. 代替

\psSolid[object=datfile, file=pyramid, action=draw**,
  fcol=0 (red) 1 (mycolor1) 4 (OliveGreen)]

可以使用

\psSolid[object=new, action=draw**,
  sommets={(pyramid-sommets.dat) run},
  faces={(pyramid-faces.dat) run},
  fcol=0 (red) 1 (mycolor1) 4 (OliveGreen)]

这样就不需要存储文件 pyramid-couleurs.dat 和 pyramid-io.dat。

相关内容