Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:52:53+00:00 2026-05-26T07:52:53+00:00

How to draw a line (not a straight one just random continuous point(like we

  • 0

How to draw a line (not a straight one just random continuous point(like we draw with pencil)) and then to erase it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:52:54+00:00Added an answer on May 26, 2026 at 7:52 am

    it is finger painting application

    ////////////******************* Pinting view *******************///////////////////
    public class MyView extends View {
        int bh = originalBitmap.getHeight();
        int bw = originalBitmap.getWidth(); 
    
        public MyView (Context c)  {  
            super(c);
            //mBitmap = Bitmap.createBitmap(bw,bh,Bitmap.Config.ARGB_8888);
            mBitmap = Bitmap.createScaledBitmap(originalBitmap,bw,bh,true);
            mCanvas = new Canvas(mBitmap);
            mPath = new Path();
            mBitmapPaint = new Paint(Paint.DITHER_FLAG);
            mBitmapPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)) ;
        }
        @Override
        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);           
                /*mBitmap = Bitmap.createBitmap(bw, bh, Bitmap.Config.ARGB_8888);
                mCanvas = new Canvas(mBitmap);*/
        }
        @Override 
        protected void onDraw(Canvas canvas) {   
            canvas.drawColor(Color.TRANSPARENT);
            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
            canvas.drawPath(mPath, mPaint);
        }
        ////////************touching evants for painting**************///////
        private float mX, mY;
        private static final float TOUCH_TOLERANCE = 4;
        private void touch_start(float x, float y) {
            mPath.reset();
            mPath.moveTo(x, y);
            mX = x;
            mY = y;
        }
        private void touch_move(float x, float y) {
            float dx = Math.abs(x - mX);
            float dy = Math.abs(y - mY);
            if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
                mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
                mX = x;
                mY = y;
            }
        }
        private void touch_up() {
            mPath.lineTo(mX, mY);
            // commit the path to our offscreen
            mCanvas.drawPath(mPath, mPaint);
            // kill this so we don't double draw
            mPath.reset();
        }
        @Override 
        public boolean onTouchEvent(MotionEvent event) {             
            float x = event.getX();
            float y = event.getY();     
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    touch_start(x, y);
                    invalidate();
                    break;
                case MotionEvent.ACTION_MOVE:
                    //if(mode == DRAW) { mView.setOnTouchListener((OnTouchListener) this); }
                    touch_move(x, y);
                    invalidate();
                    break;
                case MotionEvent.ACTION_UP:
                    touch_up();
                    invalidate();
                    break;
            }
            return true;
        }  //end of touch events for image
    }// end MyView  
    

    for erase

    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know the easiest way to draw a straight line between
I need to draw a line one inch long on any device given a
I want to draw a straight line in JFrame using Line2D.Double , also I
I have used the following lines of code to draw a line from point
I want to draw line on UIImageView. I already draw line on UIImageView but
Where do you draw the line to stop making abstractions and to start writing
I want to draw a line in Crystal report. I can do that from
Does TortoiseSVN Revision Graph draw a line from Branch back to the Trunk when
I'am trying to draw a line above mapkit. If I try to set the
I want to draw this in my view to draw this line, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.