MCPcopy Index your code
hub / github.com/fogleman/primitive / rasterizeTriangle

Function rasterizeTriangle

primitive/triangle.go:111–135  ·  view source on GitHub ↗
(x1, y1, x2, y2, x3, y3 int, buf []Scanline)

Source from the content-addressed store, hash-verified

109}
110
111func rasterizeTriangle(x1, y1, x2, y2, x3, y3 int, buf []Scanline) []Scanline {
112 if y1 > y3 {
113 x1, x3 = x3, x1
114 y1, y3 = y3, y1
115 }
116 if y1 > y2 {
117 x1, x2 = x2, x1
118 y1, y2 = y2, y1
119 }
120 if y2 > y3 {
121 x2, x3 = x3, x2
122 y2, y3 = y3, y2
123 }
124 if y2 == y3 {
125 return rasterizeTriangleBottom(x1, y1, x2, y2, x3, y3, buf)
126 } else if y1 == y2 {
127 return rasterizeTriangleTop(x1, y1, x2, y2, x3, y3, buf)
128 } else {
129 x4 := x1 + int((float64(y2-y1)/float64(y3-y1))*float64(x3-x1))
130 y4 := y2
131 buf = rasterizeTriangleBottom(x1, y1, x2, y2, x4, y4, buf)
132 buf = rasterizeTriangleTop(x2, y2, x4, y4, x3, y3, buf)
133 return buf
134 }
135}
136
137func rasterizeTriangleBottom(x1, y1, x2, y2, x3, y3 int, buf []Scanline) []Scanline {
138 s1 := float64(x2-x1) / float64(y2-y1)

Callers 1

RasterizeMethod · 0.85

Calls 2

rasterizeTriangleBottomFunction · 0.85
rasterizeTriangleTopFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…