Android-How to Draw a Alphabets by using certain Path? - android

I want to draw a Alphabetsenter link description here A to Z one by one. first i want to write 'A' in a particular path if it is correct, then it wants to move to 'B'.. All this should connect with points for example the following link shows how i expecting the same..

you can draw to the canvas in the onDraw method of the view class.

Related

How to delete first point from path which is drawn to android canvas

I want to draw a line on android canvas. This line must follow user's finger. I want to remove first point of path continuously. How to accomplish this. Thank you.
Save all the points in a linkedlist. Redraw the path every time a point is added/removed (i.e clear the screen, draw line from p0 to p1, from p1 to p2...). After a point is added and there are already say 100 points then remove the first to keep the list down to a fixed size.

Drawing and storing a user's touch path in libgdx

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?

Moving between two points in canvas

I have 2 points(x1,y1) and (x2,y2). I need to move the image from (x1,y1) to (x2,y2). Please let me know if there is any methods in android SDK to achieve this.
If you are doing a custom view that handles it's on onDraw method you could:
Create a path object:
Move to position 1 using the moveTo method
line to position 2 using the line2 method
Create a path measure object.
User the path measure object to animate to the position.(Here is an example of that--note you will have to do it a little differently as the code doesn't show View.onDraw & View.invalidate being called).
Alternatively if you aren't handling your own on draw, you might be able to simply use a TranslateAnimation.
Looks like all you need is an animation.
Search this site for Animation Drawable and you'll get tons of examples :)

android drawing on photos

I am looking to be pointed in the right direction for help. What I want to do is take a picture, and then be able to highlight certain aspects of it (i.e circle a door, comment on a color) right onto the picture. Basically what a Samsung note can do. What android package would I be looking at? What it looks like to me, is that I would use the picture as a canvas and then draw on top of the canvas(which is the picture), is that it basically summed up? Or am I missing something?
Another thing that I would like to do with the picture is add data for future identification. I know android has their Exif Interface for this, but what I cant seem to find any information on is, it possible to create my own tags for this class? For example adding a "who took it" tag.
You're going to need a custom view and override the onDraw method of the view. In the onDraw method you get a reference to a Canvas object. From there, you can do most of whatever drawing you need. If you want to take user input and draw with it, you're going to have to override the touch events, and keep track of what you want to draw and then draw in the onDraw method.
As for Exif data. If you want to develop for before Android 2.0, then you need a 3rd party library, I use sanselanandroid personally. If you don't care about pre 2.0, I head ExifInterface works well too. It looks like you can save any arbitrary tag using ExifInterface because it just uses a string tag, and then string value, but know that only your app will know to read that tag.

How to implement a DrawLine function ?

Question : Is there any better way to implement a function that draws line on the screen other than drawing circles on the input points ?
Details : I am trying to write a function which basically will draw a line.However the line will not be a regular colored line. This line will let user to copy pixels from one image to another trough that line , you can think It like "history brush" or "stamp" on Photoshop . My first thought was just get the points and draw circles on each point. Which is working but not smooth and have some bugs. The first problem is it is not working if user sweep his finger too fast. I thought it would solve problem if i can fill the dots between two points and then draw the line which is kind of work but this time drawing gets very slow. One other problem is that it never looks smooth.
Bresenham's line algorithm
Isn't the BitmapShader what you're looking for?

Categories

Resources