|
|
@ -113,6 +113,8 @@ void Raster::drawSpan(const Span &span, Image* image) { |
|
|
|
//float length = tmax<int>(span.xStart - span.xEnd, 1); //取保length不为0
|
|
|
|
|
|
|
|
Rgba color; |
|
|
|
Rgba blendColor; |
|
|
|
Rgba dstColor; |
|
|
|
float2 uv; |
|
|
|
float scale; |
|
|
|
float length = span.xEnd - span.xStart; |
|
|
@ -131,11 +133,18 @@ void Raster::drawSpan(const Span &span, Image* image) { |
|
|
|
} else { |
|
|
|
scale = (float) (i - startX) / length; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
blendColor = colorLerp(span.color1, span.color2, scale); |
|
|
|
uv = uvLerp(span.uvStart, span.uvEnd, scale); |
|
|
|
|
|
|
|
color = image->pixelUv(uv.x, uv.y); |
|
|
|
setPixel(i, span.y, color); |
|
|
|
|
|
|
|
//颜色混合
|
|
|
|
dstColor = color + blendColor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setPixel(i, span.y, dstColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -163,6 +172,9 @@ void Raster::drawEge(const Ege& e1, const Ege& e2, Image* image) { |
|
|
|
|
|
|
|
float2 uvE1; |
|
|
|
float2 uvE2; |
|
|
|
Rgba color1; |
|
|
|
Rgba color2; |
|
|
|
|
|
|
|
for (int y = startY2; y > endY2; y--) { |
|
|
|
|
|
|
|
int x2; |
|
|
@ -171,6 +183,7 @@ void Raster::drawEge(const Ege& e1, const Ege& e2, Image* image) { |
|
|
|
} else { |
|
|
|
x2 = e2.x2 - xOffset2 * scale2; |
|
|
|
} |
|
|
|
color2 = colorLerp(e2.color1, e2.color2, scale2); |
|
|
|
uvE2 = uvLerp(e2.uv2, e2.uv1, scale2); |
|
|
|
scale2 += setp2; |
|
|
|
//setPixel(x2, y, Rgba(255,0,0));
|
|
|
@ -182,11 +195,12 @@ void Raster::drawEge(const Ege& e1, const Ege& e2, Image* image) { |
|
|
|
} else { |
|
|
|
x1 = e1.x2 - xOffset1 * scale1; |
|
|
|
} |
|
|
|
color1 = colorLerp(e1.color1, e1.color2, scale1); |
|
|
|
uvE1 = uvLerp(e1.uv2, e1.uv1, scale1); |
|
|
|
scale1 += setp1; |
|
|
|
//setPixel(x1, y, Rgba(255,0,0));
|
|
|
|
|
|
|
|
Span span(x1, x2, y, Rgba(255, 255, 255), Rgba(255, 255, 255), uvE1, uvE2); |
|
|
|
Span span(x1, x2, y, color1, color2, uvE1, uvE2); |
|
|
|
drawSpan(span, image); |
|
|
|
} |
|
|
|
} |
|
|
|