Actual source code: ex1.c

petsc-3.6.1 2015-08-06
Report Typos and Errors
  2: static char help[] = "Demonstrates opening and drawing in a window\n";

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

  9: int main(int argc,char **argv)
 10: {
 11:   PetscDraw      draw;
 13:   int            x = 0,y = 0,width = 300,height = 300;

 15:   PetscInitialize(&argc,&argv,(char*)0,help);

 17:   PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw);
 18:   PetscDrawSetFromOptions(draw);
 19:   PetscDrawSetViewPort(draw,.25,.25,.75,.75);
 20:   PetscDrawLine(draw,0.0,0.0,1.0,1.0,PETSC_DRAW_BLACK);
 21:   PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text");
 22:   /*  PetscDrawStringSetSize(draw,.5,.5); */
 23:   PetscDrawString(draw,.2,.2,PETSC_DRAW_BLUE,"Some Text");
 24:   PetscDrawFlush(draw);
 25:   PetscSleep(2);
 26:   PetscDrawClear(draw);
 27:   PetscDrawFlush(draw);
 28:   PetscDrawResizeWindow(draw,600,600);
 29:   PetscSleep(2);
 30:   PetscDrawLine(draw,0.0,1.0,1.0,0.0,PETSC_DRAW_BLUE);
 31:   PetscDrawFlush(draw);
 32:   PetscSleep(2);
 33:   PetscDrawDestroy(&draw);
 34:   PetscFinalize();
 35:   return 0;
 36: }