Search in sources :

Example 6 with RenderColor

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;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 7 with RenderColor

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;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 8 with RenderColor

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;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor)

Example 9 with RenderColor

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;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 10 with RenderColor

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;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Aggregations

RenderColor (org.jwildfire.create.tina.palette.RenderColor)10 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)9