如何使用C ++绘制路径? (动画图绘制) [英] How can I plot a path by C++? (Animated graph plotting)

查看:110
本文介绍了如何使用C ++绘制路径? (动画图绘制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我想通过c ++,Window Form绘制路径
路径基于两个变量x和y
并且两个变量都改变了w.r.t时间
因此,我希望程序每0.5s在图形上绘制x和y

这是我的代码

Hi there,
I want to draw a path by c++, Window Form
the path is based on two variables, x and y
and both variables change w.r.t time
Therefore, I want the program to plot x and y on the graph every 0.5s

Here is my code

Color Black=Color::FromArgb(250, Color::Black);
   SolidBrush^ myBrush = gcnew SolidBrush( Black );
   if (x!=0 $$ y!=0)
   {
       CallerGDI-> FillRectangle(myBrush,x,y,1,1); //draw point

   };


但是我的程序只能绘制第一个点,我是否缺少某些东西

p.s实际上x和y是来自串行端口的信号


But my program can only plot the first point, am I missing something

p.s Actually x and y are signals come from a serial port

推荐答案

y!= 0) { 呼叫者GDI-> FillRectangle(myBrush,x,y,1,1); //画点 };
y!=0) { CallerGDI-> FillRectangle(myBrush,x,y,1,1); //draw point };


但是我的程序只能绘制第一个点,我是否缺少某些东西

p.s实际上x和y是来自串行端口的信号


But my program can only plot the first point, am I missing something

p.s Actually x and y are signals come from a serial port


您发布的代码正在绘制一个像素.那是您的项目的工作部分.

计时器函数或循环为x和y计算新值的地方在哪里?
Your posted code is painting one pixel. That is the working part of your project.

And where ist the timer function or the loop computing new values for x and y?


您的绘图函数每次应绘制整个图形(即一组点或线).叫.因此,您必须存储读取的点,适当地缩放比例,然后绘制所有的点(或至少固定数量的最新点).

是的,您可以使用数组来存储读取的值.

请修改您的原始帖子,以添加虚假答案.
:)
Your plotting function should draw the entire graph (i.e. a set of points -or lines-) each time is called. Hence you have to store the read points, scale properly and then plot all of them (or, at least, a fixed number of most recent ones).

And yes, you may use an array to store read values.

Please modify your original post, insted of adding fake answers.
:)


这篇关于如何使用C ++绘制路径? (动画图绘制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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