/** * Creates a packed integer color from three RGB values in the range [0, 255]. */ public static int rgb(int r, int g, int b) { return argb(0xff, r, g, b); }
/** * Creates a packed integer color from three RGB values in the range [0, 255]. */ public static int rgb(int r, int g, int b) { return argb(0xff, r, g, b); }
/** * Creates a packed integer color from three RGB values in the range [0, 255]. */ public static int rgb(int r, int g, int b) { return argb(0xff, r, g, b); }
/** * Sets the fill color from the cached rgb values. */ private void setFillColorFromCache() { canvas .setFillColor( Color.argb(fillAlpha, (int) (255 * cacheFillR), (int) (255 * cacheFillG), (int) (255 * cacheFillB))); }
/** * Sets the fill color from the cached rgb values. */ private void setStrokeColorFromCache() { canvas.setStrokeColor( Color.argb(strokeAlpha, (int) (255 * cacheStrokeR), (int) (255 * cacheStrokeG), (int) (255 * cacheStrokeB))); }
/** * Sets the fill color from the cached rgb values. */ private void setFillColorFromCache() { canvas.setFillColor( Color.argb(fillAlpha, (int) (255 * cacheFillR), (int) (255 * cacheFillG), (int) (255 * cacheFillB))); }
/** * Sets the fill color from the cached rgb values. */ private void setStrokeColorFromCache() { canvas.setStrokeColor( Color.argb(strokeAlpha, (int) (255 * cacheStrokeR), (int) (255 * cacheStrokeG), (int) (255 * cacheStrokeB))); }
/** * Creates a new brightened version of the given color. This is implemented by composing a new * color consisting of the components of the original color, each multiplied by 10/7, with * exceptions for zero-valued components. The alpha channel is copied from the original. */ public static int brighter (int color) { int a = Color.alpha(color); int r = Color.red(color), g = Color.green(color), b = Color.blue(color); // black is a special case the just goes to dark gray if (r == 0 && g == 0 && b == 0) return Color.argb(a, MIN_BRIGHT, MIN_BRIGHT, MIN_BRIGHT); // bump each component up to the minumum, unless it is absent if (r != 0) r = Math.max(MIN_BRIGHT, r); if (g != 0) g = Math.max(MIN_BRIGHT, g); if (b != 0) b = Math.max(MIN_BRIGHT, b); // scale return Color.argb(a, Math.min((int)(r*BRIGHT_FACTOR), 255), Math.min((int)(g*BRIGHT_FACTOR), 255), Math.min((int)(b*BRIGHT_FACTOR), 255)); }
/** * Creates a new darkened version of the given color. This is implemented by composing a new * color consisting of the components of the original color, each multiplied by the dark factor. * The alpha channel is copied from the original. */ public static int darker (int color, float darkFactor) { return Color.argb(Color.alpha(color), Math.max((int)(Color.red(color) * darkFactor), 0), Math.max((int)(Color.green(color) * darkFactor), 0), Math.max((int)(Color.blue(color) * darkFactor), 0)); }
@Override public void drawTransform(Transform xf) { getWorldToScreenToOut(xf.p, tempVec1); tempVec2.setZero(); // float k_axisScale = 0.4f; canvas.setStrokeColor(Color.rgb(1, 0, 0)); // note: violates strokeAlpha tempVec2.x = xf.p.x; // + k_axisScale * xf.R.m11; // Transform no longer scales tempVec2.y = xf.p.y; // + k_axisScale * xf.R.m12; getWorldToScreenToOut(tempVec2, tempVec2); canvas.drawLine(tempVec1.x, tempVec1.y, tempVec2.x, tempVec2.y); canvas.setStrokeColor(Color.rgb(0, 1, 0)); // note: violates strokeAlpha tempVec2.x = xf.p.x; // + k_axisScale * xf.R.m21; // Transform no longer scales tempVec2.y = xf.p.y; // + k_axisScale * xf.R.m22; getWorldToScreenToOut(tempVec2, tempVec2); canvas.drawLine(tempVec1.x, tempVec1.y, tempVec2.x, tempVec2.y); canvas.setStrokeColor(Color.argb(strokeAlpha, 1, 0, 0)); // restores strokeAlpha }
@Override public void drawTransform(Transform xf) { if (canvas == null) { log().error(CANVASERROR); return; } getWorldToScreenToOut(xf.p, tempVec1); tempVec2.setZero(); // float k_axisScale = 0.4f; canvas.setStrokeColor(Color.rgb(1, 0, 0)); // note: violates strokeAlpha tempVec2.x = xf.p.x; // + k_axisScale * xf.R.m11; // Transform no longer scales tempVec2.y = xf.p.y; // + k_axisScale * xf.R.m12; getWorldToScreenToOut(tempVec2, tempVec2); canvas.drawLine(tempVec1.x, tempVec1.y, tempVec2.x, tempVec2.y); canvas.setStrokeColor(Color.rgb(0, 1, 0)); // note: violates strokeAlpha tempVec2.x = xf.p.x; // + k_axisScale * xf.R.m21; // Transform no longer scales tempVec2.y = xf.p.y; // + k_axisScale * xf.R.m22; getWorldToScreenToOut(tempVec2, tempVec2); canvas.drawLine(tempVec1.x, tempVec1.y, tempVec2.x, tempVec2.y); canvas.setStrokeColor(Color.argb(strokeAlpha, 1, 0, 0)); // restores strokeAlpha }