是否有在数字屏幕上绘制2D对象的一般方法 [英] Is there a general method of drawing 2d objects on a digital screen

查看:159
本文介绍了是否有在数字屏幕上绘制2D对象的一般方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,我想通过定义一组像素来绘制2D对象,以更改为表示形状的颜色。例如,如果我想画一个正方形,我会定义一个左上角(0,0),右下角说(10,10)。然后,我会改变所有的像素x值0-10的颜色与y值0-10。

不幸的是,我没有一个可靠的一步一步的方法来完成这个任务,并且只能够绘制正方形/矩形,因为它们非常简单。

有没有一种方法可以描述,或者描述了如何做到这一点的资源,您可以指向我,这将帮助我绘制除正方形和矩形之外的其他形状?

伪代码,或者这个在C中的基本实现,或者java会很有帮助。此外,如何彻底描述如何实现这一点也会有所帮助。

解决方案


Some context, I want to draw 2D objects by defining a set of pixels to change to a color which represents the shape. For example, if I wanted to draw a square I'd define a top left corner say (0,0), and a bottom right corner say (10,10). Then I'd change the color of all the pixels x values 0-10 with y values 0-10.

Unfortunately I don't have a solid step by step method to complete this, and am only able to draw squares/rectangles due to how simple they are.

Is there a method you can describe, or a resource that describes how to do this you can point me to, which will help me draw shapes other then squares and rectangles?

pseudo code, or a basic implementation of this in C, or java would be very helpful. Also, just a thorough description of how this would be achieved would also be helpful.

解决方案

Like J... said there's a lot to cover, but I do like the method you described in the comments. I think the biggest challenge of using the method you have described would be creating the vectors between the nodes. A solution you could use to draw the vectors would be to stagger the pixels to create the illusion of a straight line. Also, shapes would become less jagged as you increased the value of n.

这篇关于是否有在数字屏幕上绘制2D对象的一般方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆