Jump to content

dxDrawRounded using Images


Recommended Posts

Posted
function drawRoundedRectangle ( x, y, w, h )
    -- draw image
end

Curious if I'm able to make a function like this, and resize the image without blurring it out. Resizing both the width and height.

For example, using this image -

UFIoOMU.png

  • Moderators
Posted (edited)

Hmm, you could try to generate it with a browser.

 

> browser

https://wiki.multitheftauto.com/wiki/CreateBrowser

 

> html + css

<section style="width:300px;height:100;background-color:white;border-radius: 25px;"></section>

 

> get

https://wiki.multitheftauto.com/wiki/DxGetTexturePixels

https://wiki.multitheftauto.com/wiki/DxGetPixelsSize

 

> set

https://wiki.multitheftauto.com/wiki/DxCreateTexture

https://wiki.multitheftauto.com/wiki/DxSetTexturePixels

 

(or just generate the corners, color = white = #fff is recommended)

Edited by IIYAMA
Posted
Just now, IIYAMA said:

Hmm, you could try to generate it with a browser.

 

> browser

https://wiki.multitheftauto.com/wiki/CreateBrowser

 

> html + css


<section style="width:300px;height:100;background-color:black;border-radius: 25px;"></section>

 

> get

https://wiki.multitheftauto.com/wiki/DxGetTexturePixels

https://wiki.multitheftauto.com/wiki/DxGetPixelsSize

 

> set

https://wiki.multitheftauto.com/wiki/DxCreateTexture

https://wiki.multitheftauto.com/wiki/DxSetTexturePixels

 

 

Yeah I know its possible with CEF, but I want to avoid that. Trying to do it through Dx, I've seen people do something with dxDrawImageSection, any idea on that?

  • Moderators
Posted
3 minutes ago, ℓιgнт said:

Yeah I know its possible with CEF, but I want to avoid that. Trying to do it through Dx, I've seen people do something with dxDrawImageSection, any idea on that?

This function can be used to repeat the same image, it might be possible that they use the rotation/rotationCenterOffsetX/rotationCenterOffsetY property for each new repeated image as offset.

But I have never seen anybody do that. So that is UNKNOWN territory for me.

Posted

Look at example: https://wiki.multitheftauto.com/wiki/DxDrawCircle

function dxDrawRoundedRectangle(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius

    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)

        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end
dxDrawRoundedRectangle(350, 50, 100, 100, tocolor(0, 255, 0, 255), 20)
  • Scripting Moderators
Posted (edited)
1 minute ago, ℓιgнт said:

I tried DGS, it's still not as smooth as I want it to be, you can see the rough edges. It's a good try though, thanks.

Perfect that's what I needed.

the rough edges is adjustable, you can make it smooth just by changing the settings. Actually the edge is smooth by default

Edited by thisdp
Posted
Just now, thisdp said:

the rough edges is adjustable, you can make it smooth just by changing the settings

I've tried it, you can still see the imperfection. Plus I think it might be better to use images since there's less rendering to do.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...