So broken lol
This commit is contained in:
parent
e473fe838f
commit
00aedc5531
@ -60,15 +60,6 @@ func Triangle1(fb *Framebuffer, color uint, v0 Vec2i, v1 Vec2i, v2 Vec2i) {
|
|||||||
v1, v2 = v2, v1
|
v1, v2 = v2, v1
|
||||||
}
|
}
|
||||||
|
|
||||||
// The lesson says to always figure out what's on the left.
|
|
||||||
// As such, we always go from left to right
|
|
||||||
// While drawing the straight line, go the opposite direction if the
|
|
||||||
// longer side is on the right (we go from long side to short)
|
|
||||||
var sweep int = 1
|
|
||||||
if v2.X > v1.X {
|
|
||||||
sweep = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't worry about speed for now...
|
// Don't worry about speed for now...
|
||||||
dy := float32(v2.Y-v0.Y) - 0.5
|
dy := float32(v2.Y-v0.Y) - 0.5
|
||||||
var v02step, v01step, v12step, xlong, xshort float32
|
var v02step, v01step, v12step, xlong, xshort float32
|
||||||
@ -88,8 +79,13 @@ func Triangle1(fb *Framebuffer, color uint, v0 Vec2i, v1 Vec2i, v2 Vec2i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for y := v0.Y; y <= v2.Y; y++ {
|
for y := v0.Y; y <= v2.Y; y++ {
|
||||||
// Draw a horizontal line from
|
xleft := int(math.Floor(float64(xshort)))
|
||||||
for x := int(math.Floor(float64(xlong))); x <= int(math.Floor(float64(xshort))); x += sweep {
|
xright := int(math.Floor(float64(xlong)))
|
||||||
|
if xleft > xright {
|
||||||
|
xleft, xright = xright, xleft
|
||||||
|
}
|
||||||
|
// Draw a horizontal line from elft to right
|
||||||
|
for x := xleft; x <= xright; x++ {
|
||||||
fb.SetSafe(uint(x), uint(y), color)
|
fb.SetSafe(uint(x), uint(y), color)
|
||||||
}
|
}
|
||||||
xlong += v02step
|
xlong += v02step
|
||||||
|
Loading…
Reference in New Issue
Block a user