Toribash
Original Post
Rounded Quads!
Here's a nice little function to draw rounded quads for you!
I'm sure that at least some of the scripters out there will find this useful, and it'll make your interfaces a little prettier with a minimum of effort! :3

Here's the attached file in code, for those of you that like to copy/paste.

-- This function will draw a nice rounded quad for you!  I'm sure that you'll be able to make your scripts prettier with this :3
-- The quad is seamless, and works perfectly with transparency. It can't do textures though.
-- Written by Lapsus Antepedis
-- It works just like the normal draw_quad, except that it has a cornerradius variable as well.

function draw_rounded_quad(x, y, width, height, cornerRadius)

	--Top Left Corner
	draw_disk (x + cornerRadius, y + cornerRadius, 0, cornerRadius, 32, 1, -90, -90, 0)
	
	--Main Box
	draw_quad ((x + cornerRadius), y, (width - cornerRadius * 2), height)
	
	--Top Right Corner
	draw_disk (x + (width - cornerRadius), y + cornerRadius, 0, cornerRadius, 32, 1, 180, -90, 0)
	
	--Left Box
	draw_quad (x, (y + cornerRadius), cornerRadius, (height - cornerRadius * 2))
	
	--Right Box
	draw_quad ((x + (width - cornerRadius)), (y + cornerRadius), cornerRadius, (height - cornerRadius * 2))
	
	--Bottom Left Corner
	draw_disk (x + cornerRadius, y + cornerRadius + (height - cornerRadius * 2), 0, cornerRadius, 32, 1, 0, -90, 0)
	
	--Bottom Right Corner
	draw_disk (x + (width - cornerRadius), y + cornerRadius + (height - cornerRadius * 2), 0, cornerRadius, 32, 1, 0, 90, 0)
	
end
Attached Files
RoundedQuad.lua (1.2 KB, 29 views)
<+veb> dude___________________._____________________<hampa> the hosting center decided to raise the price
<+veb> I am to durnk to pu6t in the wriute commmand lol ___<hampa> and we only run irc on this machine which is a bit of a waste
<+veb> and u suxc u cant od it gfro me ______|______._____<Lapsus> How much power is behind the IRC server?
<+veb> ;oml?________________________________________<hampa> it is like delivering pizza using an airplane
Nice :3
lalalla
function draw_line(x1,y1,x2,y2,step,thickness,quality,r,g,b,a)
  local dx, dy = x2 - x1, y2 - y1
  --if(dx < 0) then dx = dx*-1 end
  --if(dy < 0) then dy = dy*-1 end
  local mag = math.sqrt(dx*dx + dy*dy)
  local step = step
  dx, dy = dx/mag, dy/mag
  for i=0, mag/step do
    local x, y = x1 + dx*step*i, y1 + dy*step*i
        set_color(r, g, b, a)
        --draw_quad(x, y, thickness, thickness)
        draw_disk(x, y, 0, thickness/2, quality, 2, 0, 360, 0)
    end
end

function draw_polygon(coordinates,step,thickness,r,g,b,a)
    local NC = #coordinates
    echo(NC)
    if(NC > 3) then
    for b=1,NC do
    if(b ~= NC) then
        x1 = coordinates[b].x
        y1 = coordinates[b].y
        x2 = coordinates[b+1].x
        y2 = coordinates[b+1].y
    else
        x1 = coordinates[b].x
        y1 = coordinates[b].y
        x2 = coordinates[1].x
        y2 = coordinates[1].y
    end
        local dx, dy = x2 - x1, y2 - y1
        local mag = math.sqrt(dx*dx + dy*dy)
        local step = step
        dx, dy = dx/mag, dy/mag
        for i=0, mag/step do
        local x, y = x1 + dx*step*i, y1 + dy*step*i
        set_color(r, g, b, a)
        draw_quad(x, y, thickness, thickness)
        end
    end
    else
    echo("Error, need more points")
    end
end
Last edited by Blam; Mar 6, 2008 at 05:00 PM.
:D