Flip vertically an Android Canvas

前端 未结 2 1752
不思量自难忘°
不思量自难忘° 2021-02-20 07:55

Is there an easy way to flip a canvas in Android? I cant seem to find anything that allows me to flip it vertically so that zero on the y-axis is the bottom of the phone screen

2条回答
  •  一整个雨季
    2021-02-20 08:29

    If you are drawing a bitmap, you can also use the Shader.TileMode of MIRROR, e.g.

    val shader = BitmapShader(bitmap, Shader.TileMode.MIRROR, Shader.TileMode.MIRROR)
    paint.shader = shader
    canvas.drawRoundRect(roundRect, 20F, 20F, mPaint)
    paint.shader = null
    

提交回复
热议问题