public int filterRGB(int x, int y, int rgb) { if ((x & 1) == (y & 1)) return rgb; return ImageMath.mixColors(0.25f, 0xff999999, rgb); }
public void crossDissolve(int[] pixels1, int[] pixels2, int width, int height, float t) { int index = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { pixels1[index] = ImageMath.mixColors(t, pixels1[index], pixels2[index]); index++; } } }
/** * Set a range of the colormap, interpolating between two colors. * @param firstIndex the position of the first color * @param lastIndex the position of the second color * @param color1 the first color * @param color2 the second color */ public void setColorRange(int firstIndex, int lastIndex, int color1, int color2) { for (int i = firstIndex; i <= lastIndex; i++) map[i] = ImageMath.mixColors((float)(i-firstIndex)/(lastIndex-firstIndex), color1, color2); }
private void makeSquare(int width, int[] outPixels, int rgb, int minSx, int maxSx, int minSy, int maxSy) { for (int x = minSx; x < maxSx; x++) { for (int y = minSy; y < maxSy; y++) { int offset = y * width + x; int rgb2 = outPixels[offset]; outPixels[offset] = ImageMath.mixColors(mix, rgb2, rgb); } } }
/** * Set a range of the colormap, interpolating between two colors. * * @param firstIndex the position of the first color * @param lastIndex the position of the second color * @param color1 the first color * @param color2 the second color */ public void setColorRange(int firstIndex, int lastIndex, int color1, int color2) { for (int i = firstIndex; i <= lastIndex; i++) { map[i] = ImageMath.mixColors((float) (i - firstIndex) / (lastIndex - firstIndex), color1, color2); } }
/** * Set a knot color. * @param n the knot index * @param color the color */ public void setColor(int n, int color) { int firstColor = map[0]; int lastColor = map[256-1]; if (n > 0) for (int i = 0; i < n; i++) map[i] = ImageMath.mixColors((float)i/n, firstColor, color); if (n < 256-1) for (int i = n; i < 256; i++) map[i] = ImageMath.mixColors((float)(i-n)/(256-n), color, lastColor); }
private void makeCircle(int width, int[] outPixels, int radius2, int sx, int sy, int rgb, int minSx, int maxSx, int minSy, int maxSy) { for (int x = minSx; x < maxSx; x++) { for (int y = minSy; y < maxSy; y++) { int dsx = x - sx; int dsy = y - sy; boolean isInside = dsx * dsx + dsy * dsy <= radius2; if (isInside) { int offset = y * width + x; int rgb2 = outPixels[offset]; outPixels[offset] = ImageMath.mixColors(mix, rgb2, rgb); } } } }
public BufferedImage filter( BufferedImage src, BufferedImage dst ) { lut = new int[256]; for ( int i = 0; i < 128; i++ ) { float t = i / 127.0f; lut[i] = ImageMath.mixColors( t, shadowColor, midColor ); } for ( int i = 128; i < 256; i++ ) { float t = (i-127) / 128.0f; lut[i] = ImageMath.mixColors( t, midColor, highColor ); } dst = super.filter( src, dst ); lut = null; return dst; }
public static Color interpolateInRGB(Color startColor, Color endColor, float progress) { int initialRGB = startColor.getRGB(); int finalRGB = endColor.getRGB(); // linear interpolation in the RGB space // possibly interpolating in HSB space would be better int interpolatedRGB = ImageMath.mixColors(progress, initialRGB, finalRGB); return new Color(interpolatedRGB); }
private void makeDiamond(int width, int[] outPixels, int radius, int sx, int sy, int rgb, int minSx, int maxSx, int minSy, int maxSy) { for (int x = minSx; x < maxSx; x++) { for (int y = minSy; y < maxSy; y++) { int dx = Math.abs(x - sx); int dy = Math.abs(y - sy); boolean isInside = (dx + dy) <= radius; if (isInside) { int offset = y * width + x; int rgb2 = outPixels[offset]; outPixels[offset] = ImageMath.mixColors(mix, rgb2, rgb); } } } }
@Override public BufferedImage filter( BufferedImage src, BufferedImage dst ) { lut = new int[256]; for ( int i = 0; i < 128; i++ ) { float t = i / 127.0f; lut[i] = ImageMath.mixColors( t, shadowColor, midColor ); } for ( int i = 128; i < 256; i++ ) { float t = (i-127) / 128.0f; lut[i] = ImageMath.mixColors( t, midColor, highColor ); } dst = super.filter( src, dst ); lut = null; return dst; }
private static Color tween( Color c1, Color c2, float p) { if(p==0) return c1; if(p==1) return c2; int rgb1 = c1.getRGB(); int rgb2 = c2.getRGB(); int rgb = ImageMath.mixColors(p, rgb1, rgb2); return new Color(rgb, true); // return new Color( // (int)(c1.getRed()*(1-p)+c2.getRed()*(p)), // (int)(c1.getGreen()*(1-p)+c2.getGreen()*(p)), // (int)(c1.getBlue()*(1-p)+c2.getBlue()*(p)), // (int)(c1.getAlpha()*(1-p)+c2.getAlpha()*(p)) // ); }
/** * Convert a value in the range 0..1 to an RGB color. * @param v a value in the range 0..1 * @return an RGB color */ public int getColor(float v) { return ImageMath.mixColors(ImageMath.clamp(v, 0, 1.0f), color1, color2); }
public int filterRGB(int x, int y, int rgb) { int a = rgb & 0xff000000; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; int l = r + g + b; float f = ImageMath.smoothStep(lowerThreshold3, upperThreshold3, l); return ImageMath.mixColors(f, black, white); }
@Override public int filterRGB(int x, int y, int rgb) { // int a = rgb & 0xff000000; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; int l = r + g + b; float f = ImageMath.smoothStep(lowerThreshold3, upperThreshold3, l); return ImageMath.mixColors(f, black, white); }
@Override public int filterRGB(int x, int y, int rgb) { double outside = shape.isOutside(x, y); if (outside == 1.0) { return RGB_BLACK; } else if (outside == 0.0) { return RGB_WHITE; } else { return ImageMath.mixColors((float) outside, RGB_WHITE, RGB_BLACK); } }
/** * Convert a value in the range 0..1 to an RGB color. * * @param v a value in the range 0..1 * @return an RGB color */ @Override public int getColor(float v) { return ImageMath.mixColors(ImageMath.clamp(v, 0, 1.0f), color1, color2); }
@Override public int filterRGB(int x, int y, int rgb) { double outside = shape.isOutside(x, y); if (invert) { outside = 1.0 - outside; } if (outside == 1.0) { return bgPixel; } else if (outside == 0.0) { return rgb; } else { return ImageMath.mixColors((float) outside, rgb, bgPixel); } }
public int filterRGB(int x, int y, int rgb) { int v = PixelUtils.brightness( rgb ); float f = ImageMath.smoothStep( lowerThreshold, upperThreshold, v ); return (rgb & 0xff000000) | (ImageMath.mixColors( f, black, white ) & 0xffffff); }
public int filterRGB(int x, int y, int rgb) { float nx = (m00*x + m01*y) / xScale; float ny = (m10*x + m11*y) / yScale; float f = ((int)(nx+100000) % 2 != (int)(ny+100000) % 2) ? 1.0f : 0.0f; if (fuzziness != 0) { float fuzz = (fuzziness/100.0f); float fx = ImageMath.smoothPulse(0, fuzz, 1-fuzz, 1, ImageMath.mod(nx, 1)); float fy = ImageMath.smoothPulse(0, fuzz, 1-fuzz, 1, ImageMath.mod(ny, 1)); f *= fx*fy; } return ImageMath.mixColors(f, foreground, background); }