drawText() public method

public drawText ( char arg0, int arg1, int arg2, float arg3, float arg4, android arg5 ) : void
arg0 char
arg1 int
arg2 int
arg3 float
arg4 float
arg5 android
return void
Ejemplo n.º 1
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);
		}
Ejemplo n.º 2
0
		static void drawIntoBitmap (Bitmap bm)
		{
			float x = bm.getWidth ();
			float y = bm.getHeight ();
			Canvas c = new Canvas (bm);
			Paint p = new Paint ();
			p.setAntiAlias (true);

			p.setAlpha (0x80);
			c.drawCircle (x / 2, y / 2, x / 2, p);

			p.setAlpha (0x30);
			p.setXfermode (new PorterDuffXfermode (PorterDuff.Mode.SRC));
			p.setTextSize (60);
			p.setTextAlign (Paint.Align.CENTER);
			Paint.FontMetrics fm = p.getFontMetrics ();
			c.drawText ("Alpha", x / 2, (y - fm.ascent) / 2, p);
		}
Ejemplo n.º 3
0
		protected override void onDraw(Canvas canvas)
		{
			canvas.drawColor(Color.YELLOW);
			int width = canvas.getWidth();
			int height = canvas.getHeight();

			Paint paint = new Paint();
			paint.setColor(Color.RED);
			paint.setStyle(Paint.Style.STROKE);
			paint.setStrokeWidth(10);
			canvas.drawCircle(width / 2, height / 2, height / 3, paint);

			Paint inner = new Paint();
			paint.setColor(Color.GREEN);
			paint.setStyle(Paint.Style.FILL);
			canvas.drawCircle(width / 2, height / 2, height / 3 - 10, inner);

			Paint text = new Paint();
			text.setTextSize(20);
			canvas.drawText("I am a Xobot Monkey!", width / 8, height / 8, text);
		}
Ejemplo n.º 4
0
		void drawRgn (Canvas canvas, int color, String str, Region.Op op)
		{
			if (str != null) {
				mPaint.setColor (Color.BLACK);
				canvas.drawText (str, 80, 24, mPaint);
			}

			Region rgn = new Region ();
			rgn.set (mRect1);
			rgn.op (mRect2, op);

			mPaint.setColor (color);
			RegionIterator iter = new RegionIterator (rgn);
			Rect r = new Rect ();

			canvas.translate (0, 30);
			mPaint.setColor (color);
			while (iter.next(r)) {
				canvas.drawRect (r, mPaint);
			}
			drawOriginalRects (canvas, 0x80);
		}
Ejemplo n.º 5
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 ();
		}
Ejemplo n.º 6
0
 public override void draw(Canvas canvas)
 {
     Rect bounds = Bounds;
     int height = bounds.height();
     paint.TextSize = height;
     Rect textBounds = new Rect();
     string textValue = icon.character().ToString();
     paint.getTextBounds(textValue, 0, 1, textBounds);
     int textHeight = textBounds.height();
     float textBottom = bounds.top + (height - textHeight) / 2f + textHeight - textBounds.bottom;
     canvas.drawText(textValue, bounds.exactCenterX(), textBottom, paint);
 }
Ejemplo n.º 7
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			canvas.translate (10, 10);

			canvas.save ();
			for (int i = 0; i < N; i++) {
				setSrcR (i);
				drawSrcR (canvas, i);
				canvas.translate (mSrcR.width () + 15, 0);
			}
			canvas.restore ();

			canvas.translate (0, 100);
			for (int j = 0; j < sFits.Length; j++) {
				canvas.save ();
				for (int i = 0; i < N; i++) {
					drawFit (canvas, i, sFits [j]);
					canvas.translate (mDstR.width () + 8, 0);
				}
				canvas.drawText (sFitLabels [j], 0, HEIGHT * 2 / 3, mLabelPaint);
				canvas.restore ();
				canvas.translate (0, 80);
			}
		}
Ejemplo n.º 8
0
		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (Color.WHITE);

			Paint labelP = new Paint (Paint.ANTI_ALIAS_FLAG);
			labelP.setTextAlign (Paint.Align.CENTER);

			Paint paint = new Paint ();
			paint.setFilterBitmap (false);

			canvas.translate (15, 35);

			int x = 0;
			int y = 0;
			for (int i = 0; i < sModes.Length; i++) {
				// draw the border
				paint.setStyle (Paint.Style.STROKE);
				paint.setShader (null);
				canvas.drawRect (x - 0.5f, y - 0.5f,
						x + W + 0.5f, y + H + 0.5f, paint);

				// draw the checker-board pattern
				paint.setStyle (Paint.Style.FILL);
				paint.setShader (mBG);
				canvas.drawRect (x, y, x + W, y + H, paint);

				// draw the src/dst example into our offscreen bitmap
				int sc = canvas.saveLayer (x, y, x + W, y + H, null,
							  Canvas.MATRIX_SAVE_FLAG |
							  Canvas.CLIP_SAVE_FLAG |
							  Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
							  Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
							  Canvas.CLIP_TO_LAYER_SAVE_FLAG);
				canvas.translate (x, y);
				canvas.drawBitmap (mDstB, 0, 0, paint);
				paint.setXfermode (sModes [i]);
				canvas.drawBitmap (mSrcB, 0, 0, paint);
				paint.setXfermode (null);
				canvas.restoreToCount (sc);

				// draw the label
				canvas.drawText (sLabels [i],
						x + W / 2, y - labelP.getTextSize () / 2, labelP);

				x += W + 10;

				// wrap around when we've drawn enough for one row
				if ((i % ROW_MAX) == ROW_MAX - 1) {
					x = 0;
					y += H + 30;
				}
			}
		}
            protected override void onDraw(Canvas canvas)
            {

                Paint paint = new Paint();

                paint.setStyle(Paint.Style.STROKE);
                paint.setColor(Color.RED);
                paint.setTextSize(30);

                canvas.drawText(text, 10, 60, paint);

                base.onDraw(canvas);
            }
Ejemplo n.º 10
0
		private void drawSample (Canvas canvas, ColorFilter filter)
		{
			Rect r = mDrawable.getBounds ();
			float x = (r.left + r.right) * 0.5f;
			float y = (r.top + r.bottom) * 0.5f - mPaintTextOffset;

			mDrawable.setColorFilter (filter);
			mDrawable.draw (canvas);
			canvas.drawText ("Label", x + 1, y + 1, mPaint2);
			canvas.drawText ("Label", x, y, mPaint);

			foreach (Drawable dr in mDrawables) {
				dr.setColorFilter (filter);
				dr.draw (canvas);
			}
		}