0
所以我有这样的代码,其从阵列获取数据,并绘制曲线:如何查找曲线上的点并显示它们?
void drawDataLine(int row) {
beginShape();
for (int col = 0; col < colCount; col++) {
if (data.isValid(row, col)) {
float value = data.getPoint(row, col);
float x = map(years[col], yearMin, yearMax, plotX1, plotX2);
float y = map(value, dataMin, dataMax, plotY2, plotY1);
//vertex(x,y) ;
curveVertex(x, y);
// Double the curve points for the start and stop
if ((col == 0) || (col == colCount-1)) {
curveVertex(x, y);
}
}
}
endShape();
}
我有当光标内3个像素的点的,其显示数据值的另一个函数:
for (int col = 0; col < colCount; col++) {
if (data.isValid(row, col)) {
float radVal = ratio[col];
float value = data.getPoint(row, col);
float compareValue = compare.getPoint(row, col);
float x = map(years[col], yearMin, yearMax, plotX1, plotX2);
float y = map(value, dataMin, dataMax, plotY2, plotY1);
float ellipse1MapVal = map(value, ellipse1Min, ellipse1Max, 10, 80);
float ellipse2MapVal = map(compareValue, ellipse1Min, ellipse1Max, 10, 80);
radVal = map(radVal, radMin, radMax, 1, 7);
if (dist(mouseX, mouseY, x, y) < 3) {
if (drawCirclesPrimary || drawCirclesSecondary) {
noStroke();
if (drawCirclesPrimary) {
fill(0, 255, 0, 100);
ellipse(x, y, ellipse1MapVal, ellipse1MapVal);
}
if (drawCirclesSecondary) {
fill(255, 0, 0, 100);
ellipse(x, y, ellipse2MapVal, ellipse2MapVal);
}
fill(0);
stroke(0);
pushMatrix();
translate(x, y);
rotate(radians(radSec));
line(0, -ellipse1MapVal/2, 0, ellipse1MapVal/2);
popMatrix();
radSec += radVal;
textSize(10);
textAlign(CENTER);
text(nf(value, 0, 2) + " (" + years[col] + ")"+nf(compareValue, 0, 2), x, y-8);
}
else
text(nf(value, 0, 2) + " (" + years[col] + ")", x, y-8);
}
if ((mouseX < x+3)&&(mouseX > x-3))
{
stroke(150);
strokeWeight(1);
line(x, plotY1, x, plotY2);
} } }}
现在的问题是,curveVertex做它的插值,并做出很好的曲线,但我不能得到除我已经有的曲线以外的曲线上的点。我想要的是光标显示图上所有点上的值,而不是我在数组上的10个点,就像谷歌或雅虎财经上的图表一样。当谈到处理时,我是一个noob,因此任何帮助都将不胜感激。
问候