I am working on a project that will have some vector graphics, perhaps using TikZ (or a similar tool). All of the graphics consists of lines, in shades of gray. However, the lines from TikZ appear too clean. Is there any way to make the lines appear as if they were produced by a graphite pencil?
|
|
I'm posting this just because you mentioned specifically the lines. I modified the
Here is the output:
I'm currently studying the |
||||
|
|
|
Only for the fun, I took Marc's suggestion and I create a new decoration
|
|||
|
|
|
In terms of regular (straight) lines,
that draws a straight line with some "jagging." The "jagging" parameters that influence the line drawing are
This requires a |
|||
|
|
|
There are lots of nice answers here addressing how to get that "hand drawn" look with the shape of the lines. I'm going to sketch an approach to getting the texture right. I spent a bit of time this afternoon staring at some lines drawn with a 9B pencil on paper and decided that what it looked most like was a brass rubbing. That is, the stroke of the pencil reveals the texture of the paper underneath. This is most like a fading in TikZ/PGF parlance. The cheap and nasty paper that I buy doesn't have much of a grain to it (I have kids, they do art, I buy about 5 reams every six months). The pattern looks more like noise. So having learnt about Perlin noise recently, I thought that would be an appropriate thing to simulate the paper texture with. I soon decided that a TeX implementation would be daft, so went hunting for a Lua version and found one of the closely related Simplex noise (also due to Perlin; the link goes to a Lua implementation; the author uses strong language both in comments and function names). So I hacked that into a Lua file for LuaTeX and wrote a little demonstration LaTeX file. I'm calling this an approach because it needs considerable work to be useful. For one thing, even though I'm using Lua to do the heavy processing then it takes time to render the fading. So given that noise isn't usually required to be too random, one should do a lot of caching: both of the original generated numbers and the graphic used for the fading itself. There's also a fair bit about fadings that I don't understand, particularly related to how the fading and the picture match up. What should happen is that one uses one fading for the whole picture so that strokes laid over each other end up using the same noise and thus work as though they are on top of the same piece of paper. This would also need a little work to do with positioning. The code isn't too complicated. Here's the LaTeX file:
The Here's the lua file:
It is almost entirely just clipped out from the lua implementation linked above. There's no obvious licence information there, but consider it covered under whatever-licence-it-would-be-there. Here's the result of that code:
|
|||||||
|
|
Here are two pens with MetaPost (using ConTeXt format), I feel the code is pretty self-explanatory:
This is the first time I have used MetaPost with ConTeXt, and was happy how to see how easy it is to use. |
|||
|
|
|
Based on Marcs solution I tried to mimic the ps-tricks results (randomized/imprecise coordinates) shown by Werner using tikz:
Maybe someone can improve this, i.e. find a more general way to randomize coordinates, as this solution for example will not randomize all corners of a rectangle automatically. |
||||
|
|
|
This is another attempt to simulate hand drawn curves in Metapost. This is heavily inspired by the MetaFun macros. The main advantage of this approach is that you don't have change your drawing macros at all. Simply Save the following as
The main macro is To use these, you also need to load
which gives
Since the
The figure on the top shows the output without
And here is a slightly tweaked version of example 83 of metapost examples
In my biased opinion, this looks more natural than many of the other solutions. |
||||
|
You might want to create a brush (possibly with transparency) and apply it repeatedly on the paths created by the other replies, possibly with some transformations of the brush itself to make it appear even more random. Intensity effects can be achieved with a highly transparent brush and changing "velocity" of the path movement (or changing frequency of applying the brush). See how a graphite effect is created in this drawing pad, or the airbrush tool in GIMP. I am not an expert in graphics so I cannot give much advice here; my feeling is that you will need to experiment quite a bit to achieve the desired result. (On that note: A sample drawing would help understand your question better.) You can use marking decorations (Section 30.4 in the PGF manual). There is also an example that draws arrows along a path, so I'm pretty sure you can do the same thing with a vector or bitmap brush. This has been borrowed from the manual:
The size of the PDF will not be affected much because TikZ can be instructed to load the brush only once. However, rendering may take quite a while. |
||||
|
|









