I have a Android program which you type in equation and them program display you in “new” layout a graph, its like coordinate system.You have function line, x line, y line… like school basic, you know, easy one.
But if your equation numbers are to hight like: “x*x*40″ your graph line is to big to be on display. So here i need yur help.
In android you can move picture up, down, left, right, zoom,… and i what to do same with a graph.I found a tutorails like this one:http://obviam.net/index.php/displaying-graphics-with-android/
,but this contains picture and i dont have picture!I have no picture or what so ever. Program works in Canvas and draw lines with command like this:”g.drawLine(x1, y1, x2, y2, color);” and the and it looks somethink like this in full screen:
http://grockit.com/blog/collegeprep/files/2009/12/14.JPG
So here is problem how to move like picture but its not a picture. In a lot of examples you must have a picture like R.drawable.image, but here are just calculated lines.
I have one idea how to do it, but its probably stupid:
-if you made a graph bigger than your screen (much bigger) and than do a screenshot, save like picture and than move like picture as in example
(if you need more explanation i can do it) sry if my English was bad 🙁
Thank you
Well, your best bet here is to use OpenGL. Otherwise, not only will you have problems with lines sometimes being to big or to small for a given screen, but also with different screen resolutions (your line might be too big for a 320×480 screen, but it will very well become too small for some of the new 1280×720 screens).
Here’s what I would do:
when surface is initialized, the opengl viewport is initted to screen’s width and height
also the surface’s far side’s height will be set to keep the proportions with those of the screen.
you can then use
Canvasand itsdrawxxx()methods to create a bitmap with your graph and text and whatever else you want to display.then you use that bitmap to make a texture for a rectangular poligon that you draw in your orthogonal perspective.
now the size of the graph will always scale properlly with the user’s screen size (like fit in all the time)
also now you can easily add zoom and scroll options