Tw1xee Posted October 6, 2015 Share Posted October 6, 2015 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
Buffalo Posted October 6, 2015 Share Posted October 6, 2015 Use your 1 pixel image and draw it on whole screen Example: local screenX,screenW = guiGetScreenSize() addEventHandler('onClientRender',getRootElement(),function() dxDrawImage( 0,0,screenX,screenW,"my1pximage.png") end) Link to comment
Moderators Citizen Posted October 6, 2015 Moderators Share Posted October 6, 2015 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
obuhhh Posted October 6, 2015 Share Posted October 6, 2015 Maybe that? dxDrawRectangle ( 100, 100, 200, 50, tocolor ( 0, 0, 0, 150 )) Link to comment
Tw1xee Posted October 6, 2015 Author Share Posted October 6, 2015 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 Citizen Posted October 6, 2015 Moderators Share Posted October 6, 2015 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 IIYAMA Posted October 7, 2015 Moderators Share Posted October 7, 2015 @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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now