private void clearCanvas(Canvas canvas) { canvas.getContext2d().save(); canvas.getContext2d().setTransform(1, 0, 0, 1, 0, 0); canvas.getContext2d().clearRect(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight()); canvas.getContext2d().restore(); }
private void clearCanvas(Canvas canvas) { canvas.getContext2d().save(); canvas.getContext2d().setTransform(1, 0, 0, 1, 0, 0); canvas.getContext2d().clearRect(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight()); canvas.getContext2d().restore(); }
protected void repaintBuffer() { clearCanvas(buffer); double bufferDx = matrix.getDx() + (bufferFactor - 1) * 0.5 * canvas.getCoordinateSpaceWidth(); double bufferDy = matrix.getDy() + (bufferFactor - 1) * 0.5 * canvas.getCoordinateSpaceHeight(); Matrix bufferMatrix = new Matrix(matrix.getXx(), 0, 0, matrix.getYy(), bufferDx, bufferDy); buffer.getContext2d().setTransform(matrix.getXx(), 0, 0, matrix.getYy(), bufferDx, bufferDy); double width = canvas.getCoordinateSpaceWidth(); double height = canvas.getCoordinateSpaceHeight(); bufferBounds = toWorld(new Bbox(-0.5 * (bufferFactor - 1) * width, -0.5 * (bufferFactor - 1) * height, bufferFactor * width, bufferFactor * height)); for (CanvasShape shape : shapes) { shape.paint(buffer, bufferMatrix); } }
protected void repaintBuffer() { clearCanvas(buffer); double bufferDx = matrix.getDx() + (bufferFactor - 1) * 0.5 * canvas.getCoordinateSpaceWidth(); double bufferDy = matrix.getDy() + (bufferFactor - 1) * 0.5 * canvas.getCoordinateSpaceHeight(); Matrix bufferMatrix = new Matrix(matrix.getXx(), 0, 0, matrix.getYy(), bufferDx, bufferDy); buffer.getContext2d().setTransform(matrix.getXx(), 0, 0, matrix.getYy(), bufferDx, bufferDy); double width = canvas.getCoordinateSpaceWidth(); double height = canvas.getCoordinateSpaceHeight(); bufferBounds = toWorld(new Bbox(-0.5 * (bufferFactor - 1) * width, -0.5 * (bufferFactor - 1) * height, bufferFactor * width, bufferFactor * height)); for (CanvasShape shape : shapes) { shape.paint(buffer, bufferMatrix); } }