Jump to content

1px image repeat


Tw1xee

Recommended Posts

Hello guys, i want use 1px image for create background with him like in CSS. Example:

background-image: url(“1px image.png”); 
background-repeat: repeat 

How i can do this in MTA without use cycles? Pls show me example code if this possible. Pls use dx functions, not GUI!

Sorry for my bad English! My native language isn't English, so I have some mistakes, but I think you'll understand me)

Link to comment
  • Moderators

Just use dxDrawImage and give the width and height of that image.

The image will be stretched automatically and will exactly look like a background repeat in css.

addEventHandler("onClientRender", root, function () 
    dxDrawImage(200, 200, 400, 400, "image.png") 
end) 
  

Link to comment
Just use dxDrawImage and give the width and height of that image.

The image will be stretched automatically and will exactly look like a background repeat in css.

addEventHandler("onClientRender", root, function () 
    dxDrawImage(200, 200, 400, 400, "image.png") 
end) 
  

ty, i don't know about this)

Link to comment
  • Moderators

Note that obuhhh is right by implicitly saying that the dxDrawRectangle will be a way better than using the dxDrawImage.

If your image is only 1px, then there will be only 1 color. Get it as RGB from any image editor tool and use it in the dxDrawRectangle like obuhhh did.

By doing that you will prevent players to download an extra image and the render will need less usage of the player's computer resources and for the exact same result.

Link to comment
  • Moderators

@Tw1xee

Why would you repeat a pixel in css in order to fill it? Isn't that just wasting GPU power on the render engine of the browser?

If you had 2 pixels of differed colours, it might be handy for creating a pattern. But one pixel is just > O_o

Link to comment

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...