Drawing mirror text on canvas

I am trying to draw text on the canvas and under another text, which is a mirror of this text (which looks like a shadow)

I use it in the "onDraw" method

Is there an easy way to do this?

Thanks in advance, Lior

+2
source share
1 answer

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

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(); 

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

enter image description here

+6
source

Source: https://habr.com/ru/post/1384647/


All Articles