在画布上绘图镜文本 [英] Drawing mirror text on canvas

查看:116
本文介绍了在画布上绘图镜文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在画布上绘制文本及以下另一个文本就是本文(看起来像影子)

I'm trying to draw on a canvas a text and below another text that is the mirror of this text (that looks like shadow)

我用它在的onDraw的方法

I'm using it in the "onDraw" method

有一个简单的办法做到这一点?

Is there a simple way to do it?

在此先感谢,
利奥尔

Thanks in advance, Lior

推荐答案

当然可以。您需要先缩放画布。尝试了这一点:

sure can. You will need to scale the canvas first. Try this out:

paint.setTextSize(44);
int cx = this.getMeasuredWidth() / 2;
int cy = this.getMeasuredHeight() / 2;
paint.setColor(Color.RED);
canvas.drawText("Hello", cx, cy, paint);

canvas.save();
canvas.scale(1f, -0.5f, cx, cy);
paint.setColor(Color.GRAY);
canvas.drawText("Hello", cx, cy, paint);
super.onDraw(canvas);
canvas.restore();

尝试不同的值规模为Y值来获得你想要的效果。

Try different values for the scale Y value to get effect you want.

这篇关于在画布上绘图镜文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆