protected int randColor () { return Color.rgb(128 + _rnd.nextInt(127), 128 + _rnd.nextInt(127), 128 + _rnd.nextInt(127)); }
/** * Blends two colors proportionally. * @param p1 The percentage of the first color to use, from 0.0f to 1.0f inclusive. */ public static int blend (int c1, int c2, float p1) { float p2 = 1 - p1; return Color.rgb((int)(Color.red(c1) * p1 + Color.red(c2) * p2), (int)(Color.green(c1) * p1 + Color.green(c2) * p2), (int)(Color.blue(c1) * p1 + Color.blue(c2) * p2)); }
@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 }
public void render(Surface surf) { surf.setFillColor(Color.rgb(255, 255, 255)); surf.fillRect(0, 0, graphics().width(), graphics().height()); } });
/** * Blends two colors. * @return a color halfway between the two colors. */ public static int blend (int c1, int c2) { return Color.rgb((Color.red(c1) + Color.red(c2)) >> 1, (Color.green(c1) + Color.green(c2)) >> 1, (Color.blue(c1) + Color.blue(c2)) >> 1); }
@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 }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().removeAll(); // add a grey square SurfaceImage surf = graphics().createSurface(width, height); surf.surface().setFillColor(Color.rgb(200, 200, 200)); surf.surface().fillRect(0, 0, width, height); square = graphics().createImageLayer(surf); graphics().rootLayer().add(square); }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().clear(); // add a grey square square = graphics().createSurfaceLayer(width, height); square.surface().setFillColor(Color.rgb(200, 200, 200)); square.surface().fillRect(0, 0, square.surface().width(), square.surface().height()); graphics().rootLayer().add(square); }
@Override public void init () { // remove the background layer added by default game.rootLayer.disposeAll(); // add a grey square TextureSurface surf = game.createSurface(width, height); surf.begin().setFillColor(Color.rgb(200, 200, 200)).fillRect(0, 0, width, height).end().close(); ImageLayer square = new ImageLayer(surf.texture); game.rootLayer.add(square); conns.add(game.paint.connect(clock -> { float t = clock.tick / 1000f; IDimension vsize = game.plat.graphics().viewSize; square.setTranslation((FloatMath.cos(t) + 1) * (vsize.width() - width)/2, (FloatMath.sin(t) + 1) * (vsize.height() - height)/2); })); } }