You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love to have this function in addition to dxDrawCircle.
The difference here would be you have a clear ring while the center is empty (unlike in dxDrawCircle where you can just make a color gradient fading out towards the center / outside).
Right now you can only make a ring using images or with a ton of dxDrawLines, but no matter how many calls you make you still see pixels
Example function (like it would be in wiki):
bool dxDrawRing ( float posX, float posY, float outerRadius [, float ringWidth = 5, float startAngle = 0.0, float stopAngle = 360.0, int startColor = white, int stopColor = startColor, int segments = 32, int ratio = 1.0, bool postGUI = false ] )
Required Arguments:
posX, posY -- like dxDrawCircle
outerRadius -- The outer/max radius of the ring
Optional arguments:
ringWidth -- The thickness of the ring, expanding towards the center of the ring (so max allowed should be the 'outerRadius', that would make a full circle)
startAngle, stopAngle -- like dxDrawCircle
startColor -- The color to start at startAngle
stopColor -- The color to end with at stopAngle (That gives the oppertunity to make a ring with a color gradient or a fading-out ring towards the end)
segments, ratio, postGUI -- like dxDrawCircle
Thanks for reading and huge thanks in advance if this gets into the game!
The text was updated successfully, but these errors were encountered:
This is the best way to render a ring in mta at the moment without using an image file - render your own ring by pixels. But this takes quite long, even for just creating a renderTarget/texture its about 400ms with this sizes / detaillevel
SX, SY = guiGetScreenSize();
local sin = math.sin;
local cos = math.cos;
local txd = nil;
function dxDrawRing(posX, posY, outerRadius, ringWidth, startAngle, stopAngle, detailLevel, r, g, b, a)
local pixels = dxGetTexturePixels(dxCreateTexture(outerRadius * 2, outerRadius * 2));
for i = startAngle, stopAngle, 1 / detailLevel do
local iRad = math.rad(i);
for radius = outerRadius - ringWidth, outerRadius do
x = posX + cos(iRad) * radius;
y = posY + sin(iRad) * radius;
dxSetPixelColor(pixels, x, y, r, g, b, a);
end
end
return dxCreateTexture(pixels);
end
txd = dxDrawRing(SY / 4, SY / 4, SY / 4, 10, 0, 360, 10, 255, 165, 0, 64);
function render()
dxDrawImage(SX / 2 - SY / 8, SY / 2 - SY / 8, SY / 4, SY / 4, txd);
end
addEventHandler("onClientRender", root, render);
I would love to have this function in addition to dxDrawCircle.
The difference here would be you have a clear ring while the center is empty (unlike in dxDrawCircle where you can just make a color gradient fading out towards the center / outside).
Right now you can only make a ring using images or with a ton of dxDrawLines, but no matter how many calls you make you still see pixels
Example function (like it would be in wiki):
bool dxDrawRing ( float posX, float posY, float outerRadius [, float ringWidth = 5, float startAngle = 0.0, float stopAngle = 360.0, int startColor = white, int stopColor = startColor, int segments = 32, int ratio = 1.0, bool postGUI = false ] )
Required Arguments:
posX, posY -- like dxDrawCircle
outerRadius -- The outer/max radius of the ring
Optional arguments:
ringWidth -- The thickness of the ring, expanding towards the center of the ring (so max allowed should be the 'outerRadius', that would make a full circle)
startAngle, stopAngle -- like dxDrawCircle
startColor -- The color to start at startAngle
stopColor -- The color to end with at stopAngle (That gives the oppertunity to make a ring with a color gradient or a fading-out ring towards the end)
segments, ratio, postGUI -- like dxDrawCircle
Thanks for reading and huge thanks in advance if this gets into the game!
The text was updated successfully, but these errors were encountered: