Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
1
/* Copyright (C) 2000 The PARI group.
2
3
This file is part of the PARI/GP package.
4
5
PARI/GP is free software; you can redistribute it and/or modify it under the
6
terms of the GNU General Public License as published by the Free Software
7
Foundation; either version 2 of the License, or (at your option) any later
8
version. It is distributed in the hope that it will be useful, but WITHOUT
9
ANY WARRANTY WHATSOEVER.
10
11
Check the License for details. You should have received a copy of it, along
12
with the package; see the file 'COPYING'. If not, write to the Free Software
13
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
14
15
BEGINEXTERN
16
typedef struct dblPointList{
17
double *d; /* data */
18
long nb; /* number of elements */
19
double xsml,xbig,ysml,ybig; /* extrema */
20
} dblPointList;
21
22
typedef struct RectObj {
23
struct RectObj *next;
24
long code,color;
25
} RectObj;
26
27
typedef struct PariRect {
28
RectObj *head,*tail;
29
long sizex,sizey;
30
double cursorx,cursory;
31
double xscale,yscale;
32
double xshift,yshift;
33
} PariRect;
34
35
/* The structures below are "subclasses" of RectObj. */
36
37
typedef struct RectObj1P {
38
struct RectObj *next;
39
long code,color;
40
double x,y;
41
} RectObj1P;
42
43
typedef struct RectObj2P {
44
struct RectObj *next;
45
long code,color;
46
double x1,y1;
47
double x2,y2;
48
} RectObj2P;
49
50
typedef struct RectObjMP {
51
struct RectObj *next;
52
long code,color;
53
long count;
54
double *xs,*ys;
55
} RectObjMP;
56
57
typedef struct RectObjST {
58
struct RectObj *next;
59
long code,color;
60
long length;
61
char *s;
62
double x,y;
63
long dir;
64
} RectObjST;
65
66
typedef struct RectObjPN {
67
struct RectObj *next;
68
long code,color;
69
long pen;
70
} RectObjPN;
71
72
typedef struct RectObjPS {
73
struct RectObj *next;
74
long code,color;
75
double size;
76
} RectObjPS;
77
78
struct plot_points { long x, y; };
79
struct plot_eng {
80
PARI_plot *pl;
81
void *data;
82
void (*sc)(void *data, long col);
83
void (*pt)(void *data, long x, long y);
84
void (*ln)(void *data, long x1, long y1, long x2, long y2);
85
void (*bx)(void *data, long x, long y, long w, long h);
86
void (*fb)(void *data, long x, long y, long w, long h);
87
void (*mp)(void *data, long n, struct plot_points *points);
88
void (*ml)(void *data, long n, struct plot_points *points);
89
void (*st)(void *data, long x, long y, char *s, long l);
90
};
91
92
/* Pointer conversion. */
93
#define RoMV(rop) ((RectObj1P*)rop)
94
#define RoPT(rop) ((RectObj1P*)rop)
95
#define RoLN(rop) ((RectObj2P*)rop)
96
#define RoBX(rop) ((RectObj2P*)rop)
97
#define RoMP(rop) ((RectObjMP*)rop)
98
#define RoML(rop) ((RectObjMP*)rop)
99
#define RoST(rop) ((RectObjST*)rop)
100
#define RoPTT(rop) ((RectObjPN*)rop)
101
#define RoPTS(rop) ((RectObjPS*)rop)
102
#define RoLNT(rop) ((RectObjPN*)rop)
103
104
/* All the access to the rectangle data go via these macros! */
105
#define RHead(rp) ((rp)->head)
106
#define RTail(rp) ((rp)->tail)
107
#define RXsize(rp) ((rp)->sizex)
108
#define RYsize(rp) ((rp)->sizey)
109
#define RXcursor(rp) ((rp)->cursorx)
110
#define RYcursor(rp) ((rp)->cursory)
111
#define RXshift(rp) ((rp)->xshift)
112
#define RYshift(rp) ((rp)->yshift)
113
#define RXscale(rp) ((rp)->xscale)
114
#define RYscale(rp) ((rp)->yscale)
115
116
#define RoNext(rop) ((rop)->next)
117
#define RoType(rop) ((rop)->code)
118
#define RoCol(rop) ((rop)->color)
119
#define RoMVx(rop) (RoMV(rop)->x)
120
#define RoMVy(rop) (RoMV(rop)->y)
121
#define RoPTx(rop) (RoPT(rop)->x)
122
#define RoPTy(rop) (RoPT(rop)->y)
123
#define RoLNx1(rop) (RoLN(rop)->x1)
124
#define RoLNy1(rop) (RoLN(rop)->y1)
125
#define RoLNx2(rop) (RoLN(rop)->x2)
126
#define RoLNy2(rop) (RoLN(rop)->y2)
127
#define RoBXx1(rop) (RoBX(rop)->x1)
128
#define RoBXy1(rop) (RoBX(rop)->y1)
129
#define RoBXx2(rop) (RoBX(rop)->x2)
130
#define RoBXy2(rop) (RoBX(rop)->y2)
131
132
#define RoMPcnt(rop) (RoMP(rop)->count)
133
#define RoMPxs(rop) (RoMP(rop)->xs)
134
#define RoMPys(rop) (RoMP(rop)->ys)
135
136
#define RoMLcnt(rop) (RoML(rop)->count)
137
#define RoMLxs(rop) (RoML(rop)->xs)
138
#define RoMLys(rop) (RoML(rop)->ys)
139
140
#define RoSTs(rop) (RoST(rop)->s)
141
#define RoSTl(rop) (RoST(rop)->length)
142
#define RoSTx(rop) (RoST(rop)->x)
143
#define RoSTy(rop) (RoST(rop)->y)
144
#define RoSTdir(rop) (RoST(rop)->dir)
145
146
#define RoPTTpen(rop) (RoPTT(rop)->pen)
147
#define RoLNTpen(rop) (RoLNT(rop)->pen)
148
#define RoPTSsize(rop) (RoPTS(rop)->size)
149
150
void gen_draw(struct plot_eng *eng, GEN w, GEN x, GEN y, double xs, double ys);
151
void gp_get_plot(PARI_plot *T);
152
153
#define gp_get_ploth_default_sizes(S) \
154
{ PARI_plot *_T = (PARI_plot *)S; \
155
GEN D = GP_DATA->plothsizes; \
156
if (D) switch(lg(D)) { \
157
case 5: if (D[4]) _T->vunit = D[4]; \
158
case 4: if (D[3]) _T->hunit = D[3]; \
159
case 3: if (D[2]) _T->height = D[2]; \
160
case 2: if (D[1]) _T->width = D[1]; \
161
} \
162
}
163
164
#define gp_get_plot_generic(S,gp_get_display_sizes) \
165
{ PARI_plot *_T = (PARI_plot *)S; \
166
gp_get_display_sizes(&_T->dwidth, &_T->dheight, &_T->fwidth, &_T->fheight);\
167
_T->width = _T->dwidth? _T->dwidth*4/5: 640; \
168
_T->height= _T->dheight?_T->dheight*4/5: 480; \
169
_T->hunit = maxss(_T->height/100,3); \
170
_T->vunit = maxss(_T->height/100,3); \
171
gp_get_ploth_default_sizes(S); \
172
}
173
174
ENDEXTERN
175
176