diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2010-02-01 09:40:20 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2010-02-01 09:40:20 +0000 |
commit | 1a0cc609b9fccd3b183257a007c08e5295e782e8 (patch) | |
tree | 6857e24e70470b5e78cbec39e70668b4db049d08 /src/plot | |
parent | 266b99a1430431fd843fb5ffa9f420c46afaad49 (diff) | |
download | libnsfb-1a0cc609b9fccd3b183257a007c08e5295e782e8.tar.gz libnsfb-1a0cc609b9fccd3b183257a007c08e5295e782e8.tar.bz2 |
Simplification.
svn path=/trunk/libnsfb/; revision=9948
Diffstat (limited to 'src/plot')
-rw-r--r-- | src/plot/generic.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/plot/generic.c b/src/plot/generic.c index 3bd06a5..3d84104 100644 --- a/src/plot/generic.c +++ b/src/plot/generic.c @@ -173,22 +173,18 @@ static bool find_span(const int *p, int n, int x, int y, int *x0, int *x1) } else { /* find crossing (intersection of this line and * current y level) */ - int numerator = (y - p_y0) * (p_x1 - p_x0); - int denominator = (p_y1 - p_y0); + int num = (y - p_y0) * (p_x1 - p_x0); + int den = (p_y1 - p_y0); /* To round to nearest (rather than down) * half the denominator is either added to * or subtracted from the numerator, * depending on whether the numerator and - * denominator have the same sign */ - if ((numerator < 0) == (denominator < 0)) - x_new = p_x0 + (numerator + - (denominator / 2)) / - denominator; - else - x_new = p_x0 + (numerator - - (denominator / 2)) / - denominator; + * denominator have the same sign. */ + num = ((num < 0) == (den < 0)) ? + num + (den / 2) : + num - (den / 2); + x_new = p_x0 + num / den; } /* ignore crossings before current x */ |