Bifurcation tBifurcation; Slider tSlider; Verhulst tVerhulst; boolean drawn = false; PFont font; void setup() { // int h = screen.height; // h = (h - 50 - 30 ) /2; //h = 250; //println(h); // size(h, (h * 2)+30); size(600,330); int h = 300; background(240); font = loadFont("LucidaSansUnicode-9.vlw"); textFont(font); tBifurcation = new Bifurcation(h,30,h,h, 2.75, 4.0); tVerhulst = new Verhulst(0,30,h,h); tSlider = new Slider(h,0,h,30,10,0.5, 2.75, 4.0,h); } void draw(){ if(!drawn){ tBifurcation.display(); loadPixels(); drawn = true; } else{ updatePixels(); } tVerhulst.u = tSlider.value(); tVerhulst.display(); tSlider.display(); } class Verhulst{ float w; // single bar width float xpos; // rect xposition float h; // rect height float ypos ; // rect yposition float x = 0.1; float u = 3.5; int n = 0; float x0 = x; float x1 = 0; Verhulst(float x, float y, float ww, float hh) { w = ww; h= hh; xpos = x; ypos =y; } void calc(){ x1 = u * x0 * (1.0 - x0); } void plot(float y1,float y2){ // if (y1 == Float.NaN) return; //if (y2 == Float.NaN) return; smooth(); //fill(10); stroke(51); line((n*2)+xpos,h -(y1*h)+ypos,((n+1)*2)+xpos,h - (y2*h)+ ypos); n++; } void display(){ noStroke(); fill(255); rect(xpos,ypos,w,h); x0 = x = 0.1; while(n= sqrt(sq(xx - x) + sq(yy-y)); } void mousePressed(){ if(thumbCheck(mouseX, mouseY)){ dragging = true; offsetX = mouseX - xx; // offsetY = mouseY - yy; } } void mouseDragged(){ if(dragging){ float newX = mouseX + offsetX; if(newX < xpos) newX = xpos; if (newX > xpos + w) newX = xpos + w; xx = newX; normv = (newX - xpos)/ w; } //calcThumbCenter; } void mouseReleased(){ dragging = false; } } void mousePressed(){ tSlider.mousePressed(); } void mouseDragged(){ tSlider.mouseDragged(); } void mouseReleased(){ tSlider.mouseReleased(); }