Then you'd have the other side be longer, i'm not seeing the use for such a transformation.rmcode wrote:- Check if one of the sides is (noticeably) longer than the other -> If it is the graph should be turned by 90 degrees
Why not just do this?:
- Calculate the rectangle around your graph by going through all objects, and recording the global minimum and maximum x and y coordinates.
- Calculate the scaling needed with rectangleWidth/screenWidth and rectangleHeight/screenHeight
- Select the smaller one (so that for most resolutions (screen sizes that aren't 1:1 ratio) we don't crop, nor do we stretch non-proportionately)
- Do restrict the zoom so it doesn't blow up for 0-1 elements though. (something like math.min(1.0,the_above) would probably do the trick)
Other than this, maybe you should actually store the scale values per-step/per-commit, and smoothly interpolate between the scaling when drawing; like a simple linear interpolation or somethin when going through all the states of a repo, or a bounce for selecting one commit... if you can even do that, i don't know since i didn't have a chance to try this out yet.