Hi,

I've just been experimenting with GDlib, since I find it very interesting to build pictures I use on my homepage on the fly.

Well, here's my problem: I want to draw a rounded corner. This works well with imagefilledarc(), but it's just so rough (I'm not sure of the English word) when viewing it as a PNG!

Is there a way to smoothen this circle? Maybe a higher resolution? Or antialiasing?

I hope someone can help me, thanks,

Zumm

    Antialiasing? Does [man]imageantialias[/man] help (especially the user notes)?

      Ich befürchte es fast. Ich habe da auch schon durchgeguckt und damit experimentiert. Leider blicke ich durch den Code nur bedingt durch, da er nicht kommentiert ist. Das Endergebnis ist auf jeden Fall super, nur kann ich den Code als ganzes nur für ganze Kreise benutzen, nicht für "Tortenstücke".

      Ich werde mich damit noch beschäftigen, bin aber für andere Vorschläge immer offen.


      EDIT:
      Oops. That's the problem with surfing through both English and German pages.

      I'm afraid so. I was looking through that code in the user's notes and was experimenting with it. Unfortunately I don't understand the code completely, since there are no comments whatsoever. The final result is awesome, but I can use the entire code only for circles, not fot parts of a cirlce (like imagefilledarc()).

      I'll be working on that, but I'm always open to other suggestions.

        I'd be reluctant to take sebbi's approach and go pixel by pixel (or even line by line) across the entire image - not in PHP anyway - and the later optimised version relies on the symmetries of a digitised circle, symmetries a filled elliptical arc would usually lack.

        The note by n-dream from 19 February looks the closest to what you want. It does antialiased unfilled ellipses. The line to change would be the for($i...) statement. Replace the 0 with the starting angle, and the 2*(M_PI) with the ending angle (make sure the ending angle is larger than the starting angle: add a full circle to the ending angle if you need to make an arc larger than a half-circle). Those are in radians, and you'd no doubt be specifying degrees (to conform with imagefilledarc), so adding a couple of lines at the beginning using deg2rad() to convert the angles would be needed. (You might also want to adjust the default value of $segments depending on how big these arcs are).

        As for filled ellipses, Trimbo's suggestion further down to draw a hollow antialiased shape on top of an ordinary filled one could work.

          That's a great idea, thank you for this very detailed answer! It helped me understand a lot. I'll try right away.

            Write a Reply...