Question

I have a java.awt.canvas object and I draw stuff with the Graphics2D (which I get from the bufferStrategy) and I'd like to "zoom" in and out.

So if I zoom in (scaling it up by a factor of 1) such that a line I draw from (0,0) to (10,10) Would be in reality drawn from (0,0) to (20,20)

Is this possible, or do I have to implement this myself?

Était-ce utile?

La solution

Take a look at Graphics2D: http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html

You apply a suitable transformation to the graphics to achieve many transformations, rotate, scale (aka zoom) and translation. Simplest way to zoom would probably be

graphics2d.scale(2.0, 2.0); // draw everything twice the original size
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top