绘制填充对称多边形的算法?
我正在寻找绘制填充多边形所需的一系列步骤。我将创建一个将其呈现为位图的函数。我正在用类似于 Visual Basic 的语言编写,但没有大多数面向对象的东西,如类和继承,绘图功能是drawline()和drawrect(),仅此而已,但它可以缩放和旋转已完成的对象位图对象,因此,当我填充多边形时,它将在 for 循环或 while 循环中一次一个点,但是,如果有任何区别,我可以将位图转换为字节数组(可能会更快?)所以如果你有一种方法可以治疗将完成的多边形线作为字节数组并以这种方式填充它,可能比 100,000 个plot(x,y) 命令更快?我不知道,无论哪种方式都会很有趣。
我不想绘制不规则的多边形,只是绘制具有任意数量边(最少 3 个)的对称(径向对称)多边形,该多边形位于位图区域的中心。
绘制方法是笛卡尔坐标系,0,0 位于位图的左上角。我猜输入看起来像这样:
drawpolygon(bitmapobj,width,height,sides,radius)
也许半径不是必需的,因为位图的大小将是多边形的限制?
如果可能的话,寻找英文步骤而不是代码,但是如果代码没有太多特定于语言的方面(例如,c++ 有一堆声明、类型转换指针等我不需要的东西),那么代码可能会很有用。处理但不是 100% 确定如何转换为我正在使用的语言)。
I'm looking for the series of steps necessary to draw a filled polygon. I will create a function that renders it to a bitmap. I'm writing in a language similar to visual basic, but without most of the object oriented stuff like classes and inheritance, and the drawing capabilities are drawline() and drawrect() and that is it, but it can scale and rotate a completed bitmap object, so, when I fill the polygon, it will be one dot at a time in a for loop or a while loop, however, I can convert the bitmap to a byte array if that makes any difference (might be faster?) so if you have a method that would treat a completed polygon line as a byte array and fill it that way, might be faster than 100,000 plot(x,y) commands? I don't know, either way would be interesting to look at.
I'm not trying to draw irregular polygons, just symmetrical (radial symmetry) with an arbitrary number of sides, minimum 3, centered in the bitmap area.
Drawing method is cartesian with 0,0 being uppper left of the bitmap. I guess the inputs would look something like:
drawpolygon(bitmapobj,width,height,sides,radius)
Perhaps radius is not necessary since the size of the bitmap will be the limit of the polygon?
Looking for steps in English instead of code, if possible, but code could be useful if it doesn't have too many language specific aspects (for instance, c++ has a bunch of declarations, type casting pointers, stuff I don't have to deal with and am not 100% sure how to convert to the language I'm using).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里给出了一个方程 (最后一个)。
通过循环遍历所有 x 和 y 坐标,并检查该方程的输出是否小于零,您可以确定哪些点在“内部”并适当地为它们着色。
There is an equation given here (the last one).
By looping over all the x and y coordinates, and checking that the output of this equation is less than zero, you can determine which points are 'inside' and colour them appropraitely.