use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class AbstractFractWFFunc method transformBuddhabrot.
public void transformBuddhabrot(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
Iterator iterator = getIterator();
double x0, y0;
if (chooseNewPoint) {
while (true) {
x0 = (xmax - xmin) * pContext.random() + xmin;
y0 = (ymax - ymin) * pContext.random() + ymin;
if (iterator.preBuddhaIterate(x0, y0, max_iter)) {
break;
}
}
chooseNewPoint = false;
iterator.init(x0, y0);
for (int skip = 0; skip < buddhabrot_min_iter; skip++) {
iterator.nextIteration();
}
}
iterator.nextIteration();
if (iterator.currIter >= iterator.maxIter) {
chooseNewPoint = true;
}
pVarTP.x += scale * pAmount * (iterator.currX + offsetx);
pVarTP.y += scale * pAmount * (iterator.currY + offsety);
pVarTP.color += (double) iterator.currIter / (double) iterator.maxIter;
if (pVarTP.color < 0)
pVarTP.color = 0;
else if (pVarTP.color > 1.0)
pVarTP.color = 1.0;
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class ApocarpetFunc method transform.
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// Apolonian Carpet Reference:
// http://paulbourke.net/fractals/kissingcircles/roger17.c
double x = 0, y = 0;
double r = 1.0 / (1.0 + MathLib.sqrt(2.0));
double denom = pAffineTP.x * pAffineTP.x + pAffineTP.y * pAffineTP.y;
int weight = (int) (6.0 * pContext.random());
switch(weight) {
case 0:
x = 2.0 * pAffineTP.x * pAffineTP.y / denom;
y = (pAffineTP.x * pAffineTP.x - pAffineTP.y * pAffineTP.y) / denom;
break;
case 1:
x = pAffineTP.x * r - r;
y = pAffineTP.y * r - r;
break;
case 2:
x = pAffineTP.x * r + r;
y = pAffineTP.y * r + r;
break;
case 3:
x = pAffineTP.x * r + r;
y = pAffineTP.y * r - r;
break;
case 4:
x = pAffineTP.x * r - r;
y = pAffineTP.y * r + r;
break;
case 5:
x = (pAffineTP.x * pAffineTP.x - pAffineTP.y * pAffineTP.y) / denom;
y = 2.0 * pAffineTP.x * pAffineTP.y / denom;
break;
}
pVarTP.x += x * pAmount;
pVarTP.y += y * pAmount;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
// pVarTP.color = fmod(fabs( (sqr(pVarTP.x) + sqr(pVarTP.y ))), 1.0);
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class ApollonyFunc method transform.
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// Apollony IFS Reference:
// http://paulbourke.net/fractals/apollony/apollony.c
double x, y, a0, b0, f1x, f1y;
double r = Math.sqrt(3.0);
a0 = 3.0 * (1.0 + r - pAffineTP.x) / (Math.pow(1.0 + r - pAffineTP.x, 2.0) + pAffineTP.y * pAffineTP.y) - (1.0 + r) / (2.0 + r);
b0 = 3.0 * pAffineTP.y / (Math.pow(1.0 + r - pAffineTP.x, 2.0) + pAffineTP.y * pAffineTP.y);
f1x = a0 / (a0 * a0 + b0 * b0);
f1y = -b0 / (a0 * a0 + b0 * b0);
int w = (int) (4.0 * Math.random());
if ((w % 3) == 0) {
x = a0;
y = b0;
} else if ((w % 3) == 1) {
x = -f1x / 2.0 - f1y * r / 2.0;
y = f1x * r / 2.0 - f1y / 2.0;
} else {
x = -f1x / 2.0 + f1y * r / 2.0;
y = -f1x * r / 2.0 - f1y / 2.0;
}
pVarTP.x += x * pAmount;
pVarTP.y += y * pAmount;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class CircleTrans1Func method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
/* CircleTrans1 by eralex, http://eralex61.deviantart.com/art/Circles-Plugins-126273412 */
double U, X, Y;
int M, N;
vec2 Uxy = new vec2();
Trans(this.X, this.Y, pAffineTP.x, pAffineTP.y, Uxy);
M = (int) floor(0.5 * Uxy.x / this.Sc);
N = (int) floor(0.5 * Uxy.y / this.Sc);
X = Uxy.x - (M * 2 + 1) * this.Sc;
Y = Uxy.y - (N * 2 + 1) * this.Sc;
U = sqrt(X * X + Y * Y);
if (!((DiscretNoise2(M + this.Seed, N) > this.Dens) || (U > (0.3 + 0.7 * DiscretNoise2(M + 10, N + 3)) * this.Sc))) {
CircleR(pContext, Uxy);
}
pVarTP.x += pAmount * Uxy.x;
pVarTP.y += pAmount * Uxy.y;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class AbstractDisplacementMapWFFunc method transform.
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount, double pInputX, double pInputY) {
double x = (pInputX - (offsetX + 0.5) + 1.0) / scaleX * (double) (imgWidth - 1);
double y = (pInputY - (offsetY + 0.5) + 1.0) / scaleY * (double) (imgHeight - 1);
int ix = Tools.FTOI(x);
int iy = Tools.FTOI(y);
if (this.tileX == 1) {
if (ix < 0) {
int nx = ix / imgWidth - 1;
ix -= nx * imgWidth;
} else if (ix >= imgWidth) {
int nx = ix / imgWidth;
ix -= nx * imgWidth;
}
}
if (this.tileY == 1) {
if (iy < 0) {
int ny = iy / imgHeight - 1;
iy -= ny * imgHeight;
} else if (iy >= imgHeight) {
int ny = iy / imgHeight;
iy -= ny * imgHeight;
}
}
double r, g, b;
if (ix >= 0 && ix < imgWidth && iy >= 0 && iy < imgHeight) {
if (colorMap instanceof SimpleImage) {
toolPixel.setARGBValue(((SimpleImage) colorMap).getARGBValue(ix, iy));
r = (double) toolPixel.r / 255.0;
g = (double) toolPixel.g / 255.0;
b = (double) toolPixel.b / 255.0;
} else {
((SimpleHDRImage) colorMap).getRGBValues(rgbArray, ix, iy);
r = rgbArray[0];
g = rgbArray[0];
b = rgbArray[0];
}
} else {
return;
}
switch(mode) {
case MODE_TRANSLATE:
{
double amountX = (r - 0.5) * pAmount;
double amountY = (g - 0.5) * pAmount;
pVarTP.x += amountX;
pVarTP.y += amountY;
}
break;
case MODE_SCALE:
{
double intensity = calcIntensity(r, g, b) - bias;
if (intensity > 0.0) {
double scl = 1.0 + (intensity - 0.5) * pAmount;
pVarTP.x *= scl;
pVarTP.y *= scl;
}
}
break;
case MODE_SCISSOR:
{
double amountX = (r - 0.5) * pAmount;
double amountY = (g - 0.5) * pAmount;
double newx = pVarTP.x * amountX * amountY + pVarTP.y * amountY;
double newy = pVarTP.x * amountY - pVarTP.y * amountX * amountY;
pVarTP.x = newx;
pVarTP.y = newy;
}
break;
case MODE_ROTATE:
default:
{
double intensity = calcIntensity(r, g, b) - bias;
if (intensity > 0.0) {
double angle = intensity * M_2PI * pAmount;
double sina = sin(angle);
double cosa = cos(angle);
double xnew = pVarTP.x * cosa - pVarTP.y * sina;
double ynew = pVarTP.x * sina + pVarTP.y * cosa;
pVarTP.x = xnew;
pVarTP.y = ynew;
}
}
}
switch(colorMode) {
case COLOR_MODE_INHERIT:
{
pVarTP.rgbColor = true;
pVarTP.redColor = r;
pVarTP.greenColor = g;
pVarTP.blueColor = b;
pVarTP.color = getColorIdx(r, g, b);
}
break;
default:
// nothing to do
break;
}
}
Aggregations