graphics

Discussion in 'Java' started by fozzy, Sep 22, 2003.

  1. fozzy

    fozzy Guest

    I want to move a small painted figure (fast)over a background image.
    The small figure is also rotating, I was thinking on just painting it on
    the graphics. But, when it moves, how can I erase the previous drawn
    figure in a smart way? Are there better ways to move a drawing over a
    figure?
    I checked tutorials on graphics2D but they just move over a white
    background, so one can easily clear the rectangle.

    pls advise, thanks

    len
    fozzy, Sep 22, 2003
    #1
    1. Advertising

  2. fozzy

    VK Guest

    I'm not too familiar with the jBlahBlah stuff from Swing, it may have a
    better solution. In the old-fashion way I would make
    Class myMovingObject extends Canvas {}
    Canvas has its own Graphics object corresponding to the canvas size, so you
    could place a picture on the canvas and manipulate it as a layer above your
    background picture.


    fozzy <> wrote in message
    news:bkmade$34r37$-berlin.de...
    > I want to move a small painted figure (fast)over a background image.
    > The small figure is also rotating, I was thinking on just painting it on
    > the graphics. But, when it moves, how can I erase the previous drawn
    > figure in a smart way? Are there better ways to move a drawing over a
    > figure?
    > I checked tutorials on graphics2D but they just move over a white
    > background, so one can easily clear the rectangle.
    >
    > pls advise, thanks
    >
    > len
    >
    VK, Sep 22, 2003
    #2
    1. Advertising

  3. On Mon, 22 Sep 2003 10:04:55 +0200, fozzy <> wrote:

    >I want to move a small painted figure (fast)over a background image.
    >The small figure is also rotating, I was thinking on just painting it on
    >the graphics. But, when it moves, how can I erase the previous drawn
    >figure in a smart way? Are there better ways to move a drawing over a
    >figure?
    >I checked tutorials on graphics2D but they just move over a white
    >background, so one can easily clear the rectangle.
    >
    >pls advise, thanks
    >
    >len


    The smartest way is to redraw the background image only over the
    previous position of the figure.
    The size of the area depends of the rotation of your figure, make a
    rotation of 45°, and canculate the bounding box of the new figure,
    then use this size to redraw the background.

    Good Luck


    Pierre Pintaric
    The Genuts Team.
    http://www.genuts.com/
    Pierre Pintaric, Sep 22, 2003
    #3
  4. fozzy

    Liu, Chunyen Guest

    The most efficient way of doing this is to pre-create
    rotated images of the original object. For example,
    you can create a new image every 30 degrees. Then
    you will have 12 images. Simply pick one of the
    rotated images closest t the current angle.
    That way, you don't need to dynamically calculate the
    new image and therefore the animation will be very fast.

    > -----Original Message-----
    > From: fozzy [SMTP:]
    > Posted At: Monday, September 22, 2003 3:05 AM
    > Posted To: comp.lang.java.programmer
    > Conversation: graphics
    > Subject: graphics
    >
    > I want to move a small painted figure (fast)over a background image.
    > The small figure is also rotating, I was thinking on just painting it
    > on
    > the graphics. But, when it moves, how can I erase the previous drawn
    > figure in a smart way? Are there better ways to move a drawing over a
    > figure?
    > I checked tutorials on graphics2D but they just move over a white
    > background, so one can easily clear the rectangle.
    >
    > pls advise, thanks
    >
    > len
    Liu, Chunyen, Sep 22, 2003
    #4
  5. Pierre Pintaric <> horrified us with:

    ....[twack!]...

    > The size of the area depends of the rotation of your figure, make a
    > rotation of 45°, and canculate the bounding box of the new figure,
    > then use this size to redraw the background.



    /Whoa!/ No, that only works for squares, not arbitrary rectangles. Imagine
    a long skinny rectangle at 45°. as it continues to rotate, it'd easily
    exceed the bounding box.
    Thomas G. Marshall, Sep 23, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman

    Convert e.Graphics to an image or bitmap

    Charles A. Lackman, Jun 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    15,505
    logon68
    Feb 10, 2011
  2. DB
    Replies:
    1
    Views:
    986
    Tuukka Toivonen
    Aug 19, 2003
  3. jk
    Replies:
    1
    Views:
    513
    Mike Treseler
    Jan 4, 2004
  4. suz
    Replies:
    6
    Views:
    5,206
    Jason Zheng
    Jul 26, 2004
  5. Derek Simmons

    Primitve 3D Graphics Library

    Derek Simmons, Aug 11, 2004, in forum: VHDL
    Replies:
    1
    Views:
    484
    John Williams
    Aug 12, 2004
Loading...

Share This Page