Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: What solution (of these 2) is the fastest way to paint in graphics?

  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Question What solution (of these 2) is the fastest way to paint in graphics?

    I need to max out the speed of the repainting of some widgets.
    So I'm making my own widget system that only contains the things that I need so that it dont calculate unnessecary stuff.
    Anyhow, these two solutions both draw same pattern, but which is fastest?

    1
    Java Code:
    g.drawRect(X, Y, width, height);
    g.drawLine(X+1, 20, X+width-2, 20);
    2
    Java Code:
    g.drawRect(X, Y, width, height);
    g.drawLine(X, 20, X+width, 20);
    In number 2 I draw a line that intersects two pixels with the drawn rectangle.
    In number one I remove those two pixels of intersection but at the cost of calculating a new x value twice.'
    Which one is the preferred and fastest way to draw this pattern?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: What solution (of these 2) is the fastest way to paint in graphics?

    I really don't think you're going to see a major difference in either one. But if you're worried about it, you're going to have to benchmark it for yourself within your own context.
    DarrylBurke likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Using Graphics outside of a paint method
    By Catfish1 in forum New To Java
    Replies: 6
    Last Post: 10-26-2010, 08:57 PM
  2. paint in vector graphics
    By koddy in forum New To Java
    Replies: 7
    Last Post: 06-16-2010, 08:30 AM
  3. Two JPanels and paint(Graphics)
    By ingfy in forum New To Java
    Replies: 3
    Last Post: 04-27-2010, 08:51 PM
  4. print variable with paint(Graphics g) ??
    By tghn2b in forum New To Java
    Replies: 10
    Last Post: 12-29-2008, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •