import megamu.shapetween.*; Shaper cosine; void setup(){ size(200,200); cosine = new CosineShaper(Shaper.IN); } void draw(){ background(255); beginShape(); for( float i=0; i<=1; i+= 0.05 ) vertex( i*width, cosine.shape( i )*height ); endShape(); stroke(255,0,0); float x = norm( mouseX, 0, width ); float y = cosine.shape( x ); float m = cosine.slope( x ); println(m); line(width*(x-1), height*(y-m), width*(x+1), height*(y+m)); }
slope(in)