use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.
the class PlaneWFFunc method getUVColorIdx.
private double getUVColorIdx(int pR, int pG, int pB) {
RenderColor pColor = new RenderColor(pR, pG, pB);
Double res = uvIdxMap.get(pColor);
if (res == null) {
int nearestIdx = 0;
RenderColor color = uvColors[0];
double dr, dg, db;
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double nearestDist = sqrt(dr * dr + dg * dg + db * db);
for (int i = 1; i < uvColors.length; i++) {
color = uvColors[i];
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double dist = sqrt(dr * dr + dg * dg + db * db);
if (dist < nearestDist) {
nearestDist = dist;
nearestIdx = i;
}
}
res = (double) nearestIdx / (double) (uvColors.length - 1);
uvIdxMap.put(pColor, res);
}
return res;
}
use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.
the class ParPlot2DWFFunc method getUVColorIdx.
private double getUVColorIdx(int pR, int pG, int pB) {
RenderColor pColor = new RenderColor(pR, pG, pB);
Double res = uvIdxMap.get(pColor);
if (res == null) {
int nearestIdx = 0;
RenderColor color = uvColors[0];
double dr, dg, db;
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double nearestDist = sqrt(dr * dr + dg * dg + db * db);
for (int i = 1; i < uvColors.length; i++) {
color = uvColors[i];
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double dist = sqrt(dr * dr + dg * dg + db * db);
if (dist < nearestDist) {
nearestDist = dist;
nearestIdx = i;
}
}
res = (double) nearestIdx / (double) (uvColors.length - 1);
uvIdxMap.put(pColor, res);
}
return res;
}
use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.
the class UVColorMapper method getUVColorIdx.
public double getUVColorIdx(int pR, int pG, int pB) {
RenderColor pColor = new RenderColor(pR, pG, pB);
Double res = uvIdxMap.get(pColor);
if (res == null) {
int nearestIdx = 0;
RenderColor color = uvColors[0];
double dr, dg, db;
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double nearestDist = sqrt(dr * dr + dg * dg + db * db);
for (int i = 1; i < uvColors.length; i++) {
color = uvColors[i];
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double dist = sqrt(dr * dr + dg * dg + db * db);
if (dist < nearestDist) {
nearestDist = dist;
nearestIdx = i;
}
}
res = (double) nearestIdx / (double) (uvColors.length - 1);
uvIdxMap.put(pColor, res);
}
return res;
}
use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.
the class IsoSFPlot3DWFFunc method getUVColorIdx.
private double getUVColorIdx(int pR, int pG, int pB) {
RenderColor pColor = new RenderColor(pR, pG, pB);
Double res = uvIdxMap.get(pColor);
if (res == null) {
int nearestIdx = 0;
RenderColor color = uvColors[0];
double dr, dg, db;
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double nearestDist = sqrt(dr * dr + dg * dg + db * db);
for (int i = 1; i < uvColors.length; i++) {
color = uvColors[i];
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double dist = sqrt(dr * dr + dg * dg + db * db);
if (dist < nearestDist) {
nearestDist = dist;
nearestIdx = i;
}
}
res = (double) nearestIdx / (double) (uvColors.length - 1);
uvIdxMap.put(pColor, res);
}
return res;
}
use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.
the class AbstractDisplacementMapWFFunc method getColorIdx.
private double getColorIdx(double pR, double pG, double pB) {
RenderColor pColor = new RenderColor(pR, pG, pB);
Double res = colorIdxMap.get(pColor);
if (res == null) {
int nearestIdx = 0;
RenderColor color = renderColors[0];
double dr, dg, db;
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double nearestDist = sqrt(dr * dr + dg * dg + db * db);
for (int i = 1; i < renderColors.length; i++) {
color = renderColors[i];
dr = (color.red - pR);
dg = (color.green - pG);
db = (color.blue - pB);
double dist = sqrt(dr * dr + dg * dg + db * db);
if (dist < nearestDist) {
nearestDist = dist;
nearestIdx = i;
}
}
res = (double) nearestIdx / (double) (renderColors.length - 1);
colorIdxMap.put(pColor, res);
}
return res;
}
Aggregations