xref: /petsc/src/sys/classes/draw/tests/ex2.c (revision b122ec5aa1bd4469eb4e0673542fb7de3f411254)
1 
2 static char help[] = "Demonstrates use of color map\n";
3 
4 #include <petscsys.h>
5 #include <petscdraw.h>
6 
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;
12 
13   CHKERRQ(PetscInitialize(&argc,&argv,NULL,help));
14   CHKERRQ(PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw));
15   CHKERRQ(PetscDrawSetFromOptions(draw));
16   CHKERRMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size));
17   CHKERRMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank));
18   for (i=rank; i<height; i+=size) {
19     PetscReal y = ((PetscReal)i)/(height-1);
20     CHKERRQ(PetscDrawLine(draw,0.0,y,1.0,y,i%256));
21   }
22   CHKERRQ(PetscDrawFlush(draw));
23   CHKERRQ(PetscDrawPause(draw));
24   CHKERRQ(PetscDrawSave(draw));
25   CHKERRQ(PetscDrawDestroy(&draw));
26   CHKERRQ(PetscFinalize());
27   return 0;
28 }
29 
30 /*TEST
31 
32    build:
33      requires: x
34 
35    test:
36      output_file: output/ex1_1.out
37 
38 TEST*/
39