Drawing shapes on canvas in android - android

I have some problem. I would like to create applications paint which enabling them to draw different shapes. He wants to use the strategy pattern to change the tool used to draw. Unfortunately, I do not know how to keep the drawn shapes to be the ability to undo and change the color of specific shapes by clicking on them.

Related

Android 2D game engine with canvas capability

Im looking for Android 2D framework which allows me to create canvas layer on which I can draw simple shapes like rect, oval atc (raster graphics). The canvas have to PERSIST everything I draw on it.
I found many engines (libgdx, andengine ...) but if they have capability to draw shapes, its only for one screen update. Reason becouse I dont store drawn shapes to some kind of List is becouse in app, the drawing occurs every screen update so I just want to modify canvas and dont remember anything.
Thanks for every answer.
As far as I know, android doesn't support something like that. Android uses double-buffering which means 2 alternatives "screens" that alternate each other so if you draw on one the next would be on random state.
There are tricks you can use to achieve what you want like draw both screens and then stop drawing, but android doesn't support such behavior because when you get hold of a canvas it's not certain that it returned exactly as what you did last frame, it doesn't specify what could cause an error, but if you ask me it could be anything that pops up on screen.
You don't really need an engine to do that, you can use a SurfaceView and draw on it (it supports shapes like the ones you want)

How to make a triangle, rectangle, polygon in Android?

If I select shapes like Triangle, Rectangle, Polygon, Curve etc then it must be able to draw specific selected shapes. Like Paint (this is an application offered by Microsoft for creating shapes and sketches). In Android, I have to select the shapes and should be able to draw like a Free hand drawing but it completely should be done it in code wise.
Same: I have to draw either directly select the triangle shape from the options given, or can draw a triangle of any base and height from scratch.
How could I do this in Android application?
You can use OpenGL ES
Open this link
Hope it will useful

Android Paint. 2 canvas?

I let my user draw geometries on it. So I store all the data(ie. coordinates) required for each geometries(ie. line, triangle, quads, etc). Now, I'm implementing a paint/brush on it which I don't care about all the points that was inputted. My problem is I need to call canvas.drawColor(Color.WHITE); every time the user modify the geometry resulting to clearing also the paint which is gone now and I don't have access to.
Is there any way to actually separate the two in two canvas and combining it later? I mean, the paint is directly draw on one canvas and the geometry on other canvas and combine it.
Yout can set the backgroundcolor of your View to White.
mView.setBackgroundColor(Color.WHITE);
This way you dont need to use
canvas.drawColor(Color.WHITE);
Check out TouchPaint.java in the API demos included in the Android SDK, for an example of how you can do what you want to do.

How to implement an eraser for a drawing app in Android

I have been searching all evening for some way to implement an eraser function for my drawing app. The most common answer is to simply paint the background color or image in, but this solution will not work for my application because I am implementing multiple layers (Gimp/Photoshop style).
The user should be able to draw a line with the brush tools provided in as many layers as they like (the onDraw method of my drawingview draws layer0...layerX on top of each other). Then if they choose the eraser tool it should cause any area of the current layer that they trace over to become transparent.
I cannot seem to find an appropriate class/function built in and am unsure how I could write it myself. I tried to do something like
Paint paint = new Paint();
paint.setAlpha(0);
and then use that Paint object to draw with, but that only draws an 'invisible' line.
I also attempted to use
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
but that just seemed to draw as normal and without effect. I'm probably using it incorrectly, but the Android documentation does not contain a clear description of what it does. I just happened to see it in some examples about modifying bitmaps.
I can supply code as needed, I am just not sure what would be helpful to solve my problem. Being pointed in the right direction would be the biggest help as I have not been successful with Google.
You can find the implementation of eraser function, create new canvas, brush function and save function, on this link :
create android drawing interface
it's have very good tutorial for making drawing app on android using motion event.

Android finger paint

I m developing an application to paint the the canvas using finger stroke with the help of FingerPaint application given at the site Here one of the recently drawn color overlap the color previously drawn at same palce. Is there any way to limit one or two color that doesn't get overlapped by other In other words if i had drawn red(or any that user wants) color on canvas then none of the color should hide this it will show ever n ever.Let me know if the problem is not clear to you
thanks in advance,..
If you are using a GLSurface you can use the normal method of GL pixel manipulation - in particular, getPixels(). There are many ways to have fun with pixels in GL - you can add blending, scaling, etc and even convert the existing canvas into a texture on a model in the scene.
If you are not using a GLSurface... someone else will need to help. :)

Categories

Resources