/* Draw a vertical line from x,y1 to x,y2 including final point*/ static void linear12_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c) { ADDR8 addr = psd->addr; int linelen = psd->linelen * 3; MWUCHAR r, g, b; linelen/=2; assert (addr != 0); assert (x >= 0 && x < psd->xres); assert (y1 >= 0 && y1 < psd->yres); assert (y2 >= 0 && y2 < psd->yres); assert (y2 >= y1); assert (c < psd->ncolors); x=x+(x<<1); r = PIXEL444RED(c); g = PIXEL444GREEN(c); b = PIXEL444BLUE(c); DRAWON; while(y1++ <= y2) { setpix(addr,x,y1,r); setpix(addr,x+1,y1,g); setpix(addr,x+2,y1,b); } DRAWOFF; }
static void timeline(unsigned long stime, maptool_pIMAGE * img, unsigned long Maxx) { unsigned long y; unsigned long x; unsigned long to; unsigned long t; unsigned long tmp; to = 0UL; tmp = Maxx-1UL; x = 0UL; if (x<=tmp) for (;; x++) { setpix(*img, (long)(x+8UL), 8L, 200L, 1000L, 200L); t = ((stime+useri_localtime())-(((Maxx-1UL)-x)*86400UL)/Maxx)/3600UL; if (to==0UL) to = t; if (to!=t) { to = t; for (y = 5UL; y<=7UL; y++) { setpix(*img, (long)(x+8UL), (long)y, 200L, 1000L, 200L); } /* end for */ if (x>28UL && t%3UL==0UL) { num(*img, (long)((x+8UL)-6UL), 8L, (long)(t%24UL), "h", 2ul); } } if (x==tmp) break; } /* end for */ } /* end timeline() */
/* Draw horizontal line from x1,y to x2,y including final point*/ static void linear12_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c) { ADDR8 addr = psd->addr; MWUCHAR r, g, b; assert (addr != 0); assert (x1 >= 0 && x1 < psd->xres); assert (x2 >= 0 && x2 < psd->xres); assert (x2 >= x1); assert (y >= 0 && y < psd->yres); assert (c < psd->ncolors); r = PIXEL444RED(c); g = PIXEL444GREEN(c); b = PIXEL444BLUE(c); DRAWON; x1*=3; x2*=3; while((x1+=3) <= x2) { setpix(addr,x1,y,r); setpix(addr,x1+1,y,g); setpix(addr,x1+2,y,b); } DRAWOFF; }
static void paper(maptool_pIMAGE * img, float yax0, float yax1, unsigned long step, unsigned long margin, unsigned long maxx, unsigned long maxy, char name[], unsigned long name_len) { unsigned long y; unsigned long x; long so; long s; float v; struct maptool_PIX * anonym; unsigned long tmp; unsigned long tmp0; X2C_PCOPY((void **)&name,name_len); so = (long)X2C_TRUNCI(aprsdecode_floor(X2C_DIVR(yax0,(float)step)), X2C_min_longint,X2C_max_longint); tmp = maxy-1UL; y = 0UL; if (y<=tmp) for (;; y++) { setpix(*img, (long)margin, (long)(y+margin), 200L, 1000L, 200L); v = yax0+(yax1-yax0)*(float)y*(X2C_DIVR(1.0f,(float)maxy)); s = (long)X2C_TRUNCI(aprsdecode_floor(X2C_DIVR(v,(float)step)), X2C_min_longint,X2C_max_longint); tmp0 = (maxx-1UL)+margin; x = margin+1UL; if (x<=tmp0) for (;; x++) { { /* with */ struct maptool_PIX * anonym = &(*img)->Adr[(x)*(*img) ->Len0+(y+margin)]; anonym->r += 60U; anonym->g += (unsigned short)(50UL+40UL*(unsigned long)(char) (s&1)); anonym->b += 60U; } if (x==tmp0) break; } /* end for */ if (s!=so) { tmp0 = margin-1UL; x = margin-3UL; if (x<=tmp0) for (;; x++) { setpix(*img, (long)x, (long)(y+margin), 200L, 1000L, 200L); if (x==tmp0) break; } /* end for */ num(*img, (long)(margin+1UL), (long)((y+margin)-6UL), s*(long)step, \ "", 1ul); so = s; } if (y==tmp) break; } /* end for */ str(*img, margin+50UL, ((maxy+margin*2UL)-aprsdecode_lums.fontysize)-1UL, name, name_len); X2C_PFREE(name); } /* end paper() */
/* Set pixel at x, y, to pixelval c*/ static void linear12_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c) { ADDR8 addr = psd->addr; MWUCHAR r, g, b; assert (addr != 0); assert (x >= 0 && x < psd->xres); assert (y >= 0 && y < psd->yres); assert (c < psd->ncolors); r = PIXEL444RED(c); g = PIXEL444GREEN(c); b = PIXEL444BLUE(c); x=x+(x<<1); DRAWON; setpix(addr,x,y,r); setpix(addr,x+1,y,g); setpix(addr,x+2,y,b); DRAWOFF; }
bool Ppm::rgb2hsvpix(void){ var_pos pos; pos = filter.p1; while(pos.y < filter.p2.y){ pos.x = filter.p1.x; while(pos.x < filter.p2.x){ setpix(pos,rgb2hsv(getpix(pos))); pos.x++; } pos.y++; } return (true); }
extern void aprstat_althist(maptool_pIMAGE * img, aprsdecode_pOPHIST op, char * test, float * way, unsigned long * beacons, unsigned long * msgs, unsigned long * acks, unsigned long * rejs) { char h[256]; char s[256]; float maxalt; float minalt; float alt[5760]; float hdiv; float wdiv; unsigned long markx1; unsigned long markx; unsigned long xc; unsigned long sc; unsigned long x; unsigned long Maxx; struct aprsdecode_DAT dat; float waysum; long markalt; size_t tmp[2]; unsigned long tmp0; *way = 0.0f; *beacons = 0UL; *msgs = 0UL; *acks = 0UL; *rejs = 0UL; if (op==0 || op->frames==0) { *test = 0; return; } Maxx = dynmaxx(8UL, 400UL, 720UL); decodealt(way, beacons, wdiv, rejs, acks, msgs, &dat, alt, &waysum, op, &markalt, &markx1, &markx, 0); if (waysum<0.05f) { *test = 0; /* no altitudes or km */ return; } if (*test) return; X2C_DYNALLOCATE((char **)img,sizeof(struct maptool_PIX), (tmp[0] = Maxx+16UL,tmp[1] = 136U,tmp),2u); useri_debugmem.screens += (*img)->Len1*(*img)->Size1; if (*img==0) { osi_WrStrLn("error image alloc", 18ul); return; } maptool_clr(*img); wdiv = X2C_DIVR((float)(Maxx*8UL-1UL),waysum); decodealt(way, beacons, wdiv, rejs, acks, msgs, &dat, alt, &waysum, op, &markalt, &markx1, &markx, 1); interpol(alt); norm(&hdiv, alt, &maxalt, &minalt); /* FOR x:=0 TO HIGH(alt) DO IF alt[x]>=0.0 THEN WrFixed(alt[x], 3,11) ELSE WrStr(".") END; END; WrStrLn(""); */ /*sc:=VAL(CARDINAL, maxalt-minalt) DIV sfact(FLOAT(maxalt-minalt)); */ sc = sfact(maxalt-minalt); strncpy(s," ",256u); aprsstr_Append(s, 256ul, op->call, 9ul); aprsstr_Append(s, 256ul, " dist=", 7ul); aprsstr_FixToStr(waysum, 2UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); aprsstr_Append(s, 256ul, "km min=", 8ul); aprsstr_IntToStr((long)X2C_TRUNCI(minalt,X2C_min_longint,X2C_max_longint), 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); aprsstr_Append(s, 256ul, "m max=", 7ul); aprsstr_IntToStr((long)X2C_TRUNCI(maxalt,X2C_min_longint,X2C_max_longint), 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); if (markalt>X2C_min_longint) { aprsstr_Append(s, 256ul, "m curs=", 8ul); aprsstr_IntToStr(markalt, 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); } aprsstr_Append(s, 256ul, "m (NN)", 7ul); paper(img, minalt, maxalt, sc, 8UL, Maxx, 120UL, s, 256ul); tmp0 = Maxx+8UL; x = 5UL; if (x<=tmp0) for (;; x++) { setpix(*img, (long)x, 8L, 200L, 1000L, 200L); if (x==tmp0) break; } /* end for */ strncpy(h,"km",256u); if (waysum<5.0f) { waysum = waysum*1000.0f; strncpy(h,"m",256u); } sc = sfact(waysum); hdiv = X2C_DIVR((float)sc*(float)Maxx,waysum); wdiv = 0.0f; xc = 0UL; do { for (x = 5UL; x<=7UL; x++) { setpix(*img, (long)(aprsdecode_trunc(wdiv)+8UL), (long)x, 200L, 1000L, 200L); } /* end for */ if (xc>0UL && aprsdecode_trunc(wdiv)<Maxx-10UL) { num(*img, (long)((aprsdecode_trunc(wdiv)+8UL)-6UL), 8L, (long)xc, h, 256ul); h[0U] = 0; } xc += sc; wdiv = wdiv+hdiv; } while (aprsdecode_trunc(wdiv)<=Maxx); if (markx>0UL) { for (x = 8UL; x<=128UL; x++) { setpix(*img, (long)(markx+8UL), (long)x, 50L, 400L, 500L); } /* end for */ } tmp0 = Maxx*8UL-1UL; x = 0UL; if (x<=tmp0) for (;; x++) { /* draw graph */ addpix(*img, (float)x*0.125f+8.0f, alt[x]+8.0f, 62UL, 62UL, 87UL); if (x==tmp0) break; } /* end for */ } /* end althist() */
extern void aprstat_kmhist(maptool_pIMAGE * img, aprsdecode_pOPHIST op, char * test) { aprsdecode_pFRAMEHIST fold; aprsdecode_pFRAMEHIST fto; aprsdecode_pFRAMEHIST ffrom; aprsdecode_pFRAMEHIST fr; unsigned long ot; unsigned long t1; unsigned long t0; unsigned long markkm; unsigned long markx; unsigned long maxx; unsigned long maxkm10; unsigned long maxkm; unsigned long tf; unsigned long sp; unsigned long i; unsigned long xi; unsigned long xt; float ys; float dy; float maxy; char h[256]; char s[256]; struct aprspos_POSITION po; float vt[12720]; char marks[1584]; unsigned long tops[5]; struct aprsdecode_DAT dat; unsigned long tmp; size_t tmp0[2]; if (op==0 || op->frames==0) { *test = 0; return; } fto = 0; ffrom = 0; fr = op->frames; po = fr->vardat->pos; fold = 0; do { /* find first to last move */ if (((maptool_vistime(fr->time0) && !(fr->nodraw&~0x1U)) && aprspos_posvalid(fr->vardat->pos)) && aprspos_distance(po, fr->vardat->pos)>0.05f) { /* find last move */ fto = fr; po = fr->vardat->pos; if (ffrom==0) ffrom = fold; fold = fr; } fr = fr->next; } while (fr); if (fto==0 || ffrom==0) { *test = 0; /* no move */ return; } if (*test) return; *img = 0; for (xi = 0UL; xi<=1583UL; xi++) { marks[xi] = 0; } /* end for */ /* IF ffrom=NIL THEN ffrom:=op^.frames END; */ t1 = fto->time0; while (ffrom->next && (!(~ffrom->nodraw&0x1U) || ffrom->time0+28800UL<t1)) ffrom = ffrom->next; t0 = ffrom->time0; if (t1<t0+3600UL) { t1 = t0+3600UL; fto = 0; } /* find peak speeds to filter extrem values */ for (i = 0UL; i<=4UL; i++) { tops[i] = 0UL; } /* end for */ fr = ffrom; for (;;) { if ((!(fr->nodraw&~0x1U) && aprsdecode_Decode(fr->vardat->raw, 500ul, &dat)>=0L) && dat.speed<X2C_max_longcard) { i = 0UL; for (;;) { if (dat.speed>=tops[i]) { tops[i] = dat.speed; break; } ++i; if (i>4UL) break; } } if (fr==fto) break; fr = fr->next; if (fr==0) break; } /*FOR i:=0 TO HIGH(tops) DO WrInt(tops[i], 10) END; */ while ((float)tops[0U]>(float)tops[1U]*1.5f) { for (i = 0UL; i<=3UL; i++) { tops[i] = tops[i+1UL]; } /* end for */ } markx = 0UL; markkm = 0UL; maxx = (1584UL*((t1-t0)+3600UL))/28800UL; /* guess picture width */ if (maxx<584UL) maxx = 584UL; else if (maxx>1584UL) maxx = 1584UL; ot = t0; fr = ffrom; xi = 0UL; maxy = 0.0f; dy = 0.0f; tf = 0UL; for (;;) { if ((!(fr->nodraw&~0x1U) && aprsdecode_Decode(fr->vardat->raw, 500ul, &dat)>=0L) && (!useri_configon(useri_fTRACKFILT) || dat.speed<tops[0U])) { dy = (float)aprsdecode_knottokmh((long)dat.speed)+0.5f; if (dy>1000.0f) dy = 1000.0f; if (fr->time0>ot+300UL) tf = 48UL; xt = aprsdecode_trunc((X2C_DIVR((float)(fr->time0-t0), (float)(t1-t0)))*(float)(maxx*8UL-1UL)); /* x position in picture */ if (xt>=maxx*8UL-1UL) xt = maxx*8UL; if (xi/8UL>3UL) marks[xi/8UL-3UL] = 1; if (dy>maxy) maxy = dy; while (xi<xt) { /* constant speed till next waypoint */ vt[xi] = dy; ++xi; if (tf>0UL) { --tf; if (tf==0UL) dy = 0.0f; } } ot = fr->time0; if ((dat.pos.lat==aprsdecode_click.markpos.lat && dat.pos.long0==aprsdecode_click.markpos.long0) && aprsdecode_click.markpost==ot) { markx = xi/8UL; markkm = (unsigned long)aprsdecode_knottokmh((long)dat.speed); } } if (fr==fto) break; fr = fr->next; if (fr==0) break; } tf = 48UL; while (xi<=12719UL) { vt[xi] = dy; ++xi; if (tf>0UL) --tf; else dy = 0.0f; } tmp = maxx*8UL-1UL; xi = 0UL; if (xi<=tmp) for (;; xi++) { dy = 0.0f; for (xt = 0UL; xt<=47UL; xt++) { dy = dy+vt[xi+xt]*(1.0f-sq((float)xt*4.1666666666667E-2f-1.0f)); /* FIR lowpass */ } /* end for */ vt[xi] = dy; if (xi==tmp) break; } /* end for */ maxkm = aprsdecode_trunc(maxy); maxkm10 = ((maxkm+9UL)/10UL)*10UL; if (maxy>=2.0f) { maxy = X2C_DIVR(3.75f,(float)maxkm10); /* FIR gain integral 1-x^2 */ for (xi = 0UL; xi<=12719UL; xi++) { vt[xi] = vt[xi]*maxy; /* fit y in picture */ } /* end for */ X2C_DYNALLOCATE((char **)img,sizeof(struct maptool_PIX), (tmp0[0] = maxx+16UL,tmp0[1] = 136U,tmp0),2u); useri_debugmem.screens += (*img)->Len1*(*img)->Size1; if (*img==0) { osi_WrStrLn("error image alloc", 18ul); return; } maptool_clr(*img); /* FOR xt:=MARGIN TO MAXY+MARGIN-1 DO FOR xi:=MARGIN TO MAXX+MARGIN-1 DO WITH img^[xi+xt*(MAXX+2*MARGIN)] DO r:=30; g:=60+50*ORD(ODD(xt DIV 10)); b:=80+200*ORD(marks[xi-MARGIN]); END; END; END; */ dy = (X2C_DIVR(120.0f,(float)maxkm10))*10.0f; ys = 0.0f; xt = 0UL; sp = 0UL; do { /* draw y scale and paper and waypoints*/ for (i = 6UL-2UL*(unsigned long)(sp%5UL==0UL); i<=8UL; i++) { setpix(*img, (long)i, (long)(aprsdecode_trunc(ys+0.5f)+8UL), 200L, 1000L, 200L); } /* end for */ ys = ys+dy; while (xt<aprsdecode_trunc(ys) && xt<120UL) { tmp = (maxx+8UL)-1UL; xi = 8UL; if (xi<=tmp) for (;; xi++) { setpix(*img, (long)xi, (long)(xt+8UL), 20L, (long)(30UL+50UL*(unsigned long)(char)(sp&1)), (long)(60UL+200UL*(unsigned long)marks[xi-8UL])); if (xi==tmp) break; } /* end for */ ++xt; } ++sp; } while (ys<121.0f); tmp = maxx-1UL; xi = 0UL; if (xi<=tmp) for (;; xi++) { setpix(*img, (long)(xi+8UL), 8L, 200L, 1000L, 200L); if (xi==tmp) break; } /* end for */ for (xi = 0UL; xi<=120UL; xi++) { setpix(*img, 8L, (long)(xi+8UL), 200L, 1000L, 200L); } /* end for */ sp = t0/3600UL+1UL; ot = sp*3600UL; ys = X2C_DIVR((float)(maxx*(ot-t0)),(float)(t1-t0)); /* x of first full hour */ dy = X2C_DIVR((float)(maxx*3600UL),(float)(t1-t0)); /* x size of 1h */ if (dy>20.0f && ys<=(float)maxx) { if (ys-dy*0.5f>0.0f) { /* draw 1/2 h mark */ for (i = 6UL; i<=7UL; i++) { setpix(*img, (long)(aprsdecode_trunc(ys-dy*0.5f)+8UL), (long)i, 200L, 1000L, 200L); } /* end for */ } sp = sp+24UL+useri_localtime()/3600UL; do { /* draw h and rest of 1/2h marks */ for (i = 4UL; i<=7UL; i++) { setpix(*img, (long)(aprsdecode_trunc(ys)+8UL), (long)i, 200L, 1000L, 200L); } /* end for */ if (ys+dy*0.5f<=(float)maxx) { for (i = 6UL; i<=7UL; i++) { setpix(*img, (long)(aprsdecode_trunc(ys+dy*0.5f)+8UL), (long)i, 200L, 1000L, 200L); } /* end for */ } num(*img, (long)((aprsdecode_trunc(ys)+8UL)-6UL), 8L, (long)(sp%24UL), "h", 2ul); ++sp; ys = ys+dy; } while (ys<=(float)maxx); } if (markx>3UL) { markx -= 3UL; for (xi = 8UL; xi<=128UL; xi++) { setpix(*img, (long)(markx+8UL), (long)xi, 500L, 200L, 50L); } /* end for */ } tmp = maxx*8UL-1UL; xi = 8UL; if (xi<=tmp) for (;; xi++) { /* draw graph */ dy = vt[xi]; if (dy>=0.1f) { if (dy>120.0f) dy = 120.0f; addpix(*img, (float)xi*0.125f+8.0f, dy+8.0f, 125UL, 125UL, 12UL); } if (xi==tmp) break; } /* end for */ strncpy(s," ",256u); aprsstr_Append(s, 256ul, op->call, 9ul); aprsstr_Append(s, 256ul, " max=", 6ul); aprsstr_IntToStr((long)maxkm, 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); if (markx>0UL) { aprsstr_Append(s, 256ul, " cursor=", 9ul); aprsstr_IntToStr((long)markkm, 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); } aprsstr_Append(s, 256ul, "km/h", 5ul); num(*img, 10L, (long)((136UL-aprsdecode_lums.fontysize)-1UL), (long)maxkm10, s, 256ul); } /* IF img<>NIL THEN DISPOSE(img) END; */ } /* end kmhist() */
extern void aprstat_btimehist(maptool_pIMAGE * img, aprsdecode_pOPHIST op) { unsigned long t[7200]; aprsdecode_pFRAMEHIST pf; unsigned long textd; unsigned long textx; unsigned long max0; unsigned long expand; unsigned long scale0; unsigned long xm; unsigned long sum; unsigned long y; unsigned long i; unsigned long dt; char s[256]; unsigned long tmp; size_t tmp0[2]; if (op==0) return; for (i = 0UL; i<=7199UL; i++) { t[i] = 0UL; } /* end for */ pf = op->frames; sum = 0UL; if (pf) { while (pf->next) { if (maptool_vistime(pf->time0) && pf->next->time0>=pf->time0) { dt = pf->next->time0-pf->time0; if (dt<=7199UL) { ++t[dt]; ++sum; } } pf = pf->next; } } sum -= sum/20UL; xm = 0UL; y = 0UL; do { y += t[xm]; ++xm; } while (!(xm>=7199UL || y>=sum)); ++xm; if (xm<120UL) xm = 120UL; for (i = xm+1UL; i<=7199UL; i++) { t[xm] += t[i]; /* add not shown rest to last shown element */ } /* end for */ scale0 = ((xm+620UL)-1UL)/620UL; textd = 50UL; if (scale0>30UL) { scale0 = 60UL; textx = 50UL; } else if (scale0>12UL) { scale0 = 30UL; textx = 20UL; } else if (scale0>6UL) { scale0 = 12UL; textx = 10UL; } else if (scale0>3UL) { scale0 = 6UL; textx = 5UL; } else if (scale0>2UL) { scale0 = 3UL; textx = 3UL; textd = 60UL; } else if (scale0>1UL) { scale0 = 2UL; textx = 2UL; textd = 60UL; } else { scale0 = 1UL; textx = 1UL; textd = 60UL; } if (scale0>1UL) { for (i = 1UL; i<=7199UL; i++) { if (i%scale0==0UL) t[i/scale0] = 0UL; t[i/scale0] += t[i]; } /* end for */ } xm = ((xm+scale0)-1UL)/scale0; expand = 1UL; if (xm<310UL) expand = 2UL; else if (xm>620UL) xm = 620UL; else if (xm==0UL) return; xm = xm*expand; max0 = 0UL; tmp = xm-1UL; i = 0UL; if (i<=tmp) for (;; i++) { if (t[i]>max0) max0 = t[i]; if (i==tmp) break; } /* end for */ if (max0==0UL) return; tmp = xm-1UL; i = 0UL; if (i<=tmp) for (;; i++) { t[i] = (t[i]*150UL)/max0; if (i==tmp) break; } /* end for */ X2C_DYNALLOCATE((char **)img,sizeof(struct maptool_PIX), (tmp0[0] = xm+16UL,tmp0[1] = 166U,tmp0),2u); useri_debugmem.screens += (*img)->Len1*(*img)->Size1; if (*img==0) { osi_WrStrLn("error image alloc", 18ul); return; } maptool_clr(*img); tmp = xm-1UL; i = 0UL; if (i<=tmp) for (;; i++) { setpix(*img, (long)(i+8UL), 7L, 0L, 500L, 800L); if ((i/expand)%10UL==0UL) { setpix(*img, (long)(i+8UL), 6L, 0L, 500L, 800L); } if ((i/expand)%textd==0UL) { setpix(*img, (long)(i+8UL), 5L, 0L, 500L, 800L); setpix(*img, (long)(i+8UL), 4L, 0L, 500L, 800L); } for (y = 0UL; y<=149UL; y++) { setpix(*img, (long)(i+8UL), (long)(y+8UL), 50L, (long)(20UL*(unsigned long)(char)((i/expand)/10UL&1)+30UL), 30L); } /* end for */ y = 0UL; while (y<t[i/expand]) { setpix(*img, (long)(i+8UL), (long)(y+8UL), 500L, 500L, 0L); ++y; } if (i==tmp) break; } /* end for */ for (i = 0UL; i<=149UL; i++) { setpix(*img, 7L, (long)((i+8UL)-1UL), 0L, 500L, 800L); if (i%10UL==0UL) setpix(*img, 6L, (long)((i+8UL)-1UL), 0L, 500L, 800L); } /* end for */ strncpy(s," Beacons per Time ",256u); aprsstr_Append(s, 256ul, op->call, 9ul); num(*img, 10L, (long)((166UL-aprsdecode_lums.fontysize)-1UL), (long)max0, s, 256ul); num(*img, (long)((expand*textd+8UL)-12UL), 8L, (long)textx, "m", 2ul); /* DISPOSE(img); */ } /* end btimehist() */
GtkWidget *setpixmap (char *str, xmlNode *info) { GtkWidget *hbox; GtkWidget *pixmap_wid; GtkWidget *label; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; /***************************************************/ hbox = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox); style = gtk_widget_get_style (Peos); pixmap = gdk_pixmap_create_from_xpm_d (Peos->window, &mask, &style->bg[GTK_STATE_NORMAL], setpix(info)); pixmap_wid = gtk_pixmap_new (pixmap, mask); gtk_widget_show (pixmap_wid); gtk_misc_set_alignment (GTK_MISC (pixmap_wid), 0.0, 0.5); gtk_box_pack_start (GTK_BOX(hbox), pixmap_wid, FALSE, FALSE, 0); label = gtk_label_new (str); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); /****************************************************/ return hbox; }
void partialzetasums() { int offset = 1; int width = 1980; int height = 1080; int xoff = -width/3; #define xcoord(xxx) (xoff+(xxx)*scale + width / 2) int samples = 150; int imgi = 0; float maxsample = 28.f; float scale = 300; int granularity = 1; std::vector<vec2> traj; std::vector<int> traj_meta; std::vector<vec2> primal; bool outputiter = false; for (int yyy = 0; yyy < 1360000; ++yyy) { //int y = nth_prime(yyy); // int y = yyy; float yy = y / float(granularity); if (y % 20000 == 0) { outputiter = true; setwh(width, height); gprint(20, 20, "i=%x", yy); } else { outputiter = false; } vec2 prev; float total_rotation = 0.f; for (int s = 1; s <= samples; ++s) { float rotational_contribution = yy * (360.f / s); total_rotation += rotational_contribution; vec2 newpos = prev + vec2(1, 0).rotate(rotational_contribution, vec2()).set_length(nth_length(s)); //if(outputiter) //Line(xcoord(prev.x), prev.y*scale + height / 2, xcoord(newpos.x), newpos.y*scale + height / 2, 255); prev = newpos; } auto ffi = get_full_factor_info(y / granularity); int num_factors = ffi.prime_factors_sequence.size(); //if (y % granularity == 0 && == 4) { // primal.push_back(prev); //} traj.push_back(prev); traj_meta.push_back(num_factors); prev = traj[0]; if (outputiter) { for (int i = 0; i < traj.size(); ++i) { auto t = traj[i]; //Line(prev.x*scale + width / 2, prev.y*scale + height / 2, t.x*scale + width / 2, t.y*scale + height / 2, 0, 255, 0); setpix(xcoord(t.x), t.y*scale + height / 2, 255.f); prev = t; } if (primal.size() > 0) { prev = primal[0]; for (auto p : primal) { //Line(prev.x*scale + width / 2, prev.y*scale + height / 2, p.x*scale + width / 2, p.y*scale + height / 2, 255, 0, 0); setpix(xcoord(p.x), p.y*scale + height / 2, 255,0,0); prev = p; } } makecross(xcoord(0), height / 2, 0, 0, 255); makecross(xcoord(1), height / 2, 0, 0, 255); std::ostringstream ss; ss << "P:/newpics/big4/zeta"; ss << imgi; //ss << "("; //ss << y; //ss << ")"; ss << ".png"; lodepng::encode(ss.str(), img, w, h); imgi += 1; } } }