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 8179219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:57:13+00:00 2026-06-06T23:57:13+00:00

I’ve been developing an app to draw in ics android tablets and i’ve encountered

  • 0

I’ve been developing an app to draw in ics android tablets and i’ve encountered an issue I can’t figure out how to fix.

The problem is that I draw correctly and in a real time drawing BUT when I go really really fast (tested on real tablets) the circles are not really circles, they look like pilygons of 5 or 6 sides…

Here I declare the bitmap and assign it to the canvas:

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    width = size.x;
    height = size.y;
    bm = Bitmap.createBitmap(width, height-50,Bitmap.Config.ARGB_8888); 
    c = new Canvas(bm);

Here the code I use to get the x, y: (the layP is the “Painter” which you’ll se down here

class SaveOnTouchListener implements OnTouchListener{

    public boolean onTouch(View v, MotionEvent e) {
        final float x = e.getX();
        final float y = e.getY();
        if(e.getAction() == MotionEvent.ACTION_DOWN){  
            startx.add(x);
            starty.add(y);
            x1 = x;
            y1 = y;
        } else if(e.getAction() == MotionEvent.ACTION_MOVE){  
            endx.add(x);
            endy.add(y);
            x2 = x;
            y2 = y;
            if (id == 1) strokes.add(sb.getProgress()+1);
            else strokes.add(4*(sb.getProgress()+1));
            layP.draw();
            startx.add(x);
            starty.add(y);
            x1 = x;
            y1 = y;
        } else if(e.getAction() == MotionEvent.ACTION_UP){  
            x2 = x;
            y2 = y;
            endx.add(x);
            endy.add(y);
            strokes.add(stroke);
            layP.draw();
            return false;
        }
        return true;
    }

}

And finally here’s the code for the “painter” which is the canvas and the onDraw() method (i use the invalidate(t,l,r,b) to do it optimized….)

private class Painter extends View{
    public Painter(Context context){
        super(context);
    }

    public void draw() {
        if (firstPainting) {
                            //paint the canvas white just once
            Paint paint = new Paint();
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(Color.WHITE);
            c.drawPaint(paint);
            firstPainting = false;
            layP.invalidate();
        }
        else {
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                paint.setAntiAlias(true);
                int r = startx.get(startx.size()-1).intValue();
                int t = starty.get(starty.size()-1).intValue();
                int l = endx.get(endx.size()-1).intValue();
                int b = endy.get(endy.size()-1).intValue();
                int n = strokes.get(strokes.size()-1);
                paint.setStrokeWidth(n);
                paint.setColor(COLOR.BLACK);
                c.drawLine(r, t, l, b, paint);
                c.drawCircle(r, t, n/2, paint);

                if (l > r) {
                    int aux = l;
                    l = r;
                    r = aux;
                }
                if (t > b) {
                    int aux = t;
                    t = b;
                    b = aux;
                }
                r += n;
                l -= n;
                t -= n;
                b += n;
                if (t < 0) t = 0;
                if (l < 0) l = 0;
                layP.invalidate(l,t,r,b);
        }
    }


    @Override 
    protected void onDraw(Canvas c) {
            c.drawBitmap(bm, 0, 0, null);
    }
}
}

As you can see I use a BitMap and I just invalidate the zone needed to be invalidated, I don’t know what else to do.

Is there a way to draw properly? Even if I have to change all the bitmap and canvas..

I’ve tried to to implement Bezier but I don’t know how to do it since I need the next points before drawing the lines.

I’ve found the bezier method, I think I’m going to try this out.

  • 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-06-06T23:57:14+00:00Added an answer on June 6, 2026 at 11:57 pm

    It’s not at all clear to me what you’re trying to do. From your text, it sounds like you’re trying to do basic “finger painting”, where you basically just draw curves that match the input. Your code doesn’t look much like that to me, but between the variables you’re using that we haven’t seen declarations for (stroke and strokes) and the one-letter variable names, I’m a bit lost. Certainly these two lines:

    c.drawLine(r, t, l, b, paint);
    c.drawCircle(r, t, n/2, paint);
    

    make it look like you’re going for more than simply drawing what the user draws with their finger.

    Still, I’d like to try to help. drawCircle() really should always draw circles. Drawing lines between points is going to give you sharp corners (polygons if you close a shape). If you want to draw paths like this smoothly, then Bézier curves are indeed what you want.

    If you download the sample code from the SDK, there’s an example called “FingerPaint” that does a very good job demonstrating how to draw arbitrary curves smoothly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

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.