New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gradient with equal corners is generating some variation #368
Comments
Hrmm this is exactly what Fills::Monochromatic ought be testing, and it passes fine... |
4088997700000000 4088997700000000 4088997700000000 4088997700000000 4088997740000000 yx 0 0 8 8 |
Yeah this is all fucked up. schwarzgerat $ ./a.out 0 64 128 255 40 40 |
Disgusting. This should have never been allowed into production: schwarzgerat $ ./a.out 0 64 128 255 10 10 |
MUCH better: schwarzgerat $ ./a.out 0 64 128 255 20 20 |
Not yet perfect, though. The middle here ought be 112, not 111:
(128 + 64 + 255) / 4 == 111.75. So it's a rounding issue, but nonetheless, we ain't done until we're done. Let's see that become 112. This implementation uses |
BOOM, MOTHERFUCKERS. Integer math, perfect results:
our final equation of state becomes: static int
calc_gradient_component(unsigned tl, unsigned tr, unsigned bl, unsigned br,
int y, int x, int ylen, int xlen){
assert(xlen >= 2);
assert(ylen >= 2);
const int avm = (ylen - 1) - y;
const int ahm = (xlen - 1) - x;
const int tlc = ahm * avm * tl;
const int blc = ahm * y * bl;
const int trc = x * avm * tr;
const int brc = y * x * br;
const int divisor = (ylen - 1) * (xlen - 1);
return ((tlc + blc + trc + brc) + divisor / 2) / divisor;
} |
Monochromatic checks out, as do vertical and horizontal:
|
Perfect vertical:
Perfect horizontal:
|
If i ask for a gradient where all four corners are the exact same value, every cell in the gradient ought be that same value. I've just added a unit test which shows this not to be the case. See
Ncplane::Stain
intests/ncplane.cpp
.The text was updated successfully, but these errors were encountered: