1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

fixed the lines in the svg screenshots

This commit is contained in:
Zeno Rogue 2018-08-01 11:25:07 +02:00
parent 8a231d8269
commit a50169e3d3
4 changed files with 24 additions and 22 deletions

View File

@ -1143,7 +1143,6 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
{
dynamicval<int> dp(poly_outline);
dynamicval<double> dw(minwidth_global);
int eyecolor = 0x202020;
bool redeyes = false;
if(m == moHunterDog) eyecolor = 0xFF0000, redeyes = true;
@ -1151,9 +1150,11 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
if(m == moHunterChanging) eyecolor = 0xFFFF00, redeyes = true;
int eyes = darkena(eyecolor, 0, 0xFF);
if(redeyes) poly_outline = eyes, minwidth_global = 1;
if(redeyes) poly_outline = eyes;
queuepoly(VAHEAD, shWolf1, eyes);
if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE;
queuepoly(VAHEAD, shWolf2, eyes);
if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE;
}
queuepoly(VAHEAD, shWolf3, darkena(m == moRunDog ? 0x202020 : 0x000000, 0, 0xFF));
}

View File

@ -1583,7 +1583,7 @@ extern bool nonbitrunc;
namespace svg {
void circle(int x, int y, int size, int col);
void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double minwidth);
void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth);
void text(int x, int y, int size, const string& str, bool frame, int col, int align);
extern bool in;
extern const string *link;
@ -2359,7 +2359,7 @@ struct qpoly {
const vector<glvertex> *tab;
int offset, cnt;
int outline;
double minwidth;
double linewidth;
int flags;
textureinfo *tinf;
};

View File

@ -53,6 +53,9 @@ static const int POLY_CCONVEX = 8192;
// new system of side checking
static const int POLY_CENTERIN = 16384;
// force wide lines
static const int POLY_FORCEWIDE = (1<<15);
vector<hyperpoint> hpc;
int prehpc;
@ -62,7 +65,6 @@ bool first;
bool fatborder;
int poly_outline;
double minwidth_global;
#define PSHIFT 0
// #define STLSORT
@ -425,21 +427,20 @@ void gldraw(const transmatrix& V, const vector<glvertex>& v, int ps, int pq, int
}
#endif
double linewidthat(const hyperpoint& h, double minwidth) {
if((vid.antialias & AA_LINEWIDTH) && hyperbolic) {
double linewidthat(const hyperpoint& h, double linewidth, int flags) {
if((vid.antialias & AA_LINEWIDTH) && hyperbolic && !(flags & POLY_FORCEWIDE)) {
double dz = h[2];
if(dz < 1 || abs(dz-stereo::scrdist) < 1e-6) return vid.linewidth;
else {
double dx = sqrt(dz * dz - 1);
double dfc = dx/(dz+1);
dfc = 1 - dfc*dfc;
return max(dfc, minwidth) * vid.linewidth;
return max(dfc, linewidth) * vid.linewidth;
}
}
return vid.linewidth;
}
// -radius to +3radius
int mercator_coord;
@ -673,7 +674,7 @@ void drawpolyline(polytodraw& p) {
#if CAP_GL
if(vid.usingGL && using_perspective) {
glLineWidth(linewidthat(tC0(pp.V), pp.minwidth));
glLineWidth(linewidthat(tC0(pp.V), pp.linewidth, pp.flags));
gldraw(pp.V, *pp.tab, pp.offset, pp.cnt, p.col, pp.outline, pp.flags &~ POLY_INVERSE, pp.tinf);
return;
}
@ -804,7 +805,7 @@ void drawpolyline(polytodraw& p) {
if(pp.tinf && (poly_flags & POLY_INVERSE)) {
return;
}
glLineWidth(linewidthat(tC0(pp.V), pp.minwidth));
glLineWidth(linewidthat(tC0(pp.V), pp.linewidth, pp.flags));
if(pp.tinf && pp.offset && !nofill) {
vector<glvertex> tv;
for(int i=0; i<pp.cnt; i++)
@ -824,7 +825,7 @@ void drawpolyline(polytodraw& p) {
coords_to_poly();
int col = p.col;
if(poly_flags & POLY_INVERSE) col = 0;
svg::polygon(polyx, polyy, polyi, col, pp.outline, pp.minwidth);
svg::polygon(polyx, polyy, polyi, col, pp.outline, pp.linewidth);
continue;
}
#endif
@ -903,7 +904,7 @@ void prettyline(hyperpoint h1, hyperpoint h2, int col, int lev) {
pp.tab = &prettylinepoints;
pp.offset = 0;
pp.cnt = isize(prettylinepoints);
pp.minwidth = vid.linewidth;
pp.linewidth = vid.linewidth;
p.col = 0;
pp.outline = col;
pp.flags = POLY_ISSIDE;
@ -922,7 +923,7 @@ void prettypoly(const vector<hyperpoint>& t, int fillcol, int linecol, int lev)
pp.tab = &prettylinepoints;
pp.offset = 0;
pp.cnt = isize(prettylinepoints);
pp.minwidth = minwidth_global;
pp.linewidth = vid.linewidth;
p.col = fillcol;
pp.outline = linecol;
pp.flags = POLY_ISSIDE;
@ -2409,7 +2410,7 @@ void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) {
ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF);
ptd.prio = prio << PSHIFT;
ptd.u.poly.outline = poly_outline;
ptd.u.poly.minwidth = minwidth_global;
ptd.u.poly.linewidth = vid.linewidth;
ptd.u.poly.flags = h.flags;
ptd.u.poly.tinf = NULL;
}
@ -2435,7 +2436,7 @@ void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int li
ptd.col = fillcol;
ptd.prio = prio << PSHIFT;
ptd.u.poly.outline = linecol;
ptd.u.poly.minwidth = minwidth_global;
ptd.u.poly.linewidth = vid.linewidth;
ptd.u.poly.flags = 0;
ptd.u.poly.tinf = NULL;
}
@ -2471,7 +2472,7 @@ void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int
ptd.u.line.H1 = H1;
ptd.u.line.H2 = H2;
ptd.u.line.prf = prf;
ptd.u.line.width = (linewidthat(H1, minwidth_global) + linewidthat(H2, minwidth_global)) / 2;
ptd.u.line.width = (linewidthat(H1, vid.linewidth, 0) + linewidthat(H2, vid.linewidth, 0)) / 2;
ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF);
ptd.prio = prio << PSHIFT;
}

View File

@ -136,7 +136,7 @@ namespace svg {
}
}
void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double minwidth) {
void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth) {
if(invisible(col) && invisible(outline)) return;
if(polyi < 2) return;
@ -148,17 +148,17 @@ namespace svg {
avgy += polyy[i];
avgx /= polyi;
avgy /= polyi;
dfc = (avgx - vid.xcenter) * (avgx - vid.xcenter) +
(avgy - vid.ycenter) * (avgy - vid.ycenter);
dfc = pow(avgx - vid.xcenter, 2) +
pow((avgy - vid.ycenter) / vid.stretch, 2);
dfc /= vid.radius;
dfc /= vid.radius;
// 0 = center, 1 = edge
dfc = 1 - dfc;
if(dfc < 0) dfc = 1;
dfc = max<double>(dfc, 1) * minwidth;
dfc = max<double>(dfc, 1) * linewidth;
}
else dfc = .8 * minwidth;
else dfc = .8 * linewidth;
startstring();
for(int i=0; i<polyi; i++) {