我想使用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,因此信号的长度有效地被压缩。是否可以通过简单地使用浮点数来实现这一点我需要实际创建一个更大的画布并在那里进行缩放?
提前感谢您的帮助。
答案 0 :(得分:2)
错误,要么将y分量乘以5,要么在path.moveTo和path.lineTo中将x分量除以5?