如何创建一个线采用布氏任意厚度的?厚度、创建一个

2023-09-10 23:04:19 作者:姩仯淚願甞

我目前使用的布氏算法来画线,但它们是(当然)厚的一个像素。我的问题是什么是绘制任意厚度线最有效的方法是什么?

I am currently using Bresenham's algorithm to draw lines but they are (of course) one pixel in thickness. My question is what is the most efficient way to draw lines of arbitrary thickness?

我使用的语言是C。

推荐答案

我觉得最好的办法就是画一个矩形而不是一条线,因为与宽度的线是两维的对象。特林绘制的一组平行线,以避免透支(以减少写入带宽)和underdraw(缺失像素)将是非常复杂的。这不是太硬,从起始点和结束点和宽度来计算矩形的角点。

I think the best way is to draw a rectangle rather than a line since a line with width is a two dimensional object. Tring to draw a set of parallel lines to avoid overdraw (to reduce write bandwidth) and underdraw (missing pixels) would be quite complex. It's not too hard to calculate the corner points of the rectangle from the start and end point and the width.

 
精彩推荐
图片推荐