5

I want to create something like this:

enter image description here

By filling a rectangle.

NOTE: Ignore the borders of the image, I just want to give that texture to a tikz rectangle.

hkviktor
  • 662

1 Answers1

9

A brute-force attempt with pgfplots: there are surely better ways. :-)

The "coarseness" of the texture can be adjusted using the samples key value. For this fine of a texture, LuaLaTeX must be used (dynamic memory allocation). For samples=100 or fewer, any modern engine can be used.

\IfFileExists{luatex85.sty}{%
  \RequirePackage{luatex85}%
}{}
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  view={0}{90},
  hide axis=true,
  samples=200,
  colormap={papyrus}{
    cmyk(0cm)=(0.00,0.08,0.24,0); 
    cmyk(1cm)=(0.00,0.08,0.24,0.05)
  },
]
  \addplot3[surf,shader=interp] {rand};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

cfr
  • 198,882
Paul Gessler
  • 29,607
  • That's the effect I needed. I'll try it later :) – hkviktor Mar 08 '15 at 19:12
  • Hi Paul, I'm trying this minimal, but this show an error: !Package pgfkeys: Choice '1.12' unknown in key '/pgfplots/compat/labels'. Do you know what's going on? – MrSelberg Sep 23 '15 at 19:32
  • @MrSelberg you probably have an older version of pgfplots installed than 1.12. – Paul Gessler Sep 23 '15 at 19:52
  • 2013.84.1.7svn29531-17.1.7-noarch. That's my version. – MrSelberg Sep 23 '15 at 19:56
  • I'll install the latest. That's must be the problem. I'll coment in a while. – MrSelberg Sep 23 '15 at 20:07
  • @MrSelberg this example probably doesn't require v1.12 (though I can't check at the moment); it's just a habit of mine to set compat to the version I used to create the answer. This avoids warnings and makes the answer "future-proof" in case the behavior/syntax changes in future versions. If I were you, I'd just try removing the compat=1.12 before doing a bunch of other stuff to get pgfplots updated. Of course, it's not a bad idea to get updated, either. Just a matter of what's more important to you at the moment. – Paul Gessler Sep 23 '15 at 20:15
  • 1
    Thanks Paul. I tried it before (remove that line) did not work. But I solve the problem: I had an older version of the package. With the newest version everything is ok. :D – MrSelberg Sep 23 '15 at 20:22