Actual source code: ex1.c
petsc-3.7.3 2016-08-01
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,NULL,help);
17: PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw);
18: PetscDrawSetPause(draw,2.0);
19: PetscDrawSetFromOptions(draw);
20: PetscDrawSetViewPort(draw,.25,.25,.75,.75);
22: PetscDrawLine(draw,0.0,0.0,1.0,1.0,PETSC_DRAW_BLACK);
23: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text");
24: PetscDrawString(draw,.5,.5,PETSC_DRAW_GREEN,"Some Text");
25: PetscDrawString(draw,.2,.8,PETSC_DRAW_BLUE,"Some Text");
26: PetscDrawFlush(draw);
27: PetscDrawPause(draw);
28: PetscDrawSave(draw);
30: PetscDrawClear(draw);
31: /*PetscDrawStringSetSize(draw,.5,.5);*/
32: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text");
33: PetscDrawString(draw,.5,.5,PETSC_DRAW_GREEN,"Some Text");
34: PetscDrawString(draw,.2,.8,PETSC_DRAW_BLUE,"Some Text");
35: PetscDrawFlush(draw);
36: PetscDrawPause(draw);
37: PetscDrawSave(draw);
39: PetscDrawResizeWindow(draw,600,600);
40: PetscDrawGetWindowSize(draw,&width,&height);
41: PetscDrawSetViewPort(draw,0,0,1,1);
42: PetscDrawClear(draw);
43: /*PetscDrawLine(draw,0.0,0.0,1.0,1.0,PETSC_DRAW_RED);*/
44: /*PetscDrawLine(draw,0.0,1.0,1.0,0.0,PETSC_DRAW_BLUE);*/
45: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text\n Some Other Text");
46: PetscDrawString(draw,.5,.5,PETSC_DRAW_RED,"ABCygj\n()[]F$");
47: PetscDrawString(draw,0,0,PETSC_DRAW_RED,"Horizontal Text (ABCygj)");
48: PetscDrawStringVertical(draw,0,1,PETSC_DRAW_RED,"Vertical Text");
49: PetscDrawFlush(draw);
50: PetscDrawPause(draw);
51: PetscDrawSave(draw);
53: PetscDrawDestroy(&draw);
54: PetscFinalize();
55: return 0;
56: }