[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginner questions...



On Mon, 26 Sep 2005, Paulo Jorge de Oliveira Cantante de Matos wrote:

> The samples left me breathless however, when I try to create
> some images to my own use I get stuck with questions.
>
Dear Paulo,

Thanks for trying ePiX! Happily, some of your questions have simple
answers, but unfortunately not all of them do (which is my fault).

> Here are some of them:
> 1 - Once I use dashed(); how can I specify that the lines
> should stop being dashed and go back to normal?
>
  solid(); // :)

The style "dotted();" gives dotted lines. Dashed and dotted lines are
definitely a weak point. Originally they were implemented using eepic's
dashed and dotted styles, which also weren't perfect. In 1.0.0, dashed and
dotted lines and drawn in the eepic file as individual dots and dash
segments. The effect usually (in my experience) looks all right, but
bloats the output file, and sometimes just doesn't work.

> 2 - How can I specify a polygon by its vertices, is it possible?
>
First define the vertices as named objects:

  P pt1(0,0), pt2(3,4), pt3(-2,1); // etc...

Then pass the *addresses* of the points to polygon/polyline, and draw:

  path my_poly = polygon(3, &pt1, &pt2, &pt3);
  my_poly.draw();

Clearly this state of affairs leaves room for improvement.

> 3 - How can I shade a region between two lines?
>
For the region between two graphs, there's Jay Belanger's "shadeplot":

  fill(); // fill closed paths
  gray(0.5); // medium gray; default is 0.3
  shadeplot(f, g, a, b, n);
  fill(false); // turn off filling

which shades the region between f and g over the interval [a,b], using n+1
points to graph each function. Otherwise, the best alternative may be to
build the boundary of the filled region as a path. If you have an example
in mind, please email.

> 4 - How can I make a dashed grid. using dashed(), before grid()
> does not work!
>
By default (to save space in the output), grids are drawn with line
segments containing only two vertices, so when dashed, they're broken. :)
Commands such as

  dashed();
  grid(P(0,0), P(1,1), mesh(8,8), mesh(16,16));

should do about what you want. The first "mesh" specifies the number of
grid lines (here 8x8), while the second says how many points per line to
use (16x16, or two dashes per grid square in each direction). These
numbers can be anything, but the result will look best if the "fine" grid
is an integer multiple of the "coarse" grid. If you plan to draw lots of
dashed grids, a wrapper function would be useful, e.g.

---(snip)---
// dashed grid given by lower left/upper right points, number of segments,
// and number of dashes per grid square (default=2); N.B. Untested!
//
void dashgrid(P SW, P NE, int n1, int n2, int N=2)
{
  epix_path_style curr=path_style(); // get current style
  dashed();
  grid(SW, NE, mesh(n1, n2), mesh(n1*N, n2*N));

  switch(curr) { // restore path style
  case DASHED:
    dashed(); break;
  case DOTTED:
    dotted(); break;
  default:
    solid(); break;
}
---(snip)---

Hope that's helpful!

--Andy

Andrew D. Hwang			ahwang@mathcs.holycross.edu
Department of Math and CS	http://math.holycross.edu/~ahwang
College of the Holy Cross	(508) 793-2458 (Office: 320 Swords)
Worcester, MA, 01610-2395	(508) 793-3530 (fax)