brin
YaBB Newbies
Offline
Posts: 13
point = barrier for curve colour
Sep 14th , 2006, 7:26pm
Hi, i am trying to make a curve change its color. A point that moves from one end to the other, is to function as a "barrier": from start point of the curve to the moving point show color A, from the moving point to endpoint of the curve show color B. 1. So far, the point (shown by an ellipse) doesn´t move. 2. I don´t get that curve change its color at the moving point. I´d appreciate any help. Here´s the code: position path[]=new position[9]; void setup() { size(400,400); stroke (255); path=new position[9]; for(int i=0; i<path.length; i++) { path[0]= new position (100,100); path[1]= new position (100,100); path[2]= new position (170,200); //stroke(0,255,0); path[3]= new position (300,150); path[4]= new position (390,20); path[5]= new position (25,370); path[6]= new position (150,200); path[7]= new position (200,50); path[8]= new position (200,50); } } void draw() { background(0); beginShape(LINE_STRIP); for(int i=0;i<path.length;i++) { //stroke(0,255,0); curveVertex(path[0].x,path[0].y); curveVertex(path[1].x,path[1].y); curveVertex(path[2].x,path[2].y); curveVertex(path[3].x,path[3].y); //stroke(255,0,0); curveVertex(path[4].x,path[4].y); curveVertex(path[5].x,path[5].y); //stroke(0,0,255); curveVertex(path[6].x,path[6].y); curveVertex(path[7].x,path[7].y); curveVertex(path[8].x,path[8].y); //stroke (255); //ellipse(path[i].x,path[i].y,5,5); break; } endShape(); position cp=new position(path[1]); for (int i = 0; i< path.length; i++) { float t = .01 ; cp=new position(curvePoint(path[i].x,path[i+1].x,path[i+2].x,path[i+3].x,t),curvePoint(path[i].y,path[i+1].y,path[i+2].y,path[i+3].y,t)); break; } cp.x += cp.x; cp.y += cp.y; noFill(); stroke(255,0,0); ellipse(cp.x,cp.y,10,10); stroke(255); } class position //position class that stores 2 values x and y { float x,y; position(){} position(float tx,float ty) { x=(tx); y=(ty); } position(position p) { if(p!=null) { x=p.x; y=p.y; } } } Thanks in advance brin