xref: /petsc/src/sys/classes/draw/tests/ex2.c (revision 8fb5bd83c3955fefcf33a54e3bb66920a9fa884b)
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   PetscCall(PetscInitialize(&argc,&argv,NULL,help));
14   PetscCall(PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw));
15   PetscCall(PetscDrawSetFromOptions(draw));
16   PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size));
17   PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank));
18   for (i=rank; i<height; i+=size) {
19     PetscReal y = ((PetscReal)i)/(height-1);
20     PetscCall(PetscDrawLine(draw,0.0,y,1.0,y,i%256));
21   }
22   PetscCall(PetscDrawFlush(draw));
23   PetscCall(PetscDrawPause(draw));
24   PetscCall(PetscDrawSave(draw));
25   PetscCall(PetscDrawDestroy(&draw));
26   PetscCall(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