CTYPE html>
SetPoint: function(x,y,r,g,b) {
if (x >= 0 && x < this.width && y >= 0 && y < this.height) {
// this if is a very bad form of clipping
if (x >= this.viewportXMin && x <= this.viewportXMax
&& y>=this.viewportYMin && y <= this.viewportYMax) {
this.frameBuffer[x][y].R = Clamp(0,255,r);
this.frameBuffer[x][y].G = Clamp(0,255,g);
this.frameBuffer[x][y].B = Clamp(0,255,b);
}
}
return;
},
y(α3) = (1-α3)p1.y + α3p2.y note y(α3) = ymax
ymax = p1.y - α3p1.y + α3p2.y
ymax - p1.y = α3(p2.y-p1.y)
ymax - p1.y
α3 = ------------
p2.y - p1.y
α3(p2.y-p1.y) = ymax - p1.y
= α3Δy
define Δymax = ymax - p1.y
so α3Δy = Δymax, which is only integer computation.