基本图形问题 [英] Basic graphics question

查看:60
本文介绍了基本图形问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我对C#相对较新,对C#图形很陌生,我正在尝试为一些优化程序生成图形输出我是试验(我在数学方面有点经验)。尝试与谷歌合作一直很令人沮丧 - 没有什么成功,甚至不确定它是否可行(但肯定是)。



我的问题是自动的将一维设计的对象渲染到具有设定比例和变换的对象上。



基本上我想做以下事项:



- 我将在(0,0)到(a,b)空间上进行纯粹的2D计算,并希望将原点(0,0)保留在左下方以供参数使用。当我输出任何东西时,它必须被缩放并转换到我的Windows窗体上的图形对象(比如一个面板)(我可以看到左上角有(0,0)和与其实际相关的任意尺寸尺寸)。



- 生成并显示一些随机形状(椭圆和矩形)。我可以做到这一点(不是太难)但是无法在我的工作尺寸中生成它们并自动将它们显示在我的图形表面上而无需在渲染之前缩放/转换它们。



例如:



- 说我在(0,0)到(100,100)的ax / y空间工作/计算左下角有(0,0)。



- 我的窗体上显示的对象(比如一个面板)左上方有尺寸(0,0)低至(200,300)右下角。



- 我在我的工作空间创建一个圆圈,其中心位于(50,50)和半径10(位于中间)我的工作空间)。



- 现在我想在面板中间显示它,好像它有我的工作空间尺寸,C#自动进行转换这样它看起来会按比例缩放,而原点就在底部。



我希望这是有道理的。非常感谢任何帮助。



很多问候,

大卫(悉尼)

解决方案

我想你可以在这里得到一些好的信息:

专业C# - 带GDI +的图形 [ ^ ]



也许在这里:

http://bobpowell.net/beginnersgdi.aspx [ ^ ]

Hi all,

I'm relatively new to C# and very new to C# graphics and am trying to produce a graphical output for some optimisation routines I'm experimenting with (I'm a bit more experienced in mathematics). Trying to work this out with Google has been frustrating - have had little success and am not even sure it's doable (but surely it is).

My problem is around automatically rendering objects designed in one dimension onto an object with a set scale and transformation.

Essentially I want to do the following:

- I will be working and making calculations purely in 2D on a (0,0) to (a,b) space and wish to keep the origin (0,0) at the bottom left for argument's sake. When I output anything, it has to be scaled and transformed onto the graphics object (say a panel) on my Windows form (which as far as I can see has (0,0) at the top left and arbitrary dimensions related to its actual size).

- generate and display some random shapes (ellipses and rectangles). I can do this (not too hard) but can't get my head around generating them in my working dimensions and displaying them on my graphics surface automatically without having to scale/transform them before rendering.

As an example:

- say I'm working/calculating on a x/y space from (0,0) to (100,100) with (0,0) at the bottom left.

- the object for display (say a panel) on my windows form has dimensions (0,0) top left down to (200,300) bottom right.

- I create a circle in my working space to have centre at (50,50) and radius 10 (right in the middle of my working space).

- Now I want to display this in the middle of the panel as if it had my working space dimensions, with C# automatically doing the transformations such that it will appear to scale and with the origin at the bottom.

I hope this makes sense. Any help will be very gratefully received.

Many regards,
David (Sydney)

解决方案

I think you can get some good information here:
Professional C# - Graphics with GDI+[^]

And maybe here:
http://bobpowell.net/beginnersgdi.aspx[^]


这篇关于基本图形问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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