69 lines
2.0 KiB
Plaintext
69 lines
2.0 KiB
Plaintext
--@client
|
|
|
|
function render.drawWedge(x, y, w, h, angle, mouthSize, fidelity)
|
|
if w > 0 and h > 0 and mouthSize <= 360 then
|
|
local vertices = {}
|
|
|
|
vertices[1] = { x = x, y = y, u = 0, v = 0 }
|
|
|
|
local _ang = -math.rad(angle)
|
|
local _c = math.cos(_ang)
|
|
local _s = math.sin(_ang)
|
|
|
|
for ii = 0, fidelity do
|
|
local _i = ii * (360 - mouthSize) / fidelity
|
|
local _radd = math.rad(_i)
|
|
local _x = math.cos(_radd)
|
|
local _u = 0.5
|
|
local _y = math.sin(_radd)
|
|
local _v = 0.5
|
|
|
|
local _tempx = _x * w * _c - _y * h * _s + x
|
|
_y = _x * w * _s + _y * h * _c + y
|
|
_x = _tempx
|
|
|
|
vertices[ii + 2] = { x = _x, y = _y, u = _u, v = _v }
|
|
end
|
|
|
|
render.drawPoly(vertices)
|
|
end
|
|
end
|
|
|
|
function render.drawArc(x, y, ang, p, rad, seg)
|
|
seg = seg || 80
|
|
ang = (-ang) + 180
|
|
local vertices = {}
|
|
|
|
table.insert(vertices, {x = x, y = y})
|
|
for i = 0, seg do
|
|
local a = math.rad((i / seg) * -p + ang)
|
|
table.insert(vertices, {x = x + math.sin(a) * rad, y = y + math.cos(a) * rad})
|
|
end
|
|
|
|
render.drawPoly(vertices)
|
|
end
|
|
|
|
function render.drawFilledCircle(x, y, radius, seg)
|
|
local cir = {}
|
|
|
|
table.insert(cir, { x = x, y = y, u = 0.5, v = 0.5 })
|
|
for i = 0, seg do
|
|
local a = math.rad(( i / seg ) * -360)
|
|
table.insert(cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 })
|
|
end
|
|
|
|
local a = math.rad(0)
|
|
table.insert(cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 })
|
|
|
|
render.drawPoly(cir)
|
|
end
|
|
|
|
function render.drawRotatedSimpleText(x, y, text, ang)
|
|
local m = Matrix()
|
|
m:translate(Vector(x, y, 0 ))
|
|
m:rotate(Angle(0, ang, 0))
|
|
|
|
render.pushMatrix(m)
|
|
render.drawSimpleText(0, 0, text)
|
|
render.popMatrix()
|
|
end |