使用 Path.lineTo 在 x 轴上增加一位小数

发布于 2024-12-01 01:58:32 字数 836 浏览 1 评论 0原文

我想使用 path.linTo 方法和 for 循环绘制信号波形,如下所示。

public void drawSignal(Canvas c, PointF pos) // draws the signal onto the Canvas for each of the 12 channels
{
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    paint.setStyle(Style.STROKE);

    Path path = new Path();

        for (int i=0; i<ECGFilereader.numChannels; i++){
            path.moveTo(wavePos[i].x, wavePos[i].y);

            for (int chan = 0; chan<ECGFilereader.numChannels; chan++)

                for (int m = 0; m < ECGFilereader.numSamples; m++){

                    path.lineTo(m+wavePos[i].x, signal[chan][m]+wavePos[i].y);
            }
        }

            c.drawPath(path, paint);

不过,我想缩放图表,使 x 轴上的每次移动仅为 y 轴移动的 1/5,从而有效地水平压缩信号的长度。是否可以通过简单地使用浮动来做到这一点,我是否需要实际创建一个更大的画布并将其缩放到那里?

预先感谢您的任何帮助。

I want to draw a signal waveform using the path.linTo method and a for loop as shown below.

public void drawSignal(Canvas c, PointF pos) // draws the signal onto the Canvas for each of the 12 channels
{
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    paint.setStyle(Style.STROKE);

    Path path = new Path();

        for (int i=0; i<ECGFilereader.numChannels; i++){
            path.moveTo(wavePos[i].x, wavePos[i].y);

            for (int chan = 0; chan<ECGFilereader.numChannels; chan++)

                for (int m = 0; m < ECGFilereader.numSamples; m++){

                    path.lineTo(m+wavePos[i].x, signal[chan][m]+wavePos[i].y);
            }
        }

            c.drawPath(path, paint);

However I would like to scale the graph so that each movement in the x-axis is only 1/5 of that of the y-axis, so that the length of the signal is effectively squashed horrizontally. Is it possible to do this by simply using floats somehow I do I need to actually create a larger canvas and scale it there?

Thanks in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

活雷疯 2024-12-08 01:58:32

错误,在 path.moveTo 和 path.lineTo 中将 y 分量乘以 5 或将 x 分量除以 5?

err, either multiply the y-components by 5 or divide the x-components by 5 in both path.moveTo and path.lineTo?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文