2

see the following MWE I am trying to find a solution for the following task.

The outer rectangle should start with white color, also the inner one. the rectangle between is only for demonstration purposes and the color should be red.

The area between inner and outer rectangle should be colorized (white - red -white) and the area of the inner rectangle should remain white.

I was playing with pst-grad and pst-slpe but I cannot handle this in a right way.

\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass{article}

\usepackage{pst-node}
\usepackage{pst-blur}
\usepackage{pst-grad}
\usepackage{pst-slpe}
\usepackage{multido, pst-intersect, pst-tools,multicol}
\usepackage{pstricks-add}

\usepackage[a4paper,margin=0cm]{geometry}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{pspicture}[showgrid=false](-1.25,0)(50,-32)
\rput(0,-2.5){\psframe[linecolor=black!10,fillstyle=none,fading,slopebegin=white,slopeend=white](-1.25,0)(18.5,-29.0)}

\rput(0,-2.5){\psframe[linecolor=red,fillstyle=none,fading,slopebegin=white,slopeend=white](-0.25,-1)(17.5,-28.0)}

\rput(0,-2.5){\psframe[linecolor=black!10,fillstyle=solid,fillcolor=white](0.75,-2)(16.5,-27.0)}
\end{pspicture}

\end{document}

Any ideas?

3

Here's a TikZ solution. If you need to stick to pstricks, perhaps the same method could be applied there which is, basically, to fill the entire rectangle and to then fill 4 trapeziums to make the borders. (But the borders could be larger than the bit in the middle, of course. This is just how I thought about it.)

\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  [
    vshade/.style={bottom color=white, top color=white, middle color=red},
    hshade/.style={left color=white, right color=white, middle color=red},
  ]
  \def\borderwidth{10pt}
  \fill [white] (-5,-3) coordinate (d) rectangle (5,3) coordinate (b);
  \shade [vshade] (d |- b) coordinate (a) -- (b) -- +(\borderwidth,\borderwidth) coordinate (B) -- (a |- B) -- +(-\borderwidth,0) coordinate (A) -- cycle;
  \shade [vshade] (d) -- (d -| b) coordinate (c) -- +(\borderwidth,-\borderwidth) coordinate (C) -- (d |- C) -- +(-\borderwidth,0) coordinate (D) -- cycle;
  \shade [hshade] (D) -- (A) -- (a) -- (d) -- cycle;
  \shade [hshade] (C) -- (B) -- (b) -- (c) -- cycle;
\end{tikzpicture}
\end{document}

tikz solution

  • +1 yes, I think this is the right general approach for the pstricks too. – Alan Munn Aug 28 '16 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.