Change bold code snippets to inline code blocks
This commit is contained in:
parent
f658bfbb40
commit
3c76d884ef
185 changed files with 1772 additions and 1772 deletions
20
36-02.md
20
36-02.md
|
|
@ -59,9 +59,9 @@ however, the discussion also applies to Y-major lines, with X and Y
|
|||
reversed.
|
||||
|
||||
The minimum possible length for any run in an X-major line is
|
||||
**int(XDelta/YDelta)**, where **XDelta** is the X-dimension of the line
|
||||
and **YDelta** is the Y-dimension. The maximum possible length is
|
||||
**int(XDelta/YDelta)+ 1**. The trick, then, is knowing which of these
|
||||
`int(XDelta/YDelta)`, where `XDelta` is the X-dimension of the line
|
||||
and `YDelta` is the Y-dimension. The maximum possible length is
|
||||
`int(XDelta/YDelta)+ 1`. The trick, then, is knowing which of these
|
||||
two lengths to select for each run. To see how we can make this
|
||||
selection, refer to Figure 36.4. For each one-pixel step along the minor
|
||||
axis (Y, in this case), we advance at least three pixels. The full
|
||||
|
|
@ -83,17 +83,17 @@ floating-point arithmetic is slow and fixed-point arithmetic is
|
|||
imprecise. Therefore, we take a cue from standard Bresenham's and scale
|
||||
all the error-term calculations up so that we can work with integers.
|
||||
The fractional X (major axis) advance per one-pixel Y (minor axis)
|
||||
advance is the fractional portion of **XDelta/YDelta**. This value is
|
||||
exactly equivalent **to (XDelta % YDelta)/YDelta**. We'll scale this up
|
||||
by multiplying it by **YDelta\*2**, so that the amount by which we
|
||||
advance is the fractional portion of `XDelta/YDelta`. This value is
|
||||
exactly equivalent `to (XDelta % YDelta)/YDelta`. We'll scale this up
|
||||
by multiplying it by `YDelta*2`, so that the amount by which we
|
||||
adjust the error term up for each one-pixel minor-axis advance is
|
||||
**(XDelta % YDelta)\*2**.
|
||||
`(XDelta % YDelta)*2`.
|
||||
|
||||
We'll similarly scale up the one pixel by which we adjust the error term
|
||||
down after it turns over, so our downward error-term adjustment is
|
||||
**YDelta\*2**. Therefore, before drawing each run, we'll add **(XDelta %
|
||||
YDelta)\*2** to the error term. If the error term runs over (reaches one
|
||||
full pixel), we'll lengthen the run by 1, and subtract **YDelta\*2**
|
||||
`YDelta*2`. Therefore, before drawing each run, we'll add `(XDelta %
|
||||
YDelta)*2` to the error term. If the error term runs over (reaches one
|
||||
full pixel), we'll lengthen the run by 1, and subtract `YDelta*2`
|
||||
from the error term. (All values are multiplied by 2 so that the initial
|
||||
error term, which involves a 0.5 term, can be scaled up to an integer,
|
||||
as discussed next.)
|
||||
|
|
|
|||
Loading…
Reference in a new issue