Code examples for Canvas

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
67:	canvas.save(); 
68:	canvas.scale(w,h); 
-
70:	canvas.translate(1, 0); 
-
76:	canvas.drawPath(path, p); 
-
83:	canvas.drawPath(path, p); 
84:	canvas.restore(); 
Full Snippet Info
9
CodeRank
53:	canvas.save(); 
54:	canvas.translate(dipToPx(getContext(), 400), dipToPx(getContext(), 200)); 
55:	canvas.rotate(45.0f); 
56:	canvas.drawRGB(255, 255, 255); 
-
58:	canvas.drawRect(-80.0f, -80.0f, 80.0f, 80.0f, mPaint); 
59:	canvas.drawRect(0.0f, 0.0f, 220.0f, 220.0f, mPaint); 
60:	canvas.restore(); 
Full Snippet Info
9
CodeRank
70:	canvas.translate(120.0f, 50.0f); 
71:	canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint); 
-
73:	canvas.translate(0.0f, mBitmap1.getHeight()); 
74:	canvas.translate(0.0f, 25.0f); 
75:	canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, null); 
-
77:	canvas.translate(0.0f, mBitmap2.getHeight()); 
78:	canvas.translate(0.0f, 25.0f); 
79:	canvas.drawBitmap(mBitmap3, 0.0f, 0.0f, null); 
Full Snippet Info
9
CodeRank
185:	Canvas c = new Canvas(mMapPin); 
186:	c.drawRect(0, 0, mMapPin.getWidth(), mMapPin.getHeight(), sClearerPaint); 
-
189:	c.drawBitmap(mBase, 0, 0, null); 
-
192:	c.drawBitmap(mPin, 0, 0, mPaint); 
-
195:	c.drawBitmap(mDot, 0, 0, mPaint); 
Full Snippet Info
9
CodeRank
58:	canvas.translate(100.0f, 100.0f); 
-
61:	canvas.save(); 
-
64:	canvas.translate(0.0f, 100.0f); 
-
67:	canvas.translate(0.0f, 100.0f); 
-
70:	canvas.translate(0.0f, 100.0f); 
-
73:	canvas.translate(0.0f, 100.0f); 
-
77:	canvas.restore(); 
-
79:	canvas.translate(100.0f, 0.0f); 
-
82:	canvas.save(); 
-
85:	canvas.translate(0.0f, 100.0f); 
-
88:	canvas.translate(0.0f, 100.0f); 
-
91:	canvas.translate(0.0f, 100.0f); 
-
94:	canvas.translate(0.0f, 100.0f); 
-
98:	canvas.restore(); 
-
100:	canvas.translate(100.0f, 0.0f); 
-
103:	canvas.save(); 
-
106:	canvas.translate(0.0f, 100.0f); 
-
110:	canvas.translate(0.0f, 100.0f); 
-
113:	canvas.drawRect(0.0f, 0.0f, 50.0f, 50.0f, mBluePaint); 
-
115:	canvas.translate(0.0f, 100.0f); 
-
119:	canvas.drawRect(0.0f, 0.0f, 50.0f, 50.0f, mBluePaint); 
-
124:	canvas.restore(); 
-
128:	canvas.drawRect(0.0f, 0.0f, 50.0f, 50.0f, mBluePaint); 
-
130:	canvas.save(); 
131:	canvas.translate(25.0f, 25.0f); 
-
133:	canvas.drawRect(0.0f, 0.0f, 50.0f, 50.0f, mRedPaint); 
134:	canvas.restore(); 
Full Snippet Info
9
CodeRank
182:	final Canvas dest = new Canvas(result); 
-
184:	dest.drawColor(0, PorterDuff.Mode.CLEAR); 
-
189:	dest.drawBitmap(mask, xy[0], xy[1], 
-
194:	dest.drawBitmap(src, 0, 0, mPaint); 
195:	dest.setBitmap(null); 
Full Snippet Info
9
CodeRank
38:	canvas = new Canvas(rounded); 
39:	canvas.drawBitmap(source, 0, 0, null); 
40:	canvas.drawBitmap(clipped, 0, 0, paint); 
Full Snippet Info
9
CodeRank
65:	final Canvas canvas = new Canvas(mBitmap); 
-
79:	canvas.drawColor(0, PorterDuff.Mode.CLEAR); 
-
86:	canvas.drawPath(fillPath, mPaint); 
-
90:	canvas.drawBitmap(bitmap, cropRect, circleRect, mPaint); 
Full Snippet Info
8
CodeRank
157:	can.clipRect(0, 0, mVertical ? size : can.getWidth(), mVertical ? can.getHeight() : size); 
-
159:	can.drawARGB((int) (frac * 0xFF), 0xDD, 0xEE, 0xAA); 
Full Snippet Info
8
CodeRank
253:	canvas.save(); 
-
262:	canvas.clipRect(mClipBounds); 
263:	mMatrix.set(canvas.getMatrix()); 
-
267:	canvas.setMatrix(mMatrix); 
-
271:	canvas.restore(); 
Full Snippet Info
8
CodeRank
65:	canvas.save(); 
66:	canvas.scale(0.3f, 0.3f); 
67:	canvas.drawBitmap(mBitmap1, 0, 0, mBitmapPaint); 
68:	canvas.restore(); 
-
70:	canvas.save(); 
71:	canvas.translate(mBitmap1.getWidth() * 0.3f + 96.0f, 0.0f); 
72:	canvas.scale(0.3f, 0.3f); 
73:	canvas.drawBitmap(mBitmap2, 0, 0, mBitmapPaint); 
74:	canvas.restore(); 
Full Snippet Info
9
CodeRank
72:	canvas.drawARGB(255, 255, 255, 255); 
-
74:	canvas.save(); 
75:	canvas.translate(120.0f, 50.0f); 
76:	canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mColorMatrixPaint); 
-
78:	canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); 
79:	canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mLightingPaint); 
-
81:	canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); 
82:	canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBlendPaint); 
83:	canvas.restore(); 
-
85:	canvas.save(); 
86:	canvas.translate(120.0f + mBitmap1.getWidth() + 120.0f, 50.0f); 
87:	canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mColorMatrixPaint); 
-
89:	canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); 
90:	canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mLightingPaint); 
-
92:	canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); 
93:	canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mBlendPaint); 
94:	canvas.restore(); 
Full Snippet Info
9
CodeRank
71:	canvas.drawRGB(255, 255, 255); 
-
73:	canvas.save(); 
74:	canvas.translate(130.0f, 100.0f); 
-
78:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
80:	canvas.translate(400.0f, 000.0f); 
-
84:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
86:	canvas.translate(400.0f, 000.0f); 
-
90:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
92:	canvas.translate(-800.0f, 300.0f); 
-
96:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
98:	canvas.translate(400.0f, 000.0f); 
-
102:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
104:	canvas.translate(400.0f, 000.0f); 
-
108:	canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint); 
-
111:	canvas.restore(); 
Full Snippet Info
9
CodeRank
103:	canvas.drawRGB(255, 255, 255); 
-
105:	canvas.save(); 
106:	canvas.translate(40.0f, 40.0f); 
-
109:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
111:	canvas.translate(0.0f, 40.0f + mDrawHeight); 
-
113:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
115:	canvas.translate(0.0f, 40.0f + mDrawHeight); 
-
117:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
119:	canvas.restore(); 
-
121:	canvas.save(); 
122:	canvas.translate(40.0f + mDrawWidth + 40.0f, 40.0f); 
-
125:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
127:	canvas.translate(0.0f, 40.0f + mDrawHeight); 
-
129:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
131:	canvas.translate(0.0f, 40.0f + mDrawHeight); 
-
133:	canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint); 
-
135:	canvas.restore(); 
Full Snippet Info
9
CodeRank
59:	canvas.drawRGB(255, 255, 255); 
-
63:	canvas.translate(100.0f, 300.0f); 
-
66:	canvas.translate(0.0f, 400.0f); 
-
74:	canvas.drawPath(path, mHugePaint); 
Full Snippet Info
9
CodeRank
81:	canvas.save(); 
82:	canvas.translate(0.0f, -height * 2 - 20.0f); 
-
87:	canvas.restore(); 
-
92:	canvas.save(); 
93:	canvas.translate(0.0f, height + 20.0f); 
-
98:	canvas.restore(); 
Full Snippet Info
8
CodeRank
131:	canvas.save(Canvas.MATRIX_SAVE_FLAG); 
132:	canvas.translate(mX, mY); 
133:	canvas.scale(mScaleX, mScaleY); 
134:	canvas.translate(-0.5f*getWidth(), -0.5f*getHeight()); 
-
137:	canvas.restore(); 
Full Snippet Info
8
CodeRank
78:	canvas.drawColor(0xffffffff); 
79:	canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint); 
-
84:	canvas.drawBitmap(mBitmap1, matrix, mBitmapPaint); 
-
89:	canvas.drawBitmap(mBitmap1, src, dst, mBitmapPaint); 
-
91:	canvas.translate(0.0f, mBitmap1.getHeight() * 4); 
92:	canvas.drawBitmapMesh(mBitmap1, 3, 3, mVertices, 0, null, 0, mBitmapPaint); 
Full Snippet Info
8
CodeRank