• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Graphics.drawRoundRect() not have symmetrical corners?

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
anyone know?
 
C. Alan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Anyone try this or make it work?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic