mTranslateMatrix.preTranslate(dx, dy); mTranslateMatrix.invert(mTranslateMatrixInverse);
mMatrix.preTranslate(-centerX, -centerY); mMatrix.postTranslate(centerX, centerY); mMatrix.postTranslate(left, top);
mTranslateMatrix.preTranslate(dx, dy); mTranslateMatrix.invert(mTranslateMatrixInverse);
private Matrix rotateMe(Canvas canvas, Bitmap bm) { // TODO Auto-generated method stub Matrix mtx=new Matrix(); float scale = (float) canvas.getWidth() / (float) bm.getHeight(); mtx.preTranslate((canvas.getWidth() - bm.getWidth())/2, (canvas.getHeight() - bm.getHeight())/2); mtx.postRotate(90,canvas.getWidth()/2, canvas.getHeight()/2); mtx.postScale(scale, scale, canvas.getWidth()/2 , canvas.getHeight()/2 ); return mtx; }
canvas.save(); Matrix matrix = new Matrix(); camera.save(); camera.rotateY(rotateAngle); camera.getMatrix(matrix); camera.restore(); mPaint.setColor(textBackgroundColor); int centerX = diameter / 2; int centerY = diameter / 2; matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); canvas.concat(matrix); canvas.drawCircle(diameter / 2, diameter / 2, diameter / 2, mPaint); canvas.restore();
Matrix matrix = new Matrix(); mCamera = new Camera(); canvas.drawText("In the name of God", 30, 100, redPaint); mCamera.rotateY(60); mCamera.getMatrix(matrix); matrix.preTranslate(-30, -100); matrix.postTranslate(30, 100); canvas.concat(matrix); canvas.drawText("In the name of God", 30, 100, greenPaint);
matrix.preTranslate(f1, f2); if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) matrix.postRotate(270f,(width_Canvas) / 2,(height_Canvas) / 2);
Matrix newMatrix = new Matrix(); newMatrix.set(imageMatrix); newMatrix.preTranslate(-(imageWidth/2), -(imageHeight/2)); newMatrix.preScale(scaleWidth, scaleHeight); newMatrix.postTranslate((imageWidth/2), (imageHeight/2));
mClickCoords = new float[2]; //e is the motionevent that contains the screen touch we //want to translate into a canvas coordinate mClickCoords[0] = e.getX(); mClickCoords[1] = e.getY(); Matrix matrix = new Matrix(); matrix.set(getMatrix()); //this is where you apply any translations/scaling/rotation etc. //Typically you want to apply the same adjustments that you apply //in your onDraw(). matrix.preTranslate(mVirtualX, mVirtualY); matrix.preScale(mScaleFactor, mScaleFactor, mPivotX, mPivotY); // invert the matrix, creating the mapping from screen //coordinates to canvas coordinates matrix.invert(matrix); //apply the mapping matrix.mapPoints(mClickCoords); //mClickCoords[0] is the canvas x coordinate and //mClickCoords[1] is the y coordinate.
mClickCoords = new float[2]; //e is the motionevent that contains the screen touch we //want to translate into a canvas coordinate mClickCoords[0] = e.getX(); mClickCoords[1] = e.getY(); Matrix matrix = new Matrix(); matrix.set(getMatrix()); //this is where you apply any translations/scaling/rotation etc. //Typically you want to apply the same adjustments that you apply //in your onDraw(). matrix.preTranslate(mVirtualX, mVirtualY); matrix.preScale(mScaleFactor, mScaleFactor, mPivotX, mPivotY); // invert the matrix, creating the mapping from screen //coordinates to canvas coordinates matrix.invert(matrix); //apply the mapping matrix.mapPoints(mClickCoords); //mClickCoords[0] is the canvas x coordinate and //mClickCoords[1] is the y coordinate.
//Shape pathShape = this.getPathShape(); Bitmap groundImage = ImageHandler.getmGroundImage(); int offset = groundImage.getWidth()-(xPosition%groundImage.getWidth()); Path path = new Path(); path.moveTo(coordinates.get(0).getmX(), coordinates.get(0).getmY()); for ( ShapeCoordinate coordinate : coordinates ) { path.lineTo(coordinate.getmX(), coordinate.getmY()); } path.lineTo(coordinates.get(coordinates.size()-1).getmX(), mYBase); path.lineTo(coordinates.get(0).getmX(), mYBase); path.lineTo(coordinates.get(0).getmX(), coordinates.get(0).getmY()); path.close(); PathShape shape = new PathShape(path,canvas.getWidth(),canvas.getHeight()); BitmapShader bs = new BitmapShader(groundImage, Shader.TileMode.REPEAT,Shader.TileMode.REPEAT); Matrix matrix = new Matrix(); matrix.reset(); matrix.setScale(1,1); matrix.preTranslate(offset, 0); bs.setLocalMatrix(matrix); ShapeDrawable sd = new ShapeDrawable(shape); sd.setColorFilter(Color.argb(255, 50*(mLevel+1), 50*(mLevel+1), 50*(mLevel+1)), Mode.LIGHTEN); sd.getPaint().setShader(bs); sd.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); sd.draw(canvas);
mTranslateMatrix.preTranslate(dx, dy); mTranslateMatrix.invert(mTranslateMatrixInverse);
m.preTranslate( -clamp(0.5f * getWidth() / zoom, zoomX, getWidth() - 0.5f m.preTranslate(v.getLeft(), v.getTop());
m.preTranslate(-clamp(0.5f * getWidth() / zoom, zoomX, getWidth() - 0.5f * getWidth() / zoom), -clamp(0.5f * getHeight() / zoom, zoomY, getHeight() - 0.5f * getHeight() / zoom)); m.preTranslate(v.getLeft(), v.getTop());
m.preTranslate( -clamp(0.5f * getWidth() / zoom, zoomX, getWidth() - 0.5f m.preTranslate(v.getLeft(), v.getTop());
leftMatrix.preTranslate(-w2, -h2); leftMatrix.postTranslate(w2, h2); rightMatrix.preTranslate(-w2, -h2); rightMatrix.postTranslate(w2, h2);
matrix.reset(); matrix.setScale(1,1); matrix.preTranslate(xOffset, yOffset);
matrix.reset(); matrix.setScale(1,1); matrix.preTranslate(xOffset, yOffset);
camera.getMatrix(m); camera.restore(); m.preTranslate(-pX, -pY); m.postTranslate(pX, pY);
mCamera.rotateY(getRotateY()); mCamera.getMatrix(mMatrix); mMatrix.preTranslate(-getPivotX(), -getPivotY()); mMatrix.postTranslate(getPivotX(), getPivotY()); mCamera.restore();