I'm developing a finger paint type of application . I want a erase functionality that delete a single full stroke (i don't want point by point or full screen deletion) I want exactly to delete the strokes(a single stroke is points between touch down and touch up). Is there any predefined method in the android canvas do this stroke deletion ?
Keep a list of all the strokes. When you want to delete one, remove it from the list, invalidate your view, and recreate the canvas by walking through the full list of all strokes.
Related
I want to draw some path with user's touch. if users moves finger from one position to another position a path will be drawn exactly as user moved finger.
We can draw a line with by defining color but i want to draw that line with sprite(image).
What I exactly meant is I just want to use image using sprite instead of using color to draw line. is it possible with LibGDX? if yes , how can we do that? and how will I generate image to use as sprite for that?
I my app I have some shapes , I want to fill the specified color in it using touch and gesture. the user finger finger will move inside the shape to fill the color in it , It has starting point so that it should always start from the right corner until it gets the last corner which should be the ending corner.
is the picture link so that you guys can easily understand what I am trying to say.
in this picture you can see the white space of the center shape , I want to fill it with user finger touch.
I have read to many gesture techniques including the gesture builder , but they are free form drawings , so in my app I have to face do following thing
1. To fill under the predefined shape
2. The shape should be filled in a single way , ie from starting point towards the ending point.
3. in other Examples they are drawing on canvas , in my case What should I use ??
Please answer me of my confusions or at least tell me how to do it, Please give me a starting point.
I'm struggling with something I would expect to be straight forward with libgdx.
In short this is a "finger paint" app where I want to draw a path of a certain width where the user touches the screen.
I've earlier done this by using a plain Android android.view.View. I had a android.graphics.Path in which I stored the coordinates of the user's current touch. In the onDraw() method of the view I drew the path to the android.graphics.Canvas. Whenever the user released a finger I drew the path to an offline canvas/android.graphics.Bitmap which also was drawn in the onDraw() method. Plain and simple.
How can that be done using libgdx?
I have tried using a com.badlogic.gdx.graphics.Pixmap that I can draw a line to whenever the user moves a finger. This works well except the fact that I'm unable to control the witdh of the line using Gdx.gl.glLineWidth(). I know I can draw a rectangle instead of a line to set the width, but Pixmap doesn't seem to have any means of rotating, so I don't see how this can be done.
I can use a com.badlogic.gdx.graphics.glutils.ShapeRenderer for drawing lines (or rectangles) in com.badlogic.gdx.Screen.render(). As far as I can see I then need to store every single touch point of the current touch, and then draw all lines on render. Whenever the user relases a finger I guess I can store the screen as-is with something like com.badlogic.gdx.utils.ScreenUtils.getFrameBufferPixmap(). Hopefully there is a easier way to achieve what I want.
I ended up drawing circles on a pixmap where the line should be:
One circle on touchDown
Several circles from last touch point to next touch point reported to touchDragged
I'm not very happy with this solution, but it kinda works.
Maybe you can calculate line dot coordinates manually and use triangles to draw them on pixmap? Like use 2 triangles to form (rotated) box?
I want to make drag and drop game in android
at initial stage image is drawn on canvas and at touch event it will move from that position and put at the specific point
what i can do for this? can any one suggest me something
I want to add undo & redo feature to the finger paint, does anyone got ideas?
it is suitable to use in finger paint of android API demos.
You want to record your drawing steps, such as using an array of Paths every time a new path is drawn. When the undo button is pressed, you decrease your "draw counter" by one and redraw all the paths up to your "draw counter". When you redo, increase your "draw counter" by one and redraw all the paths up to the counter (or end of the array, naturally!). And after undoing and then drawing anew, remove the later entries from the draw array.