Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd.
3
All rights reserved.
4
Copyright (C), 2007-2008, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical ALgorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
/* Data file to test out Gdraw functions */
37
38
#include "Gdraws0.h"
39
#include "../view3D/header.h"
40
#include "noX10.h"
41
42
extern GC gc, gc1;
43
44
int
45
Gdraws_data(int dFlag)
46
{
47
static Vertex vlist[5];
48
static int vcount = 5;
49
static int x0, y0, x1, y1;
50
static const char* str = "This is a text string.";
51
static int x, y;
52
static int FirstTime = yes;
53
static int Rx, Ry, Rwidth, Rheight;
54
static int Ix, Iy;
55
static const char* Istr = "Image text string.";
56
static XPoint points[7];
57
static XPoint p1[7];
58
static int np1 = 7;
59
static int npoints, mode;
60
static int ax, ay, angle1, angle2;
61
static unsigned int awidth, aheight;
62
static Vertex dfvlist[7];
63
static int dfvcount = 7;
64
static XPoint dfvl1[7];
65
static int dfvc = 7;
66
67
if (FirstTime) {
68
69
vlist[0].x = 10;
70
vlist[0].y = 10;
71
vlist[0].flags = 0;
72
73
vlist[1].x = 250;
74
vlist[1].y = 10;
75
vlist[1].flags = 0;
76
77
vlist[2].x = 250;
78
vlist[2].y = 140;
79
vlist[2].flags = 0;
80
81
vlist[3].x = 10;
82
vlist[3].y = 140;
83
vlist[3].flags = 0;
84
85
vlist[4].x = 10;
86
vlist[4].y = 10;
87
vlist[4].flags = 0;
88
89
x0 = y0 = 12;
90
x1 = 248;
91
y1 = 138;
92
93
x = 25;
94
y = 50;
95
96
Ix = 20;
97
Iy = 180;
98
99
Rx = 160;
100
Ry = 40;
101
Rwidth = 30;
102
Rheight = 80;
103
104
points[0].x = 80;
105
points[0].y = 95;
106
points[1].x = 30;
107
points[1].y = 15;
108
points[2].x = 120;
109
points[2].y = 70;
110
points[3].x = 25;
111
points[3].y = 180;
112
points[4].x = 43;
113
points[4].y = 56;
114
points[5].x = 270;
115
points[6].y = 0;
116
points[6].x = 0;
117
points[5].y = 160;
118
119
p1[0].x = 2;
120
p1[0].y = 155;
121
p1[1].x = 99;
122
p1[1].y = 39;
123
p1[2].x = 260;
124
p1[2].y = 75;
125
p1[3].x = 33;
126
p1[3].y = 170;
127
p1[4].x = 4;
128
p1[4].y = 111;
129
p1[5].x = 203;
130
p1[6].y = 33;
131
p1[6].x = 170;
132
p1[5].y = 200;
133
134
npoints = 7;
135
mode = CoordModeOrigin; /* there's also CoordModePrevious */
136
137
ax = 130;
138
ay = 100;
139
awidth = 165;
140
aheight = 95;
141
angle1 = 165;
142
angle2 = -330;
143
144
dfvlist[0].x = 300;
145
dfvlist[0].y = 0;
146
dfvlist[0].flags = 0;
147
148
dfvlist[1].x = 200;
149
dfvlist[1].y = 0;
150
dfvlist[1].flags = 0;
151
152
dfvlist[2].x = 200;
153
dfvlist[2].y = 100;
154
dfvlist[2].flags = 0;
155
156
dfvlist[3].x = 100;
157
dfvlist[3].y = 100;
158
dfvlist[3].flags = 0;
159
160
dfvlist[4].x = 100;
161
dfvlist[4].y = 200;
162
dfvlist[4].flags = 0;
163
164
dfvlist[5].x = 0;
165
dfvlist[5].y = 200;
166
dfvlist[5].flags = 0;
167
168
dfvlist[6].x = 300;
169
dfvlist[6].y = 0;
170
dfvlist[6].flags = 0;
171
172
dfvl1[0].x = 0;
173
dfvl1[0].y = 300;
174
dfvl1[1].x = 0;
175
dfvl1[1].y = 200;
176
dfvl1[2].x = 100;
177
dfvl1[2].y = 200;
178
dfvl1[3].x = 100;
179
dfvl1[3].y = 100;
180
dfvl1[4].x = 200;
181
dfvl1[4].y = 100;
182
dfvl1[5].x = 200;
183
dfvl1[5].y = 0;
184
dfvl1[6].x = 0;
185
dfvl1[6].y = 300;
186
187
FirstTime = no;
188
}
189
190
if (dFlag == PS) {
191
GSetForeground(gc1, 0.3125, PS);
192
if (PSFillwOutline(gc1, dfvl1, dfvc) == psError)
193
return (psError);
194
}
195
196
if (GDrawString(gc, viewport->viewWindow, x, y, str, strlen(str), dFlag)
197
== psError)
198
return (psError);
199
200
201
if (GDrawLine(gc, viewport->viewWindow, x0, y0, x1, y1, dFlag) == psError)
202
return (psError);
203
204
if (GDrawRectangle(gc, viewport->viewWindow, Rx, Ry, Rwidth, Rheight, dFlag)
205
== psError)
206
return (psError);
207
208
if (GDrawLines(gc, viewport->viewWindow, points, npoints, mode, dFlag)
209
== psError)
210
return (psError);
211
212
if (GDrawArc(gc, viewport->viewWindow, ax, ay, awidth, aheight, angle1 * 64,
213
angle2 * 64, dFlag) == psError)
214
return (psError);
215
216
GSetForeground(gc1, (float) psBlack, dFlag);
217
GSetBackground(gc1, (float) psWhite, dFlag);
218
if (GFillArc(gc1, viewport->viewWindow, 20, ay - 20, awidth / 2, aheight / 2,
219
angle1 * 64, angle2 * 64, dFlag) == psError)
220
return (psError);
221
222
223
GSetForeground(gc1, (float) psWhite, dFlag);
224
GSetBackground(gc1, (float) psBlack, dFlag);
225
if (GDrawImageString(gc1, viewport->viewWindow, Ix, Iy,
226
Istr, strlen(Istr), dFlag) == psError)
227
return (psError);
228
229
if (dFlag == PS) {
230
GSetForeground(gc1, 0.8, dFlag);
231
PSFillPolygon(gc1, p1, np1);
232
PSColorPolygon(0.2, 0.4, 0.8, p1, np1);
233
}
234
235
return (1);
236
}
237
238