public int m; public double n1; public double n2; public double n3; public double scale; public double NP; int NUMS = 4; // Number of sliders HSlide[] hs = new HSlide[NUMS]; BFont fontA; class HSlide { // HSlide class by Casey Reas int swidth, sheight; // width and height of bar int xpos, ypos; // x and y position of bar float spos, newspos; // x position of slider int sposMin, sposMax; // max and min values of slider int loose; // how loose/heavy boolean over; // is the mouse over the slider? boolean locked; HSlide (int xp, int yp, int sw, int sh, int l) { swidth = sw; sheight = sh; xpos = xp; ypos = yp-sheight/2; spos = xpos + swidth/2 - sheight/2; newspos = spos; sposMin = xpos; sposMax = xpos + swidth - sheight; loose = l; } void update() { if(over()) { over = true; } else { over = false; } if(mousePressed && over) { locked = true; } if(!mousePressed) { locked = false; } if(locked) { newspos = constrain(mouseX-sheight/2, sposMin, sposMax); } if(abs(newspos - spos) > 1) { spos = spos + (newspos-spos)/loose; } } int constrain(int val, int minv, int maxv) { return min(max(val, minv), maxv); } boolean over() { if(mouseX > xpos && mouseX < xpos+swidth && mouseY > ypos && mouseY < ypos+sheight) { return true; } else { return false; } } void draw() { fill(255); rect(xpos, ypos, swidth, sheight); if(over || locked) { fill(0, 153, 204); } else { fill(0, 102, 153); } rect(spos, ypos, sheight, sheight); } } int blend(int org, int col, int alpha) { int r1=(org&0x0000ff); int g1=(org&0x00ff00); int b1=(org&0xff0000); int r2=(col&0x0000ff); int g2=(col&0x00ff00); int b2=(col&0xff0000); int r3=(((alpha*(r1-r2)) >>8 )+r2)&0x000000ff; int g3=(((alpha*(g1-g2)) >>8 )+g2)&0x0000ff00; int b3=(((alpha*(b1-b2)) >>8 )+b2)&0x00ff0000; return (r3)|(g3)|(b3); } void aapixel(float ax, float ay, int col, int alp) { int x = (int)ax; int y = (int)ay; if(x <= 0 || x >= width || y <= 0 || y >= height-2) return; float fx = 0, fy = 0; y = (int)ay; fx = ax - x; fy = ay - y; int u = x+y*width; pixels[u] = blend(col, pixels[u], (int)((1-fx)*(1-fy)*alp)); pixels[u+1] = blend(col, pixels[u+1], (int)((fx)*(1-fy)*alp)); pixels[u+width] = blend(col, pixels[u+width], (int)((1-fx)*(fy)*alp)); pixels[u+width+1] = blend(col, pixels[u+width+1], (int)((fx)*(fy)*alp)); } void Eval(double m,double n1,double n2,double n3,double phi,double x,double y) { double f[]; double r; double t1,t2; double a=1,b=1; t1 = Math.cos(float(m * phi / 4)) / a; t1 = Math.abs(t1); t1 = Math.pow(t1,n2); t2 = Math.sin(float(m * phi / 4)) / b; t2 = Math.abs(t2); t2 = Math.pow(t2,n3); r = Math.pow(t1+t2,1/n1); if (Math.abs(r) == 0) { x = 0; y = 0; } else { r = 1 / r; x = r * Math.cos(phi); y = r * Math.sin(phi); } aapixel(width/2+(float)(x*scale), height/2+(float)(y*scale),0xff000000,128); } void setup() { size(500,500); background(#ffffff); for (int i=0; i