\documentclass{article}
\title{PSTricks Crash Course}
\author{Matt Wright}
\date{Feb 2015}
\usepackage{pstricks,pst-plot}
\begin{document}
\maketitle

\section{What is PSTricks?}
\begin{flushleft}
PSTricks is package that was created by Timothy Van Zandt as a means to easily insert custom diagrams and images into a LaTex document. Just like in LaTex, it is very easy to build up several lines of code to create very complex images.  In order to use PSTricks in a document, first you must add the PSTricks package to the document preamble. For this document, we will be using the standard 'pstricks' package as well as a graphing package, 'pst-plot'  Thus, our preamble should be as follows:\\
\vline 

\begin{verbatim}
\documentclass{article}
\usepackage{pstricks,pst-plot}
\begin{document}
\end{verbatim}

Anytime you wish to insert a diagram, you must first enter the PSTricks environment:
\begin{verbatim}
\begin{pspicture}(6,6)
\end{pspicture}
\end{verbatim}
The coordinate (6,6) indicates your diagram will occupy a 6x6 coordinate grid

\section{Basic Lines and Shapes}
For example, a single line can be drawn or a series of lines can be used to create various shapes.  This is done by using the 'psline' command followed by the coordinates that the line should follow.

\begin{verbatim}
\begin{pspicture}(6,6)
\psline(0,0)(0,6)(6,6)(6,0)(0,0)
\psline(2,2)(4,2)(4,4)(2,4)(2,2)
\end{pspicture}
\end{verbatim}

\end{flushleft}
\begin{center}
\begin{pspicture}(6,6)
\psline(0,0)(0,6)(6,6)(6,0)(0,0)
\psline(2,2)(4,2)(4,4)(2,4)(2,2)
\end{pspicture}
\end{center}

\begin{flushleft}
Circles and arcs can also be drawn using the 'pscircle' and 'psarc' commands respectively.

\begin{verbatim}
\begin{pspicture}(6,6)
\psline(0,0)(0,6)(6,6)(6,0)(0,0)
\psline(2,2)(4,2)(4,4)(2,4)(2,2)
\pscircle(3,3){0.5}
\pscircle(3,3){1.5}
\pscircle(3,3){2.5}
\psarc(3,3){2}{0}{90}
\psarc(3,3){2}{180}{270}
\psarc(3,3){3}{0}{60}
\psarc(3,3){3}{120}{180}
\psarc(3,3){3}{240}{300}
\end{pspicture}
\end{verbatim}


\end{flushleft}
\begin{center}
\begin{pspicture}(6,6)
\psline(0,0)(0,6)(6,6)(6,0)(0,0)
\psline(2,2)(4,2)(4,4)(2,4)(2,2)
\pscircle(3,3){0.5}
\pscircle(3,3){1.5}
\pscircle(3,3){2.5}
\psarc(3,3){2}{0}{90}
\psarc(3,3){2}{180}{270}
\psarc(3,3){3}{0}{60}
\psarc(3,3){3}{120}{180}
\psarc(3,3){3}{240}{300}
\end{pspicture}
\end{center}
\begin{flushleft}


Colors, fill, and line types can be controlled as well using modifiers placed in [brackets] after the command:

\begin{verbatim}
\begin{pspicture}(6,6)
\psset{unit=1}
\psline[linewidth=4pt](0,0)(0,6)(6,6)(6,0)(0,0)
\pscircle[linestyle=dashed,fillstyle=vlines](3,3){1.5}
\psline[fillstyle=solid,fillcolor=white](2,2)(4,2)(4,4)(2,4)(2,2)
\pscircle[fillstyle=solid,fillcolor=blue](3,3){0.5}
\pscircle[linestyle=dotted,linewidth=3pt](3,3){2.5}
\psarc[linecolor=green,linewidth=2pt](3,3){2}{0}{90}
\psarc[linecolor=green,linewidth=2pt](3,3){2}{180}{270}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{0}{60}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{120}{180}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{240}{300}
\end{pspicture}
\end{verbatim}
\end{flushleft}

\begin{center}
\begin{pspicture}(6,6)
\psset{unit=1}
\psline[linewidth=4pt](0,0)(0,6)(6,6)(6,0)(0,0)
\pscircle[linestyle=dashed,fillstyle=vlines](3,3){1.5}
\psline[fillstyle=solid,fillcolor=white](2,2)(4,2)(4,4)(2,4)(2,2)
\pscircle[fillstyle=solid,fillcolor=blue](3,3){0.5}
\pscircle[linestyle=dotted,linewidth=3pt](3,3){2.5}
\psarc[linecolor=green,linewidth=2pt](3,3){2}{0}{90}
\psarc[linecolor=green,linewidth=2pt](3,3){2}{180}{270}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{0}{60}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{120}{180}
\psarc[linecolor=yellow,linewidth=4pt](3,3){3}{240}{300}
\end{pspicture}
\end{center}
\begin{flushleft}
Which objects are on top is determined by the order of the code. Objects in the background should be placed in the beginning, while objects on top should be placed at the end.
\end{flushleft}
\newpage

\section{Graphing}
\begin{flushleft}
PSTricks can also be used to create graphs.  Inserting 'psgrid' will create a gridded background to any image. In combination with other commands, simple graphs can be made.

\begin{verbatim}
\begin{pspicture}(7,6)
\psgrid
\rput(-1,3.7){Distance (m)}
\rput(3.5,6.3){Distance vs. Time Graph}
\rput(3.5,-0.6){Time (s)}
\psline[linecolor=red](0,0)(7,5)
\psline[fillstyle=solid,fillcolor=yellow](1,3)(1,4)
(3.6,4)(3.6,3)(1,3)
\rput(2.2,3.5){Slope= $\frac{5}{7}$}
\end{pspicture}
\end{verbatim}
\end{flushleft}
\vline
\begin{center}
\begin{pspicture}(7,6)
\psgrid
\rput(-1,3.7){Distance (m)}
\rput(3.5,6.3){Distance vs. Time Graph}
\rput(3.5,-0.6){Time (s)}
\psline[linecolor=red](0,0)(7,5)
\psline[fillstyle=solid,fillcolor=yellow](1,3)(1,4)(3.6,4)(3.6,3)(1,3)
\rput(2.2,3.5){Slope= $\frac{5}{7}$}
\end{pspicture}
\end{center}
\vline\\
\vline\\
In addition to manually creating graphs, PSTricks can also plot functions with help from the pst-plot package we added.  This requires use of the 'psplot' command. It is important to realize that all functions must be entered in RPN.  The 'RadtoDeg' function converts sin from Radians to Degrees.
\begin{verbatim}
\begin{pspicture}(7,7)
\psplot{0}{7}{x RadtoDeg sin}
\end{pspicture}
\end{verbatim}

\begin{center}
\begin{pspicture}(0,-1.5)(6,2)
\psplot{0}{7}{x RadtoDeg sin}
\end{pspicture}
\end{center}


\begin{flushleft}
Notice, it only graphs the function and nothing else.  We must use additional commands to describe everything else.
\end{flushleft}
\begin{verbatim}
\begin{pspicture}(5,5)
\psaxes{->}(0,0)(0,-2)(7,2)
\psplot{0}{7}{x RadtoDeg sin}
\end{pspicture}
\end{verbatim}


\begin{center}
\begin{pspicture}(0,-2)(6,2)
\psaxes{->}(0,0)(0,-2)(7,2)
\psplot{0}{7}{x RadtoDeg sin}
\end{pspicture}
\end{center}
\begin{flushleft}
Several functions can be graphed at once by adding additional 'psplot' commands.  Color and style can also be changed using previous commands.
\end{flushleft}
\begin{verbatim}
\begin{pspicture}(0,-2)(6,2)
\psaxes{->}(0,0)(0,-2)(7,2)
\psplot[linecolor=red,linewidth=1.5pt]{0}{7}{x RadtoDeg sin}
\psplot[linecolor=green,linewidth=1.5pt]{0}{7}{x RadtoDeg cos}
\rput(2.1,1.3){Sin Curve}
\rput(6.5,1.3){Cos Curve}
\end{pspicture}
\end{verbatim}


\begin{center}
\begin{pspicture}(0,-2)(6,2)
\psaxes{->}(0,0)(0,-2)(7,2)
\psplot[linecolor=red,linewidth=1.5pt]{0}{7}{x RadtoDeg sin}
\psplot[linecolor=green,linewidth=1.5pt]{0}{7}{x RadtoDeg cos}
\rput(2.1,1.3){Sin Curve}
\rput(6.5,1.3){Cos Curve}
\end{pspicture}
\end{center}





























\end{document}