1

I am working on implementing an eraser tool for a paint style app using Kotlin. I have the following function which so far just changes whatever i touch to black.

    fun setEraser(){
        mDrawPaint!!.alpha = 0
        mDrawPaint!!.maskFilter = null
        mDrawPaint!!.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
        mDrawPaint!!.isAntiAlias = true
    } 

I have the following private variables which I am also making use of when the function setEraser is called:

    private var mCanvasBitMap: Bitmap? = null
    private var mDrawPaint: Paint? = null
    private var mCanvasPaint: Paint? = null
    private var color = Color.BLACK
    private var canvas: Canvas? = null

I have found examples for Java but havent been able to make use of them:

Android: Painting app with eraser not working

Implementing an eraser in an Android drawing app - black trail and then transparent

Any help would be greatly appreciated! I am quite stuck after lots of googling and reading :/

Zomb991
  • 33
  • 4

0 Answers0