summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/mpattern/README
blob: 5f6441c018d544e3043e944be8a9034d454707b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of the MPATTERN package
%
% Author: Piotr Bolek
% wersja: 0.5 (Jun 25, 2001)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Description
===========

Package MPATTERN gives ability to define and use patterns in
MetaPost. It uses Pattern Color Space available in PostScript Level 2.

Package contains:
- mpattern.mp: MetaPost macros for defining and using patterns.
- README: short description in English.
- README.PL: short description in Polish.
- test.mp, test.tex, test.ps: usage examples.

Using package
=============

Include the file mpattern.mp with the input command at the beginning
of the source file and process the source file with the standard mpost
program.

User Interface
==============

Defining pattern
----------------

Patterns are defined using the following construct:

beginpattern(<name_of_pattern>);
...
endpattern;

Parameter <name_of_pattern> is the name by which the pattern is
identified. This name can contain letters and underscore characters
"_" but not digits. This name should NOT be given in quotes.

One or more of the following macros can be invoked in any place
inside pattern definition (between beginpattern and endpattern):
- patternbbox(<pair>,<pair>)
- patternbbox((<numeric>,<numeric>,<numeric>,<numeric>) 
  Explicit coordinates of bounding box of pattern cell

- patternxstep(<numeric>)
- patternystep(<numeric>)
- patternstep(<numeric>,<numeric>)
- patternstep(<pair>)
  Pattern spacing

- patterntransform(<transform>)
  Transformation of pattern shape

- patterncolor(0<= <numeric> <= 1)
  Explicit color replaced later by pattern

Each pattern is temporarily written as picture with big number
(default is 999) but when user will use this number for his own
picture then for temporal storing of next patterns the greatest free
number less then 999 will be used.

Using patterns
--------------

Already defined pattern can be used for filling objects with
two argument withpattern macro. It is used as follows:

<path> withpattern <name_of_pattern>;

where <path> is any valid expression defining closed path and
<name_of_pattern> is the name given in definition of the pattern.

Example
-------

Here is code to draw two circles filled with different checker
patterns.

input mpattern;

beginpattern(checker);
 d:=4mm;
 fill unitsquare scaled d;
 fill unitsquare scaled d shifted (d,d);
 patternbbox(0,0,2d,2d);
endpattern;

beginpattern(rotated_checker);
 fill unitsquare scaled 4mm rotated 45 withcolor .7white;
endpattern;

beginfig(11);
 path p;
 z1=(1cm,1cm);
 p=fullcircle scaled 3cm;
 fill p withpattern checker;
 unfill p shifted z1;
 fill p shifted z1 withpattern rotated_checker;
endfig;

Distribution of the package
===========================

The package MPATTERN belongs to the public domain. You can use any
actuall version of GPL Licence if you want to modify or redistribute
this package.

Problems
========

06-2001: Filling text with patterns can make problems. The current
	 solution is unstable.

Changes
=======

06-2001: By the inspiration by the Piotr Strzelczyk's tutorial at the
	 BachoTeX'2001 conference the necesity of Perl postprocessing
	 is eliminated. The substitution of colors to patterns is now
	 performed with help of dictionaries at the PostScript level.

Contact with author
=================

e-mail: P.Bolek@gust.org.pl