Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SUB that draws boxes with rounded corners.
#21
(09-15-2024, 05:43 AM)vince Wrote: is this gonna be another 10 page arms race? let me throw mine in then

Code: (Select All)
sub cboxf (x, y, w, h, r, c as _unsigned long)
    x0 = r
    y0 = 0
    e = -r

    do while y0 < x0
        if e <= 0 then
            y0 = y0 + 1
            line (x + r - x0, y + r - y0) - (x + w - r + x0, y + r - y0), c, bf
            line (x + r - x0, y + h - r + y0) - (x + w - r + x0, y + h - r + y0), c, bf
            e = e + 2*y0
        else
            line (x + r - y0, y + r - x0) - (x + w - r + y0, y + r - x0), c, bf
            line (x + r - y0, y + h - r + x0) - (x + w - r + y0, y + h - r + x0), c, bf
            x0 = x0 - 1
            e = e - 2*x0
        end if
    loop
    line (x, y + r)-step(w, h - 2*r), c, bf
end sub

Nice one, @vince!  Fast too.  +1 from me,

I like the think border yours can do, Steve. The one pixel edge mine does isn't very useful now that I think of it, ecxect maybe putting a highlight around a filled one.

- Dav

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
RE: SUB that draws boxes with rounded corners. - by Dav - 09-15-2024, 11:53 AM



Users browsing this thread: 7 Guest(s)