Showing posts with label \pscircle. Show all posts
Showing posts with label \pscircle. Show all posts

Friday, November 30, 2012

Deal with repetitive work in pstricks efficiently (2) --- multido

Last time we talked about doing repetitive work in postricks using command "\multirput", and this time "\multido" will be introduced. "\multido" is a much more general loop macro than "\multirput". You can use it like this "\multido {\loop_indication = start_value + increment} {loop_nums} {loop_content}", very simillar to loop in programming language. Some examples are shown below.

\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}

\begin{document}
  \begin{pspicture}*(-0.5,0.5)(5.5,5.5)
    \multido{\ix=0+1}{6}
    {
      \multido{\iy=0+1}{6}
      {
        \rput(\ix,\iy){(\ix,\iy)}
      }
    }
  \end{pspicture}
\end{document}

Fig.1 Deal with repetitive work in efficiently (2) --- multido

Files Download: tex ps pdf

\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}

\begin{document}
  \begin{pspicture}(2,2)
    \pscircle*[linecolor=yellow](1,1){0.707}
    \psset{linecolor=red}
    \multido{\ix=0+15}{24}
    {
      \rput{\ix}(1,1){\psline(0.5,0.5)(1,1)}
    }
  \end{pspicture}
\end{document}

Fig.2 Deal with repetitive work in efficiently (2) --- multido

Files Download: tex ps pdf

Sunday, December 4, 2011

Some basic graph objects in pstricks (3) ---- Circles,Arc,Wedge,Ellipses,Elliptic Arc,Rectangle and so on

"\pscircle[parameters](x0,y0){r}" draws a circle whose center is located at (x0,y0) and that has radius r.

"\pswedge[parameters](x0,y0){r}{ang1}{ang2}" draws a wedge whose center is located at (x0,y0), that has radius r and extened counterclockwise from ang1 to ang2.

"\psarc[parameters]{arrowstyle}(x,y){r}{angA}{angB}" clockwisely draws an arc form angA to angB. (x,y) and r are the center and radius of the circle ( a arc curve is always a part of a circle).

"\psellipse[parameters](x0,y0)(h_r,v_r)" draws a ellipse. (x0,y0) is the center, h_r is the horizontal radius and v_r is the vertical radius.

"\psellipticarc[par]{arrow}(x0,y0)(x1,y1){angA}{angB}" which is very similar to "\psarc" draws an elliptic.

"\psframe[parameters](x0,y0)(x1,y1)" draws a rectangle with lower left corner at (xo,y0), upper right corner at (x1,y1).

There are also command like "\pstriangle","\psdiamond" to draw triangle and diamond. But we can use "\pspolygon" to realize the utility of all these commands. So we will not talk about them here.

For all these commands a star can be followed (for example, "\pscircle*"). This determine the fill the object.

Now let we have a practice on these commands.


\documentclass{article}
\usepackage{pstricks}
\begin{document}
  \begin{pspicture}(-2.5,2.5)(2.5,2.5)
    \psframe[linestyle=none,framearc=0.25,%
      fillstyle=solid,fillcolor=green]
      (-2.5,-2.5)(2.5,2.5)
    \pscircle[linecolor=red](0,0){2.5}
    \pswedge[fillstyle=solid,
      fillcolor=red](0,0){2.5}{0}{45}
    \psarc{->}(0,0){1.5}{0}{45} %draw arc
    \uput{1.5}[22.5]
      (0,0){$45^{\circ}$} %put a label
    \psellipse(0,-1.25)(2.5,1.25)
  \end{pspicture}
\end{document}

This practice draw something like this:

Fig.1 Draw circle,arc,ellipse,rectangle... uisng Pstricks
 Files download: tex ps pdf
Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.