RoundRectShape Segment property not working

I’m experiencing some troubles in working with rounded rectangle.

  1. The round sections of the edges of things rendered on the screen by the DrawRoundRect and FillroundedRect commands appear rather jagged. The AntiAlias property of the graphics class does not seem to have any effect. So I thought I’d use the corresponding vector graphics class RoundRectShape, which has a Segments property to control the edge smoothness. However, working on Windows 7, I see no effect of adjusting the Segments property value.

Is this property ineffective in Win7, or am I missing something?

The following code example in a canvas paint event yields the same result for any value assigned to objShp.Segments :

Dim objShp as new RoundRectShape
objShp.Segments = 100

objShp.Width = 200
objShp.Height = 200
objShp.CornerHeight = 40
objShp.CornerWidth = 40
objShp.FillColor = g.ForeColor
g.DrawObject objShp, 110 , 110

Hi
I experienced very same on window7. I tested “Use GDI Plus” is On & Off in before Xojo vesion Real studio. If this is OFF, RoundRect is correct shape. If On, it is very not rounded. Please test this.

Thanks Katuzo. I did forget to turn GDIplus on. Therefore anti-aliasing was disabled, which resulted into the jagged edges.

With anti-aliasing enabled, the edge smoothness is acceptable. It appears that the Segments property signifies the total number of edge segments on all 4 edges. Using high values for the Segments property does not seem to produce significantly better results that the default value 0. The DrawRoundRect and FillroundedRect commands yield results similar to the RoundRectShape class with Segments = 0.

Hi! Gerard.

I wrote test code below. I make Graphic Big , after make small. But this is needing more memory isn’t it. Is It a bit smooth edge ? Can you see It?
//////
Dim objShp as new RoundRectShape
objShp.Segments = 0

objShp.Width = 400
objShp.Height = 400
objShp.CornerHeight = 80
objShp.CornerWidth = 80
objShp.FillColor = g.ForeColor
Dim thePic As Picture
thePic=New Picture(900,900,32)
thePic.Transparent=1
thePic.Graphics.AntiAlias=True
thePic.Graphics.DrawObject objShp, 220 , 220
g.DrawPicture thePic,0,0,450,450,0,0,900,900

i.e
Please compare below.

Dim objShp as new RoundRectShape
objShp.Segments = 0
objShp.Width = 2008
objShp.Height = 200
8
objShp.CornerHeight = 408
objShp.CornerWidth = 40
8
objShp.FillColor = g.ForeColor
objShp.Scale=1/8
g.DrawObject objShp,110,110

It seems as same as first code.

Kazuto, I tested your code. Nice idea.

On Win7 I clearly get better results for the second approach. I changed it a bit to be able to verify the effect of the “magnification” factor, for which you used the value 8. Choosing lower values down to 1 for the variable r does not seem to make much difference.

Dim r as Integer = 8
g.AntiAlias = true
Dim objShp as new RoundRectShape
objShp.Segments = 0
objShp.Width = 200r
objShp.Height = 200
r
objShp.CornerHeight = 60r
objShp.CornerWidth = 60
r
objShp.FillColor = g.ForeColor
objShp.Scale=1/r
g.DrawObject objShp,100,100

I’ve been testing the RoundRectShape class a bit more, and I feel that smoothness is acceptable. The only remaining problem is that the curved edges of borders look rather unsophisticated, unfortunately. I could draw my own borders, but that would require a lot of programming, especially with rotation, and I think that’s what we have Xojo for.

Another missing feature is the possibility to draw dashed and dotted lines. Quite annoying, because these seem rather basic graphics attributes to me.

Gerard, It is very difficult problem indeed. I think that we should simply take method to use jpg or PNG graphics was drawn with PhotoShop or some other soft. But Some cases, it needs control directly Graphics on UserInterface or other show Graph or so. This is Windows OS problem I think in result. Mac OSX has very beautiful Screen Drawing with Quartz2D, So I create graphics code very smoothly.
Is It being same problem in Other IDE as Visual Basic? I want to know that.