OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [demos/] [nanox/] [polytest.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#include <stdio.h>
2
#include "nano-X.h"
3
 
4
void draw(GR_EVENT * e)
5
{
6
  GR_GC_ID      gc;
7
  GR_POINT      points[4];
8
 
9
  int x = 10;
10
  int y = 10;
11
  int sz = 20;
12
  int sz2 = 5;
13
 
14
  gc = GrNewGC();
15
 
16
  GrSetGCBackground(gc, GR_RGB(0,0,0));
17
  //GrSetGCMode(gc, GR_MODE_XOR);
18
 
19
  points[0].x = x;
20
  points[0].y = y;
21
 
22
  points[1].x = x + sz;
23
  points[1].y = y;
24
 
25
  points[2].x = x + (sz/2) ;
26
  points[2].y = y + sz;
27
 
28
  GrSetGCForeground(gc, GR_RGB(255,255,255));
29
  GrFillPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,3,points);
30
  points[3].x = x;
31
  points[3].y = y;
32
  GrSetGCForeground(gc,GR_RGB(0,255,0));
33
  GrPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,4,points);
34
 
35
  y += sz + 10;
36
 
37
  points[0].x = x;
38
  points[0].y = y;
39
 
40
  points[1].x = x + sz + 1;
41
  points[1].y = y;
42
 
43
  points[2].x = x + (sz/2) ;
44
  points[2].y = y + sz;
45
 
46
  GrSetGCForeground(gc, GR_RGB(255,255,255));
47
  GrFillPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,3,points);
48
  points[3].x = x;
49
  points[3].y = y;
50
  GrSetGCForeground(gc,GR_RGB(0,255,0));
51
  GrPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,4,points);
52
 
53
  y += sz + 10;
54
 
55
  points[0].x = x;
56
  points[0].y = y;
57
 
58
  points[1].x = x + sz - 1;
59
  points[1].y = y;
60
 
61
  points[2].x = x + (sz/2) ;
62
  points[2].y = y + sz;
63
 
64
  GrSetGCForeground(gc, GR_RGB(255,255,255));
65
  GrFillPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,3,points);
66
  points[3].x = x;
67
  points[3].y = y;
68
  GrSetGCForeground(gc,GR_RGB(0,255,0));
69
  GrPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,4,points);
70
 
71
  /* draw right arrow*/
72
  sz = 10;
73
  sz2 = 8;
74
 
75
  x = 60;
76
  y = 60;
77
 
78
  points[0].x = x;
79
  points[0].y = y;
80
 
81
  y -= sz;
82
 
83
  points[1].x = x + sz2;
84
  points[1].y = y;
85
 
86
  y -= sz;
87
 
88
  points[2].x = x;
89
  points[2].y = y;
90
 
91
  GrSetGCForeground(gc, GR_RGB(255,255,255));
92
  GrFillPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,3,points);
93
 
94
  points[3].x = x;
95
  points[3].y = 60;
96
 
97
  GrSetGCForeground(gc,GR_RGB(0,255,0));
98
  GrPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,4,points);
99
 
100
  GrSetGCForeground(gc,GR_RGB(255,255,255));
101
 
102
  x = 60;
103
  y = 90;
104
 
105
  points[0].x = x;
106
  points[0].y = y;
107
 
108
  y -= sz;
109
 
110
  points[1].x = x + sz2;
111
  points[1].y = y;
112
 
113
  y -= sz;
114
 
115
  points[2].x = x;
116
  points[2].y = y;
117
 
118
  GrSetGCForeground(gc, GR_RGB(255,255,255));
119
  GrFillPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,3,points);
120
  points[3].x = x;
121
  points[3].y = 90;
122
  //GrPoly(((GR_EVENT_EXPOSURE*)e)->wid,gc,4,points);
123
 
124
  GrDestroyGC(gc);
125
}
126
 
127
main()
128
{
129
  GR_EVENT      event;
130
  GR_WINDOW_ID  w;
131
 
132
  if (GrOpen() < 0) {
133
    fprintf(stderr, "cannot open graphics\n");
134
    exit(1);
135
  }
136
 
137
  /* create window*/
138
  w = GrNewWindowEx(
139
                     GR_WM_PROPS_NOAUTOMOVE|GR_WM_PROPS_BORDER|GR_WM_PROPS_CAPTION|
140
                     GR_WM_PROPS_CLOSEBOX, "POLY FILL", GR_ROOT_WINDOW_ID,
141
                     10, 10, 100, 300, GR_RGB(0,0,0));
142
  //  w = GrNewWindow(0,100,100,100,100,3,GR_RGB(0,0,255),GR_RGB(0,0,0));
143
 
144
  GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ);
145
  GrMapWindow(w);
146
 
147
  while (1) {
148
    GrGetNextEvent(&event);
149
 
150
    switch (event.type) {
151
    case GR_EVENT_TYPE_EXPOSURE:
152
      draw(&event);
153
      break;
154
    case GR_EVENT_TYPE_CLOSE_REQ:
155
      GrClose();
156
      exit(0);
157
    }
158
  }
159
 
160
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.