//———————————————————————-
// you need processing to run this code
// you can download processing from processing.org
//
//———————————————————————-
// hold mousekey pressed and move the mouse to change the image
//——————————————————————-
int breite, hoehe, groesse;
float[] farbe;
float shiftX, shiftY;
void setup() {
size(600, 600);
breite=50;
hoehe=breite;
groesse=breite*hoehe;
farbe=new float[groesse];
//—————————————————————–
// set suitable origin to begin
//————————————————
shiftX=10.01;
shiftY=5.4234;
}
void draw() {
startBild();
interpoliertZeigen();
if (mousePressed) {
shiftX-=float(mouseX-pmouseX)/width;
shiftY-=float(mouseY-pmouseY)/height;
}
}
void interpoliertZeigen() {
int iS, jS, jjS, indexS;
int iM, jM, jjM, indexM;
float x, y, dx, dy;
float f11, f12, f21, f22, f;
colorMode(HSB, 400, 100, 100);
loadPixels();
for (jS=0;jS<height;jS++) {
jjS=jS*width;
y=jS*float(hoehe-1)/height;
jM=int(y);
dy=y-jM;
jjM=jM*breite;
for (iS=0;iS<width;iS++) {
indexS=jjS+iS;
x=iS*float(breite-1)/width;
iM=int(x);
dx=x-iM;
indexM=iM+jjM;
f11=farbe[indexM];
f12=farbe[indexM+1];
f21=farbe[indexM+breite];
f22=farbe[indexM+1+breite];
f=(1-dy)*((1-dx)*f11+dx*f12)+dy*((1-dx)*f21+dx*f22);
pixels[indexS]=color(400*f, 100, 100);
}
}
updatePixels();
}
void startBild() {
int i, j, jj;
int k;
float x, y, z;
float scaleX, scaleY, scaleZ;
//———————————————————
// change scales to fit
//—————————————————
scaleX=4.;
scaleY=scaleX;
scaleZ=1.;
//———————————————————
for (j=0;j<hoehe;j++) {
jj=breite*j;
y=(2*(float(j)/hoehe)-1+shiftY)*scaleY; // y goes from scaleY(-1+shiftY) to scaleY*(1+shiftY)
for (i=0;i
x=(2*(float(i)/breite)-1+shiftX)*scaleX; // x goes from scaleY(-1+shiftY) to scaleY*(1+shiftY)
//—————————————————————————————-
// you may try other functions here, maybe you will have to adjust scales and origin
//———————————————————————————————-
z=x*x+y*y;
//——————————–
z=z*scaleZ;
farbe[i+jj]=z-floor(z);
}
}
}