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.
Related
I am making an Android app for colour book, where I have various images with different parts, and when user touch on it - it will be coloured.
I have seen so many answers here for this question but all of them uses Flood Fill algorithm. I don't want to fulfill that part with only one touch, I want the user should fill it with his touch, as a painter uses his brush.
I am using Canvas' onTouchEvent, OnDraw etc. methods for getting the touched area painted, but when user draw his finger outside specific part of image, that part also get colored (even the outer part of Image also gets colored when user touch the background).
I want the user can only paint the specific area of that image and that area will not be fullfilled by only one touch (as FloodFill does), it should be painted as a painter paints with his brush.
Can anybody give me some advice how I can implement what I want?
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 am developing one application with drawing and all, One problem I am facing is I want single touch scaling image. I have done image scaling with multi touch but I am so stuck with single touch.
Example :-
I have one Rectangle on canvas. Now I want to scale and rotate that Rectangle with its one corner with one finger. I am finding this on google but not get perfect materiel or demo and else.
Please help me to find this.
For zooming with single touch this will help you
http://developer.sonymobile.com/wp/2010/05/18/android-one-finger-zoom-tutorial-part-1/
I was just playing with Android SDK Demos and I found the rotating dialer example which you can find here : Android Rotating Dialer and I'm curious about one thing. How can I set the image to rotate only when I click on image..not inside in or out. I don't want to rotate it if I click at the center (in white area) or outside of the image (again in white area).
Any suggestions how can I achieve this?
Interesting question.
This would be possible by modifiying the code of myOnTouchListener. Just before the switch statement you would perform a calculation to check whether the x,y coords of the touch were outside an inner radius and inside an outer radius.
Some simple Pythagoras and it wouldn't be too hard. If this was not the case then return true at that point.
suppose my bitmap is like
This image is actually in square transparent. I want to get the only viewable points as array so I can bound it and handle touch event on canvas. Right now it is square so when I touch at the corner of the image it still detect touch event on image. i don't want to do like this. Only if user clicked on viewable part then only action would be taken otherwise not.
For temporary I have used radius of image from center point it works fine but accurate, also if this image triangle part length is long then if it remain in square format user fill/get event on image outside.
I have used canvas to draw bitmap. Is there any other way or easy way to do this thing and handle event.
I have seen many games in that they used like custom shapes and touch event fire only on display part of object, how could i achieve this things.
Take a look at coordinates:
Android Canvas Coordinate System
and
http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/src/com/android/spritemethodtest/CanvasSprite.java?r=150
Which goes into sprite:
http://p-xr.com/android-tutorial-how-to-paint-animate-loop-and-remove-a-sprite/
This may help too:
http://www.droidnova.com/playing-with-graphics-in-android-part-vi,209.html
Some of that should be helpful.