Manual entries for path parameters

This commit is contained in:
John Whitington 2023-06-06 16:47:51 +01:00
parent 7c81d33c4b
commit e42f1229a7
5 changed files with 143 additions and 11 deletions

Binary file not shown.

View File

@ -4199,7 +4199,7 @@ We can draw on an existing PDF (or a new one created with \texttt{-create-pdf} f
\noindent The first example builds a new A4 portrait PDF with one page, and writes Hello in the default 12pt Times Roman font at the bottom left. The second does the same, but for every page of an existing PDF.
Coordinates in a PDF file have the origin $(0, 0)$ at the bottom-left of the page.
Coordinates in a PDF file have the origin $(0, 0)$ at the bottom-left of the page. All units are in points (1/72 inch).
\section{Building and showing paths}
@ -4289,22 +4289,64 @@ To avoid calculating the Bezier curves for a circle manually, \texttt{cpdf} can
\section{Clipping with paths}
{\small\begin{framed}
\noindent\verb!-clip! Clip\\
\noindent\verb!-clipeo! Clip, even odd\\
\noindent\verb!-clipeo! Clip, even odd
\end{framed}}
\section{Path parameters}
{\small\begin{framed}
\noindent\verb!-strokecol! Set stroke colour\\
\noindent\verb!-fillcol! Set fill colour\\
\noindent\verb!-thick! Set stroke thickness\\
\noindent\verb!-cap! Set cap\\
\noindent\verb!-join! Set join\\
\noindent\verb!-miter! Set miter limit\\
\noindent\verb!-dash! Set dash pattern
\noindent\verb!-strokecol "g" | "r g b" | "c y m k"! Set stroke colour\\
\noindent\verb!-fillcol "g" | "r g b" | "c y m k"! Set fill colour\\
\noindent\verb!-thick n! Set stroke thickness\\
\noindent\verb!-cap butt | round | square! Set cap\\
\noindent\verb!-join miter | round | bevel! Set join\\
\noindent\verb!-miter n! Set miter limit\\
\noindent\verb!-dash <pattern>! Set dash pattern
\end{framed}}
We can set stroke and fill colours for our paths, either as greyscale (one component), RGB (three components) or CYMK (four components):
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -circle "200 200 100" -thick 20?\\
\noindent\small\verb? -strokecol 0.5 -fillcol "0.2 0.7 0.2" -stroke -o out.pdf?
\end{framed}
\noindent Here is the result:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/colfill.pdf}}
\bigskip
\noindent We can set line caps and joins with \texttt{-cap}, \texttt{-join}:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -to "100 100"?\\
\noindent\small\verb?-join round -cap round -thick 40?\\
\noindent\small\verb?-line "200 200" -line "220 100" -stroke?\\
\noindent\small\verb?-o out.pdf?
\end{framed}
\noindent Then we see:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/capjoins.pdf}}
\bigskip
\noindent The miter limit (see PDF reference for details) may be set with \texttt{-miter}.
Lines may have dash patterns. A dash pattern consists of one or more numbers. All save the last form the list of dash lengths and gap lengths. The last is the phase, which defines how far along the pattern we start. For example, using a dash pattern of "30 20 0" i.e black 30, white 20, phase 0:
\begin{framed}
\noindent\small\verb?cpdf -create-pdf AND -draw -to "100 100"?\\
\noindent\small\verb?-dash "30 20 0" -thick 20 -line "400 300" -stroke?\\
\noindent\small\verb?-o out.pdf?
\end{framed}
\noindent Here is the result:
\bigskip
\fbox{\includegraphics[width=0.3\textwidth]{manualimages/dash.pdf}}
\bigskip
\section{The graphics stack and matrices}
{\small\begin{framed}
\noindent\verb!-push! Push graphics stack\\

29
manualimages/capjoins.pdf Normal file
View File

@ -0,0 +1,29 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Catalog/Pages 2 0 R>>
endobj
2 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<<>>/MediaBox[0 0 595.2765 841.89105]/Contents[4 0 R]>>
endobj
4 0 obj
<</Length 48>>
stream
100 100 m 1 j 1 J 1 M 40 w 200 200 l 220 100 l S
endstream
endobj
xref
0 5
0000000000 65535 f
0000000015 00000 n
0000000060 00000 n
0000000111 00000 n
0000000217 00000 n
trailer
<</Size 5/Root 1 0 R/ID[<d15fe412eeb61095b867c18813f4c08a><d15fe412eeb61095b867c18813f4c08a>]>>
startxref
313
%%EOF

32
manualimages/colfill.pdf Normal file
View File

@ -0,0 +1,32 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Catalog/Pages 2 0 R>>
endobj
2 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<<>>/MediaBox[0 0 595.2765 841.89105]/Contents[4 0 R]>>
endobj
4 0 obj
<</Length 99/Filter/FlateDecode>>
stream
xeN1€0û
/à€ÂQWÒÁÉÅÅïXÛpI!¸ <10>Ä/3Cª®K-ƒúœ6`Utg#ö¼ñ”çžhÉþ‰AaZ9ísM™
ú;vBƒ-¶Äxâ¹ÃzÚ¬+
endstream
endobj
xref
0 5
0000000000 65535 f
0000000015 00000 n
0000000060 00000 n
0000000111 00000 n
0000000217 00000 n
trailer
<</Size 5/Root 1 0 R/ID[<4ba93f9e60c81a25903b75d279047af4><4ba93f9e60c81a25903b75d279047af4>]>>
startxref
383
%%EOF

29
manualimages/dash.pdf Normal file
View File

@ -0,0 +1,29 @@
%PDF-2.0
%€<>ƒ
1 0 obj
<</Type/Catalog/Pages 2 0 R>>
endobj
2 0 obj
<</Type/Pages/Kids[3 0 R]/Count 1>>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<<>>/MediaBox[0 0 595.2765 841.89105]/Contents[4 0 R]>>
endobj
4 0 obj
<</Length 36>>
stream
100 100 m 20 w[30 20]0 d 400 300 l S
endstream
endobj
xref
0 5
0000000000 65535 f
0000000015 00000 n
0000000060 00000 n
0000000111 00000 n
0000000217 00000 n
trailer
<</Size 5/Root 1 0 R/ID[<4736f799ac58f6aab465f1cbd5579a19><4736f799ac58f6aab465f1cbd5579a19>]>>
startxref
301
%%EOF