相关疑难解决方法(0)

如何光栅化旋转的矩形(在2d内由setpixel)

我有旋转矩形的四个2d顶点ABCD,我需要使用setpixel(x,y,color)在pixelbufer中光栅化/绘制它(有效)

怎么做?

我正在尝试使用一些代码

    // convertilg a b c d do up down left right, 
    // calculating some dx_left dx_right on y--
    // etc (frustrating on special cases when there are 2 up_y vertices in same line etc)


    for(;;)
    {

     drawhorizontalline(y, xstart, xend, color);

     if(y==downy) break;

     y--;
     xstart+=dxstart;
     xend+=dxend;

     if(y==lefty)  dxstart = dxright;
     if(y==righty) dxend = dxleft;

     }
Run Code Online (Sandbox Code Playgroud)

但它是最令人沮丧的(非常容易出错和最令人沮丧)我真的厌倦了昨天整整这一天,我需要找到一些工作代码,而不是试图调试这个

c algorithm 2d graph-algorithm rasterize

2
推荐指数
1
解决办法
3406
查看次数

标签 统计

2d ×1

algorithm ×1

c ×1

graph-algorithm ×1

rasterize ×1