Tudor
Tudor

Reputation: 4164

iOS OpenGL or CoreGraphics smooth rectangle drawing

I'm trying to draw a filled rectangle in the drawRect and the rotate it by 5 degrees. The problem is that when I rotate this rectangle, the edges look very jagged. I have the feeling that this needs some anti-alising (or something similar), but I can't find any good sources of more information.

Does anyone have a good hint?

Upvotes: 0

Views: 634

Answers (1)

user836218
user836218

Reputation:

It really isn't possible to have a nice, natural curve on a computer because if you look closely you will always see that it really isn't a curve, it's a jagged line of squares.

More answering your question, if you want your line to be softer, you could blur it with a CIFilter. Remember that when you rotate something by anything other than 90, 180, 270, or 360 degrees you will lose quality. Your rectangle doesn't need anti-aliasing until it's rotated, and I'm sure apple has written a beautifully complicated way to blend/antialias your context.

Probably the easiest way to do this is to draw the individual lines in your rect at the slant instead of rotate the rect after you draw it.

Upvotes: 1

Related Questions