drawLine() public method

public drawLine ( float arg0, float arg1, float arg2, float arg3, android arg4 ) : void
arg0 float
arg1 float
arg2 float
arg3 float
arg4 android
return void
Exemplo n.º 1
0
		void doDraw (Canvas canvas, float[] src, float[] dst)
		{
			canvas.save ();
			mMatrix.setPolyToPoly (src, 0, dst, 0, src.Length >> 1);
			canvas.concat (mMatrix);

			mPaint.setColor (Color.GRAY);
			mPaint.setStyle (Paint.Style.STROKE);
			canvas.drawRect (0, 0, 64, 64, mPaint);
			canvas.drawLine (0, 0, 64, 64, mPaint);
			canvas.drawLine (0, 64, 64, 0, mPaint);

			mPaint.setColor (Color.RED);
			mPaint.setStyle (Paint.Style.FILL);
			// how to draw the text center on our square
			// centering in X is easy... use alignment (and X at midpoint)
			float x = 64 / 2;
			// centering in Y, we need to measure ascent/descent first
			float y = 64 / 2 - (mFontMetrics.ascent + mFontMetrics.descent) / 2;
			canvas.drawText (src.Length / 2 + "", x, y, mPaint);

			canvas.restore ();
		}
Exemplo n.º 2
0
		void drawScene (Canvas canvas)
		{
			canvas.clipRect (0, 0, 100, 100);

			canvas.drawColor (Color.WHITE);

			mPaint.setColor (Color.RED);
			canvas.drawLine (0, 0, 100, 100, mPaint);

			mPaint.setColor (Color.GREEN);
			canvas.drawCircle (30, 70, 30, mPaint);

			mPaint.setColor (Color.BLUE);
			canvas.drawText ("Clipping", 100, 30, mPaint);
		}