我是 Octave/MATLAB 的新手。我想为一个三角形矢量化一个简单的扫描线填充。这是我要消除的 while 循环:
#Iterate over all the scan lines from bottom to top
while(yCurr <= 200)
#VARIABLES:
# img - Zero matrix used as an image. Zero is black. Assume 320x200 pixels.
# leftIdx - Vector that contains the left-most pixel to fill in each
# scanline. Dim is 1x200. Each element represents x-coord of a pixel.
# rightIdx - Vector that contains the right-most pixel to fill in each
# scanline. Dim is also 1x200. Each element represents x-coord of a pixel.
# yCurr - The current row being scanned.
#Fill all the pixels in one scan line
img(leftIdx(yCurr) : rightIdx(yCurr), yCurr) = color;
#Increment the row
yCurr++;
endwhile