Problem with TouchPaint style application

Put your problem here if it does not fit any of the other categories.

Re: The Pizza Timer - Threading/Drawing on Canvas

Postby qamerfarooq » Thu Jan 24, 2008 9:09 am

I am changing the TouchPaint.java which is provided with the Android SDK samples. Currently it supports the pixels drawing on the canvas by pressing & dragging the mouse, though its missing the pixels in drawing (Any Solution?).

Any way I want to change this in such a way that I could draw lines,rectangles or other shapes with mouse pointer dragging, like in normal paint brush applications. I tried to do it my self but faced following issues

- When I draw rectangles/lines with mouse drag, its not clearing the rectangles/lines which are keep drawing during mouse dragging (of course i tried to remove them but not successful yet). You can see it in the attached screen shot.

Required:
Kindly write some code in which some shape like line or rectangle could be drawn with the mouse pointer, i have attached my code.
Attachments
line-issue.JPG
Screen Shot showing problem
line-issue.JPG (17.64 KiB) Viewed 811 times
TouchPaint.zip
Full Source
(1.44 KiB) Downloaded 138 times
Qamer Farooq
End 2 End Solution Providers
http://www.e2esp.com
qamerfarooq
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Jan 11, 2008 6:07 am
Location: Pakistan

Top

Postby res » Sun Jan 27, 2008 6:32 am

I haven't read your code but this is what I would do.

Create a clear screen "hot key" on the keypad to clear the screen of any input, there isn't really anyway to know when you should automatically clear the screen while the user is drawing so keep this part manual.

From the picture you posted it appears all the lines start from the same point. The starting X,Y co-ordinate of each new line should be the last point the user touched the screen when drawing the previous line.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby Ishtar » Sun Jan 27, 2008 5:04 pm

Just an idea. Make a new view, let it draw the rect/oval, and invalidate it on pointer movement. So that it will redraw itself (discarding the old rect). When the user stops dragging, then really draw it.

Ishtar
Ishtar
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Wed Jan 16, 2008 10:22 pm
Location: Netherlands

Postby qamerfarooq » Mon Jan 28, 2008 6:19 am

Ishtar wrote:Just an idea. Make a new view, let it draw the rect/oval, and invalidate it on pointer movement. So that it will redraw itself (discarding the old rect). When the user stops dragging, then really draw it.

Ishtar


If I clear every thing during mouse dragging and draw the actual shape when I stop dragging, then finally I have one shape on my screen which i have just drawn all other previously drawn shapes will be removed.

I tried your suggestion before but wasn't successful.
Qamer Farooq
End 2 End Solution Providers
http://www.e2esp.com
qamerfarooq
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Jan 11, 2008 6:07 am
Location: Pakistan

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests