Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
/* Copyright (C) 2000 The PARI group.12This file is part of the PARI/GP package.34PARI/GP is free software; you can redistribute it and/or modify it under the5terms of the GNU General Public License as published by the Free Software6Foundation; either version 2 of the License, or (at your option) any later7version. It is distributed in the hope that it will be useful, but WITHOUT8ANY WARRANTY WHATSOEVER.910Check the License for details. You should have received a copy of it, along11with the package; see the file 'COPYING'. If not, write to the Free Software12Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */1314BEGINEXTERN15typedef struct dblPointList{16double *d; /* data */17long nb; /* number of elements */18double xsml,xbig,ysml,ybig; /* extrema */19} dblPointList;2021typedef struct RectObj {22struct RectObj *next;23long code,color;24} RectObj;2526typedef struct PariRect {27RectObj *head,*tail;28long sizex,sizey;29double cursorx,cursory;30double xscale,yscale;31double xshift,yshift;32} PariRect;3334/* The structures below are "subclasses" of RectObj. */3536typedef struct RectObj1P {37struct RectObj *next;38long code,color;39double x,y;40} RectObj1P;4142typedef struct RectObj2P {43struct RectObj *next;44long code,color;45double x1,y1;46double x2,y2;47} RectObj2P;4849typedef struct RectObjMP {50struct RectObj *next;51long code,color;52long count;53double *xs,*ys;54} RectObjMP;5556typedef struct RectObjST {57struct RectObj *next;58long code,color;59long length;60char *s;61double x,y;62long dir;63} RectObjST;6465typedef struct RectObjPN {66struct RectObj *next;67long code,color;68long pen;69} RectObjPN;7071typedef struct RectObjPS {72struct RectObj *next;73long code,color;74double size;75} RectObjPS;7677struct plot_points { long x, y; };78struct plot_eng {79PARI_plot *pl;80void *data;81void (*sc)(void *data, long col);82void (*pt)(void *data, long x, long y);83void (*ln)(void *data, long x1, long y1, long x2, long y2);84void (*bx)(void *data, long x, long y, long w, long h);85void (*fb)(void *data, long x, long y, long w, long h);86void (*mp)(void *data, long n, struct plot_points *points);87void (*ml)(void *data, long n, struct plot_points *points);88void (*st)(void *data, long x, long y, char *s, long l);89};9091/* Pointer conversion. */92#define RoMV(rop) ((RectObj1P*)rop)93#define RoPT(rop) ((RectObj1P*)rop)94#define RoLN(rop) ((RectObj2P*)rop)95#define RoBX(rop) ((RectObj2P*)rop)96#define RoMP(rop) ((RectObjMP*)rop)97#define RoML(rop) ((RectObjMP*)rop)98#define RoST(rop) ((RectObjST*)rop)99#define RoPTT(rop) ((RectObjPN*)rop)100#define RoPTS(rop) ((RectObjPS*)rop)101#define RoLNT(rop) ((RectObjPN*)rop)102103/* All the access to the rectangle data go via these macros! */104#define RHead(rp) ((rp)->head)105#define RTail(rp) ((rp)->tail)106#define RXsize(rp) ((rp)->sizex)107#define RYsize(rp) ((rp)->sizey)108#define RXcursor(rp) ((rp)->cursorx)109#define RYcursor(rp) ((rp)->cursory)110#define RXshift(rp) ((rp)->xshift)111#define RYshift(rp) ((rp)->yshift)112#define RXscale(rp) ((rp)->xscale)113#define RYscale(rp) ((rp)->yscale)114115#define RoNext(rop) ((rop)->next)116#define RoType(rop) ((rop)->code)117#define RoCol(rop) ((rop)->color)118#define RoMVx(rop) (RoMV(rop)->x)119#define RoMVy(rop) (RoMV(rop)->y)120#define RoPTx(rop) (RoPT(rop)->x)121#define RoPTy(rop) (RoPT(rop)->y)122#define RoLNx1(rop) (RoLN(rop)->x1)123#define RoLNy1(rop) (RoLN(rop)->y1)124#define RoLNx2(rop) (RoLN(rop)->x2)125#define RoLNy2(rop) (RoLN(rop)->y2)126#define RoBXx1(rop) (RoBX(rop)->x1)127#define RoBXy1(rop) (RoBX(rop)->y1)128#define RoBXx2(rop) (RoBX(rop)->x2)129#define RoBXy2(rop) (RoBX(rop)->y2)130131#define RoMPcnt(rop) (RoMP(rop)->count)132#define RoMPxs(rop) (RoMP(rop)->xs)133#define RoMPys(rop) (RoMP(rop)->ys)134135#define RoMLcnt(rop) (RoML(rop)->count)136#define RoMLxs(rop) (RoML(rop)->xs)137#define RoMLys(rop) (RoML(rop)->ys)138139#define RoSTs(rop) (RoST(rop)->s)140#define RoSTl(rop) (RoST(rop)->length)141#define RoSTx(rop) (RoST(rop)->x)142#define RoSTy(rop) (RoST(rop)->y)143#define RoSTdir(rop) (RoST(rop)->dir)144145#define RoPTTpen(rop) (RoPTT(rop)->pen)146#define RoLNTpen(rop) (RoLNT(rop)->pen)147#define RoPTSsize(rop) (RoPTS(rop)->size)148149void gen_draw(struct plot_eng *eng, GEN w, GEN x, GEN y, double xs, double ys);150void gp_get_plot(PARI_plot *T);151152#define gp_get_ploth_default_sizes(S) \153{ PARI_plot *_T = (PARI_plot *)S; \154GEN D = GP_DATA->plothsizes; \155if (D) switch(lg(D)) { \156case 5: if (D[4]) _T->vunit = D[4]; \157case 4: if (D[3]) _T->hunit = D[3]; \158case 3: if (D[2]) _T->height = D[2]; \159case 2: if (D[1]) _T->width = D[1]; \160} \161}162163#define gp_get_plot_generic(S,gp_get_display_sizes) \164{ PARI_plot *_T = (PARI_plot *)S; \165gp_get_display_sizes(&_T->dwidth, &_T->dheight, &_T->fwidth, &_T->fheight);\166_T->width = _T->dwidth? _T->dwidth*4/5: 640; \167_T->height= _T->dheight?_T->dheight*4/5: 480; \168_T->hunit = maxss(_T->height/100,3); \169_T->vunit = maxss(_T->height/100,3); \170gp_get_ploth_default_sizes(S); \171}172173ENDEXTERN174175176