• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Feb 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. @Override
2. public void onDraw(Canvas canvas)
3. {
4.     int startX, startY, stopX, stopY;
5.     startY = stopY = 100;
6.     startX = 100;
7.     stopX = 200;
8.     this.paint = new Paint();
9.     //this.path = new Path();
10.     this.matrix = canvas.getMatrix();
11.     this.paint.setColor(Color.BLUE);
12.     this.paint.setStrokeWidth(4);
13.
14.     this.matrix.setRotate(180, startX, startY);
15.     canvas.concat(this.matrix);
16.     /*this.matrix.setTranslate(startX, 0);
17.     canvas.concat(this.matrix);*/
18.
19.     canvas.drawLine(startX, startY, stopX, stopY, this.paint);
20.
21.     canvas.setMatrix(new Matrix());
22.     //canvas.drawCircle(200, 200, 50, paint);
23. }
24.
25. this.matrix.setRotate(180, startX, startY);
26. canvas.save();
27. canvas.concat(this.matrix);
28. canvas.drawLine(startX, startY, stopX, stopY, this.paint);
29. canvas.restore();
30.
31. Matrix m = new Matrix();       //Declaring a new matrix
32.     float[] vecs = {7, 3};    //Declaring an end-point of the line
33.
34.    /*Declaring the initial values of the matrix
35.      according to the theory of the 3
36.      dimensional chicken in 2D space
37.     There is also 4D chicken in 3D space*/
38.
39.     float[] initial = {1, 0, 0, 0, 1, 0, 0, 0, 1};
40.     m.setValues(initial);
41.     float[] tmp = new float[9];    //Debug array of floats
42.     m.setRotate(90, 4.0f, 3.0f);    //Rotating by 90 degrees around the (4, 3) point
43. /*Mapping our vector to the matrix.
44.   Similar to the multiplication of two
45.   matrices 3x3 by 1x3.
46.   In our case they are (matrix m after rotating) multiplied by
47.   (7)
48.   (3)
49.   (1) according to the theory*/
50.
51.   m.mapPoints(vecs);
52.
53.     for(float n : vecs)
54.     {
55.         Log.d("VECS", "" + n);     //Some debug info
56.     }
57.
58.     m.getValues(tmp);
59.     for(float n : tmp)
60.     {
61.         Log.d("TMP", "" + n);      //also debug info
62.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top