Actual source code: ex2.c


  2: static char help[] = "Demonstrates use of color map\n";

  4: #include <petscsys.h>
  5: #include <petscdraw.h>

  7: int main(int argc, char **argv)
  8: {
  9:   PetscDraw   draw;
 10:   PetscMPIInt size, rank;
 11:   int         x = 0, y = 0, width = 256, height = 256, i;

 14:   PetscInitialize(&argc, &argv, NULL, help);
 15:   PetscDrawCreate(PETSC_COMM_WORLD, 0, "Title", x, y, width, height, &draw);
 16:   PetscDrawSetFromOptions(draw);
 17:   MPI_Comm_size(PETSC_COMM_WORLD, &size);
 18:   MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
 19:   for (i = rank; i < height; i += size) {
 20:     PetscReal y = ((PetscReal)i) / (height - 1);
 21:     PetscDrawLine(draw, 0.0, y, 1.0, y, i % 256);
 22:   }
 23:   PetscDrawFlush(draw);
 24:   PetscDrawPause(draw);
 25:   PetscDrawSave(draw);
 26:   PetscDrawDestroy(&draw);
 27:   PetscFinalize();
 28:   return 0;
 29: }

 31: /*TEST

 33:    build:
 34:      requires: x

 36:    test:
 37:      output_file: output/ex1_1.out

 39: TEST*/