1

Possible Duplicate:
square to trapezoid

Here is what i want to do. I'm currently drawing with Awt librairy and use the paintComponent method to draw (a grid for example). I draw colors, lines, images, etc. What i want to do is to take the Graphics g parameter of paintComponent and apply a trapezoid-like transformation after all my draw methods. My result will simulate a grid in space in 3D:

     --------
    - - - -  -
   -  - -  -  -
  -  -  -   -  -
 ---------------- 

like this.

Note: I don't want to draw a trapeze, or draw a rectangle into a trapeze. This won't work for me. And i'm open to change librairy (swing or whatever). I'v been searching for quite a while and i haven't found any example about this, clear enough at least for me to understand. Any tips, links? Thanks.

edit: I'm drawing in a JPanel

Community
  • 1
  • 1
Sophie
  • 324
  • 3
  • 12
  • It's simple. Create a *normal* grid say at y = 0, and position the camera. – nullpotent Oct 05 '12 at 15:25
  • 1
    I'm not using 3D, I'm simulating it­. – Sophie Oct 05 '12 at 15:29
  • I don't know the actual math/setup involved, but if you're using a `Graphics2D`, I'm guessing you need to use `Graphics2D.transform(AfflineTransform)`. – Clockwork-Muse Oct 05 '12 at 15:52
  • 1
    @Clockwork-Muse AffineTransform maintains parallelness and straightness. Obviously this transformation does not maintain parallelness so an AffineTransform won't enable this feature. – Guillaume Polet Oct 05 '12 at 16:40
  • 1
    @Clockwork-Muse: Guillaume is correct; [`javax.media.jai.PerspectiveTransform`](http://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PerspectiveTransform.html) may be an alternative. See also this [Q&A](http://stackoverflow.com/q/6157886/230513). – trashgod Oct 05 '12 at 16:55

0 Answers0