use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class ECollideFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// eCollide by Michael Faber, http://michaelfaber.deviantart.com/art/eSeries-306044892
double tmp = pAffineTP.y * pAffineTP.y + pAffineTP.x * pAffineTP.x + 1.0;
double tmp2 = 2.0 * pAffineTP.x;
double xmax = (sqrt_safe(tmp + tmp2) + sqrt_safe(tmp - tmp2)) * 0.5;
double sinnu, cosnu;
int alt;
if (xmax < 1.0)
xmax = 1.0;
double t = pAffineTP.x / xmax;
if (t > 1.0)
t = 1.0;
else if (t < -1.0)
t = -1.0;
// -Pi < nu < Pi
double nu = acos(t);
alt = (int) (nu * _eCn_pi);
if (alt % 2 == 0)
nu = alt * _pi_eCn + fmod(nu + _eCa_eCn, _pi_eCn);
else
nu = alt * _pi_eCn + fmod(nu - _eCa_eCn, _pi_eCn);
if (pAffineTP.y <= 0.0)
nu *= -1.0;
sinnu = sin(nu);
cosnu = cos(nu);
pVarTP.x += pAmount * xmax * cosnu;
pVarTP.y += pAmount * sqrt(xmax - 1.0) * sqrt(xmax + 1.0) * sinnu;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class CrackleFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
double DXo, DYo, L, R, s, trgL;
double[] U = new double[2];
int XCv, YCv;
// An infinite number of invisible cells? No thanks!
if (0.0 == cellsize) {
return;
}
// Scaling factor
s = cellsize / 2.0;
if (pAmount != 0) {
// For a blur effect, base everything starting on a circle radius 1.0
// (as opposed to reading the values from FTx and FTy)
double blurr = (pContext.random() + pContext.random()) / 2.0 + (pContext.random() - 0.5) / 4.0;
double theta = 2 * M_PI * pContext.random();
U[_x_] = blurr * sin(theta);
U[_y_] = blurr * cos(theta);
} else {
// pAmount=0, so color only (DC versions; won't affect normal one); don't blur
U[_x_] = pAffineTP.x;
U[_y_] = pAffineTP.y;
}
// Use integer values as Voronoi grid co-ordinates
XCv = (int) floor(U[_x_] / s);
YCv = (int) floor(U[_y_] / s);
// Get a set of 9 square centre points, based around the one above
int di, dj;
int i = 0;
for (di = -1; di < 2; di++) {
for (dj = -1; dj < 2; dj++) {
cached_position(C, XCv + di, YCv + dj, z, s, distort, P[i]);
i++;
}
}
int q = closest(P, 9, U);
int[][] offset = new int[][] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 0 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
// Remake list starting from chosen square, ensure it is completely surrounded (total 9 points)
// First adjust centres according to which one was found to be closest
XCv += offset[q][_x_];
YCv += offset[q][_y_];
// Get a new set of 9 square centre points, based around the definite closest point
i = 0;
for (di = -1; di < 2; di++) {
for (dj = -1; dj < 2; dj++) {
cached_position(C, XCv + di, YCv + dj, z, s, distort, P[i]);
i++;
}
}
// index 4 is centre cell
L = voronoi(P, 9, 4, U);
// Delta vector from centre
DXo = U[_x_] - P[4][_x_];
DYo = U[_y_] - P[4][_y_];
// ///////////////////////////////////////////////////////////////
// Apply "interesting bit" to cell's DXo and DYo co-ordinates
// trgL is the new value of L
// ( 0.9 )
trgL = pow(L + 1e-100, power) * scale;
R = trgL / (L + 1e-100);
DXo *= R;
DYo *= R;
// Add cell centre co-ordinates back in
DXo += P[4][_x_];
DYo += P[4][_y_];
// Finally add values in
applyCellCalculation(pVarTP, pAmount, DXo, DYo, L);
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class RecurrencePlotFunc method transform.
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
int i, j;
double dist, x, y;
i = (int) ((N) * pContext.random());
j = (int) ((N) * pContext.random());
if (id == 0) {
y1 = 50 * sin(i * 4 * M_PI / (1 * N)) + 25 * sin(i * 40 * M_PI / (1 * N));
y2 = 50 * sin(j * 4 * M_PI / (1 * N)) + 25 * sin(j * 40 * M_PI / (1 * N));
} else if (id == 1) {
y1 = 10 * sin(i * 5 * M_PI / (1 * N)) * 5 * sin(i * 15 * M_PI / (1 * N));
y2 = 10 * sin(j * 5 * M_PI / (1 * N)) * 5 * sin(j * 15 * M_PI / (1 * N));
} else if (id == 2) {
y1 = 50 * cos(i * 24 * M_PI / (1 * N) + 5 * sin(i * 6 * M_PI / (1 * N)));
y2 = 50 * cos(j * 24 * M_PI / (1 * N) + 5 * sin(j * 6 * M_PI / (1 * N)));
} else if (id == 3) {
y1 = 50 * sin(i * 20 * M_PI / (1 * N)) + 50 * sin(i * 22 * M_PI / (1 * N) + M_PI);
y2 = 50 * sin(j * 20 * M_PI / (1 * N)) + 50 * sin(j * 22 * M_PI / (1 * N) + M_PI);
} else if (id == 4) {
y1 = 50 * sin(i * 20 * M_PI / (1 * N)) + 10 * sin(i * 22 * M_PI / (1 * N));
y2 = 50 * sin(j * 20 * M_PI / (1 * N)) + 10 * sin(j * 22 * M_PI / (1 * N));
} else if (id == 5) {
y1 = 50 * sin(i * a * M_PI / (1 * N) + 1 * sin(i * a * M_PI / (1 * N)));
y2 = 50 * sin(j * a * M_PI / (1 * N) + 1 * sin(j * a * M_PI / (1 * N)));
} else if (// Sigmoid Function
id == 6) {
y1 = F6(i);
y2 = F6(j);
} else if (id == 7) {
y1 = (400 / M_PI) * (sin(i * M_PI / (0.5 * N)) + sin(i * 3 * M_PI / (0.5 * N)) / 3.0 + sin(i * 5 * M_PI / (0.5 * N)) / 5.0 + sin(i * 7 * M_PI / (0.5 * N)) / 7.0);
y2 = (400 / M_PI) * (sin(j * M_PI / (0.5 * N)) + sin(j * 3 * M_PI / (0.5 * N)) / 3.0 + sin(j * 5 * M_PI / (0.5 * N)) / 5.0 + sin(j * 7 * M_PI / (0.5 * N)) / 7.0);
} else if (id == 8) {
y1 = (400 / M_PI * M_PI) * (sin(i * M_PI / (0.5 * N)) - sin(i * 3 * M_PI / (0.5 * N)) / 9.0 + sin(i * 5 * M_PI / (0.5 * N)) / 25.0 - sin(i * 7 * M_PI / (0.5 * N)) / 49.0);
y2 = (400 / M_PI * M_PI) * (sin(j * M_PI / (0.5 * N)) - sin(j * 3 * M_PI / (0.5 * N)) / 9.0 + sin(j * 5 * M_PI / (0.5 * N)) / 25.0 - sin(j * 7 * M_PI / (0.5 * N)) / 49.0);
} else if (// tanh(a*x*M_PI)
id == 9) {
// y1=(400/M_PI*M_PI)*( sin(i*M_PI/(0.5*N)) - sin(i*3*M_PI/(0.5*N))/9.0 + sin(i*5*M_PI/(0.5*N))/25.0 );
// y2=(400/M_PI*M_PI)*( sin(j*M_PI/(0.5*N)) - sin(j*3*M_PI/(0.5*N))/9.0 + sin(j*5*M_PI/(0.5*N))/25.0 );
y1 = tanh(a * i * M_PI / N);
y2 = tanh(a * j * M_PI / N);
} else if (// tan(a* x * PI)
id == 10) {
// y1=(400/M_PI*M_PI)*( sin(i*M_PI/(0.5*N)) - sin(i*3*M_PI/(0.5*N))/9.0 );
// y2=(400/M_PI*M_PI)*( sin(j*M_PI/(0.5*N)) - sin(j*3*M_PI/(0.5*N))/9.0 );
y1 = tan(a * i * M_PI / N);
y2 = tan(a * j * M_PI / N);
} else if (id == 11) {
y1 = (-200 / M_PI) * (sin(i * M_PI / (0.5 * N)) + sin(i * 2 * M_PI / (0.5 * N)) / 2.0 + sin(i * 3 * M_PI / (0.5 * N)) / 3.0 + sin(i * 4 * M_PI / (0.5 * N)) / 4.0 + sin(i * 5 * M_PI / (0.5 * N)) / 5.0 + sin(i * 6 * M_PI / (0.5 * N)) / 6.0 + sin(i * 7 * M_PI / (0.5 * N)) / 7.0 + sin(i * 8 * M_PI / (0.5 * N)) / 8.0);
y2 = (-200 / M_PI) * (sin(j * M_PI / (0.5 * N)) + sin(j * 2 * M_PI / (0.5 * N)) / 2.0 + sin(j * 3 * M_PI / (0.5 * N)) / 3.0 + sin(j * 4 * M_PI / (0.5 * N)) / 4.0 + sin(j * 5 * M_PI / (0.5 * N)) / 5.0 + sin(j * 6 * M_PI / (0.5 * N)) / 6.0 + sin(j * 7 * M_PI / (0.5 * N)) / 7.0 + sin(j * 8 * M_PI / (0.5 * N)) / 8.0);
} else if (id == 12) {
y1 = 50 * sin(i * 40 * M_PI / (1 * N)) + 50 * sin(i * 44 * M_PI / (1.0 * N));
y2 = 50 * sin(j * 40 * M_PI / (1 * N)) + 50 * sin(j * 44 * M_PI / (1.0 * N));
} else if (id == 13) {
y1 = 50 * sin(i * 40 * M_PI / (1 * N)) + 50 * sin(i * 44 * M_PI / (1.0 * N) + M_PI);
y2 = 50 * sin(j * 40 * M_PI / (1 * N)) + 50 * sin(j * 44 * M_PI / (1.0 * N) + M_PI);
} else if (id == 14) {
y1 = 100 * sin(i * 16 * M_PI / (1 * N)) - 500 + i * 0.25;
y2 = 100 * sin(j * 16 * M_PI / (1 * N)) - 500 + j * 0.25;
} else if (id == 15) {
y1 = 100 * sin(i * 16 * M_PI / (1 * N));
y2 = 100 * sin(j * 16 * M_PI / (1 * N));
} else if (// casi igual =15
id == 16) {
// y1=100*sin(i*16*M_PI/(1*N))-5+i*0.0025;
// y2=100*sin(j*16*M_PI/(1*N))-5+j*0.0025;
y1 = 1.0 / cos(i * a * M_PI / N);
y2 = 1.0 / cos(j * a * M_PI / N);
} else if (id == 17) {
y1 = 50 * cos(i * 2 * M_PI * 25 / (1 * N) + 25 * sin(i * 2 * M_PI * 0.50 / (1 * N)));
y2 = 50 * cos(j * 2 * M_PI * 25 / (1 * N) + 25 * sin(j * 2 * M_PI * 0.50 / (1 * N)));
} else if (id == 18) {
// a=5;// b=18;
y1 = a * exp(-b * (2.0 * a * i / N - a) * (2.0 * a * i / N - a));
y2 = a * exp(-b * (2.0 * a * j / N - a) * (2.0 * a * j / N - a));
} else if (id == 19) {
y1 = 500 * sin(i * 10 * M_PI / (N)) * exp(-5.0 * i / N);
y2 = 500 * sin(j * 10 * M_PI / (N)) * exp(-5.0 * j / N);
} else if (id == 20) {
y1 = 500 * sin(i * 20 * M_PI / (N)) * exp(-3.0 * i / N);
y2 = 500 * sin(j * 20 * M_PI / (N)) * exp(-3.0 * j / N);
} else if (id == 21) {
y1 = 50 * tan(i * 2 * M_PI / (1 * N));
y2 = 50 * tan(j * 2 * M_PI / (1 * N));
} else if (id == 22) {
// a=490; // b=10;
y1 = F22(i, (int) b);
y2 = F22(j, (int) b);
} else if (id == 23) {
// a=500.0;b=2.0;k=5;
y1 = F23(i, k);
y2 = F23(j, k);
} else if (id == 24) {
// a=500.0;b=1.0;k=5;
y1 = F24(i, k);
y2 = F24(j, k);
} else if (id == 25) {
// a=500.0;b=1.0;k=5;
y1 = F25(i, k);
y2 = F25(j, k);
} else if (id == 26) {
// a=90.0;b=1.0;k=5;
y1 = F26(i, k);
y2 = F26(j, k);
} else if (id == 27) {
// a=1.0;b=10.0;
y1 = F27(i);
y2 = F27(j);
} else if (id == 28) {
// a=1.0;b=10.0;k=2;
y1 = F28(i);
y2 = F28(j);
} else if (id == 29) {
// a=475;k=5;
y1 = F29(i, k);
y2 = F29(j, k);
}
dist = sqrt((y1 - y2) * (y1 - y2));
if (dist < maxdist) {
x = i / N - 0.5;
y = j / N - 0.5;
pVarTP.x += pAmount * (x);
pVarTP.y += pAmount * (y);
oldx = pVarTP.x;
oldy = pVarTP.y;
if (dc != 0) {
double s = sin(angle);
double c = cos(angle);
if (dc == 1)
pVarTP.color = fmod(fabs(0.5 * ldcs * pVarTP.x * pVarTP.y + offset), 1.0);
if (dc == 2)
pVarTP.color = fmod(fabs(0.5 * (ldcs * ((c * pVarTP.x + s * pVarTP.y + offset)) + 1.0)), 1.0);
}
} else {
pVarTP.x = oldx;
pVarTP.y = oldy;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class TextWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
List<Point> points = getPoints();
final double DFLT_SCALE = 3.0;
if (points.size() > 1) {
Point point = points.get(pContext.random(points.size()));
double rawX = point.getX();
double rawY = point.getY();
if (antialias > 0.01) {
double dr = (exp(antialias * sqrt(-log(pContext.random()))) - 1.0) * 0.001;
double da = pContext.random() * 2.0 * M_PI;
rawX += dr * cos(da);
rawY += dr * sin(da);
}
pVarTP.x += (rawX * scale_x + offset_x) * DFLT_SCALE;
pVarTP.y += (rawY * scale_y + offset_y) * DFLT_SCALE;
} else {
pVarTP.x += pContext.random();
pVarTP.y += pContext.random();
pVarTP.rgbColor = true;
pVarTP.redColor = 0;
pVarTP.greenColor = 0;
pVarTP.blueColor = 0;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class PreStabilizeFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
if (start || pContext.random() < p / 1000) {
start = false;
int i = pContext.random(n);
pAffineTP.x = x[i];
pAffineTP.y = y[i];
pAffineTP.z = 0;
if (dc != 0)
pAffineTP.color = c[i];
}
}
Aggregations