Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SUB that draws boxes with rounded corners.
#28
(09-15-2024, 01:16 PM)bplus Wrote: +1 @Vince fills are great but need a submission for jut rounded boxes without fills.

Code: (Select All)
sub cbox (x, y, w, h, r, c as _unsigned long)
    x0 = r
    y0 = 0
    e = -r
    do while y0 < x0
        pset (x + r - x0, y + r - y0),c
        pset (x + w - r + x0, y + r - y0), c
        pset (x + r - x0, y + h - r + y0), c
        pset (x + w - r + x0, y + h - r + y0), c
        pset (x + r - y0, y + r - x0), c
        pset (x + w - r + y0, y + r - x0), c
        pset (x + r - y0, y + h - r + x0), c
        pset (x + w - r + y0, y + h - r + x0), c
        if e <= 0 then
            y0 = y0 + 1
            e = e + 2*y0
        else
            x0 = x0 - 1
            e = e - 2*x0
        end if
    loop
    line (x, y + r + 1)-step(0, h - 2*r - 2), c, bf
    line (x + w, y + r + 1)-step(0, h - 2*r - 2), c, bf
    line (x + r + 1, y)-step(w - 2*r - 2, 0), c, bf
    line (x + r + 1, y + h)-step(w - 2*r - 2, 0), c, bf
end sub
Reply


Messages In This Thread
RE: SUB that draws boxes with rounded corners. - by vince - 09-15-2024, 09:10 PM



Users browsing this thread: 27 Guest(s)