Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

round rectangle with only top corners rounded  RSS feed

 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just trying to create a rounded rectangle with only the top left and right corners rounded. I'm not great at doing custom drawing so was wondering if anyone knew how?

Sincerely,
Christopher Dancy
 
Campbell Ritchie
Sheriff
Posts: 53773
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filled or empty?
If filled, cheat by superimposing a smaller ordinary Rectangle, maybe?
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well... the idea is the rectangle is actually a button and being used kind of like a tab, or at least in the shape of a tab anyway.
 
Campbell Ritchie
Sheriff
Posts: 53773
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a search; there are occasionally threads on this forum about round buttons, or round windows, etc. They might help.
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea i've been searching and only found the obvious, which is using a roundrectangle, but that's not going to work. It's the hard coding of the pixels, which would be drawing the lines of the corners by hand, so to speak, that i've never done before. I guess there will have to be a first for everything...
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A combination of Graphics#drawLine and Graphics#drawArc should do the stuff for you.
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, I didn't get exactly what I wanted( time constraints being the reason ) but I got close enough. So for anyone else looking for a reasonable answer...



Basically what's going on, is that I'm drawing the left side of the shape. Than I draw an arc from the top of the leftside to the top of the right side, than draw a line for the right side. x and y are starting points with w and h being width and height. Hope that helps anyone else in the same boat.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!