• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why Graphics.drawRoundRect() not have symmetrical corners?

 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are the corners not all the same when drawing a round rectangle in Java? When I do:

drawRoundRect( 0, 0, 100, 100, 10, 10 );

it draws the left side corners differently than the right. What's going on? how do i get them to be the same?
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone know?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without seeing exactly waht is going on, and not having your code in front of me, is there some other component that may somehow be interfering? I can't think of anything else right off hand, and I guess I can't think of ever having run into that particular problem before. I have had weird things happen with graphics when I tried to stuff them into a space where they wouldn't fit properly, and java resized them for me.

I know, not much help...sorry.
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The curves will likely look fine to the naked eye, but if you scale the drawings (in MS Paint, or some other graphical program) you'll see the imperfection -- they are quite asymetrical. Varying the width and/or arcsize makes a little difference, but the result is still asymmetrical.

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone try this or make it work?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dan Bizman:
The curves will likely look fine to the naked eye



Well, there you go. Good enough is good enough, right? Besides, I ran your program and the rounded corners are defined by the placement of two or three pixels each -- how much more accurate could they be?

Scaling up bitmapped graphics always looks lousy -- that's why there are vector formats like SVG and PostScript.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if its absolutely mission-critical that it draws symmetrically you could write your own code to grab the image data of one corner, invert it, and then redraw it on the opposite side.
reply
    Bookmark Topic Watch Topic
  • New Topic