I'd like to make an Android app that will display a drawing of lines and I'd like to make something beautiful (big challenge).
Basically the app will show a drawing based on x y coordinates. The result must be identical to another drawing in a web based app. For the web based app, we'll be using this library.
I know how to draw paths on a canvas in an Android app but I don't know how to apply a custom effect on it. I've noticed I could use a PathEffect with this method:
paint.setPathEffect(myEffect);
but I'm not sure how to create another effect than the available ones (ComposePathEffect, CornerPathEffect, DashPathEffect, DiscretePathEffect, PathDashPathEffect, SumPathEffect).
Any tips and help would be much appreciated!!
An option would be to look in the source code of these path effects and understand how do they work, what's the idea, and derive how you could make your own path effect.
Related
I'm trying to make an app where I can show some statistics.
I have some data that I collect from an STM microcontroller each 5 minutes, and with those data, i want to be able to draw a curve with this data, something like this :
https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ56Bh-zxV5SZ0OYfaO0sLlxYCuZG0PbDtRR95opMtU80SPDx2r
So, what element in android can allow me to do so and how should i process the data i have ? I thought about using canvas, and making point then drawing the curve using those points, is that a valid method ?
And thanks
You can implement your own CustomView, which allows you to draw, like in a canvas. You can draw lines, curves and charts, but you must implement it manually, by extending and overriding View class method. But it isn't hard. The abilities of the CustomView is wide, you can even use it for simple games. So check this tutorial, if you want to know more.
But if you haven't time for it, you can use libraries, that do all work for you, just like this.
find some components to try in the Graphics section https://android-arsenal.com/free
william chart looks really cool!
im new to this android things. And i have to develop an application that can help an autism to learn numbers. I have a few ideas and I've been trying to learn and implement the code. But it's failed. The question is how can i apply the motion code or sprite to draw a numbers or letter? For example like this, i wanna make the penguin move through the line and draw a number nine.
There is example from mybringback.com which is the image move to draw a rectangle. How can i implement it to draw a number? Im sorry if i asking too much, i just trying to get some ideas.
I think that you should first build an utility program, in order to create the "path vector".
What I mean by path vector is simply a vector of Points (where a point has x value, and y value). And your utility should let you draw whatever you want, with a simple pen. You should draw on surface and store points when mouse is down, and ignore points when mouse is up.
Then, in the main program, you will just have to read at the path of your number/letter.
I've tried to implement something like this for the Sugar OLPC platform, without serializing path into files : I was able to draw, and to view the animation. And I used the process I've just described you.
Hope it can help you.
P.S : I used the word mouse, but you guessed that I talk about finger ...
There are various ways to achieve animation effects. One approach that is quite versatile involves creating a custom View or SurfaceView in which you Override the onDraw method. Various tutorials can be found on this; the official Android discussion of it is here:
http://developer.android.com/guide/topics/graphics/2d-graphics.html#on-view
Your implementation will look something like this:
// Find elapsed time since previous draw
// Compute new position of drawable/bitmap along figure
// Draw bitmap in appropriate location
// Add line to buffer containing segments of curve drawn so far
// Render all segments in curve buffer
// Take some action to call for the rendering of the next frame (this may be done in another thread)
Obviously a simplification. For a very simplistic tutorial, see here:
http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/1733/
Note that different implementations of this technique will require different levels of involvement by you; for example, if you use a SurfaceView, you are in charge of calling the onDraw method, whereas subclassing the normal View lets you leave Android in charge of redrawing (at the expense of limiting your ability to draw on a different thread). In this respect, Google remains your friend =]
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.
I am hoping this question/issue is not too vague as I have tried asking something earlier but seemed to have came to a dead end.
Basically I am looking at stretching/pinching parts of a Bitmap within my Android project. There would be coordinates passed to the function in order to indicate where the move would need to take place (x,y).
I need to find a way to shift pixels up and down (in either a line or arc type format) and allow the pixels in between to be warped accordingly (not disappear or hide).
A sample image of what I am trying to achieve would be something like:
I would paste an image here but apparently am not allowed yet. (Image URL: http://t1.gstatic.com/images?q=tbn:ANd9GcQtLEHS-ZRQs3p7XmeU2TM6Vwgfh7DGnh-5nDIDu3Yd7zTIR0zX)
(Just grabbed a random Google face warp)
I have read about a few things like openCV and javaCV but they seem like overkill. I am simply looking for something that might allow me to move an array of coordinates from a source point to destination and allow for a smooth warp.
Any help/information is greatly appreciated.
Brad,
Heres a link on how to create a smudge tool. That should help you create images like the one you included within your post.
Hope that helps!
To explain my problem, I am going to start from a case study that is not what I have to do but which will give you a good idea of what I am talking about.
Imagine the map of the US in which you have the states / provinces. Each of these provinces has got a shape that is random (by random I mean it is not a rectangle, a triangle or a circle). I need to build these shapes independantly, size them correctly and put them at the correct place on the screen to represent the country. Finally, each of these province should be clickable.
To achieve that :
1) I don't want to use google map
2) I guess that I'll have to construct each provine using android path and android region ... can you confirm?
3) Is there a graphical tool for building these paths (photoshop import ?)
4) Assuming that I succeed to build the path, how can I put them at the correct place on the screen ?
5) How can I make these path clickable ?
Basically, I want to build an interactive map with clickable items that doesn't use Google map because it won't necessarly be a real map.
Thanks for your help,
R.
There are lot of variables in the problem you describe:
If you don't want to use google-maps, you'll need to use another engine. There are a few open-source ones available.
If you feel you don't need a map engine, you'll need to provide you're own image of the US to draw on an pin the image to the View
How do you plan to draw the boundaries? Do you have coordinate data for the boundaries or do you plan to draw them manually.
I would suggest first looking at openstreetmap: http://www.openstreetmap.org/ The have a lot of information and tools on creating Maps. From there you can attack adding to the phone. Or you can use their web api and build a web view for doing what you suggest.