Fist Posted March 11, 2017 Share Posted March 11, 2017 hello! I barerly know anything about dxDraw that's why im here, So far i have used only ceGui but i want to learn how i can make dxDraw box with image parts that automaticly make box no matter what kind of size from images that are splitted into several images which contains box all together. Link to comment
Fist Posted March 11, 2017 Author Share Posted March 11, 2017 anyone? I mean't draw image and then around it would be bordered with images that would connect to each other to no matter what size box is. Link to comment
pa3ck Posted March 11, 2017 Share Posted March 11, 2017 As far as I understand you, you're looking for this: https://wiki.multitheftauto.com/wiki/DxDrawBorderedRectangle Note: This function is not a native MTA function. You will need to copy-paste the function given on the wiki in order to use it. Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 14 hours ago, pa3ck said: As far as I understand you, you're looking for this: https://wiki.multitheftauto.com/wiki/DxDrawBorderedRectangle Note: This function is not a native MTA function. You will need to copy-paste the function given on the wiki in order to use it. yeah but it's only for rectangle, no images whatsoever. Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 here is example how images would be http://prntscr.com/eiy10n Link to comment
coNolel Posted March 12, 2017 Share Posted March 12, 2017 Hello @Fist as pack03 told you , you can use the function posted by me in the wiki , to help the others , but now you want it for an image so it's pretty easy as i think , u can just edit the function from dxDrawRectangle => to dxDrawImage and edit the x,y,w,h and the color ... Peace ! Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 10 minutes ago, coNolel said: Hello @Fist as pack03 told you , you can use the function posted by me in the wiki , to help the others , but now you want it for an image so it's pretty easy as i think , u can just edit the function from dxDrawRectangle => to dxDrawImage and edit the x,y,w,h and the color ... Peace ! yes it actually would work, but i want to draw corner images aswell but in your code there are only top-bottom and left-right. How about right-top corner, left-top corner, etc. Link to comment
coNolel Posted March 12, 2017 Share Posted March 12, 2017 Just now, Fist said: yes it actually would work, but i want to draw corner images aswell but in your code there are only top-bottom and left-right. How about right-top corner, left-top corner, etc. What do you mean , can you show me an image explaining what exactly do you want ? Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 Just now, coNolel said: What do you mean , can you show me an image explaining what exactly do you want ? i posted image above already. http://prntscr.com/eiy10n see there are images with corner parts. Link to comment
coNolel Posted March 12, 2017 Share Posted March 12, 2017 aaaah Just now, Fist said: i posted image above already. http://prntscr.com/eiy10n see there are images with corner parts. u can try this, ( btw not tested ^^" ) function dxDrawBorderedImage( x, y, width, height, color1, color2, _width, postGUI ) local _width = _width or 1 -- dxDrawRectangle ( x+1, y+1, width-1, height-1, color1, postGUI ) dxDrawImage ( (x+width)/2-imageWidth,(y+height)/2-(imageHeight), image) dxDrawLine ( x, y, x+width, y, color2, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color2, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color2, _width, postGUI ) -- Bottom dxDrawLine ( x+width, y, x+width, y+height, color2, _width, postGUI ) -- Right end i hope it works for you Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 2 minutes ago, coNolel said: aaaah u can try this, ( btw not tested ^^" ) function dxDrawBorderedImage( x, y, width, height, color1, color2, _width, postGUI ) local _width = _width or 1 -- dxDrawRectangle ( x+1, y+1, width-1, height-1, color1, postGUI ) dxDrawImage ( (x+width)/2-imageWidth,(y+height)/2-(imageHeight), image) dxDrawLine ( x, y, x+width, y, color2, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color2, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color2, _width, postGUI ) -- Bottom dxDrawLine ( x+width, y, x+width, y+height, color2, _width, postGUI ) -- Right end i hope it works for you imageWidth and imageHeight doesn't exist? Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 (edited) i think he need this On 3/11/2017 at 10:12, Fist said: hello! I barerly know anything about dxDraw that's why im here, So far i have used only ceGui but i want to learn how i can make dxDraw box with image parts that automaticly make box no matter what kind of size from images that are splitted into several images which contains box all together. addEventHandler('onClientRender', root, function() dxDrawImageSection(400, 200, 64, 64, 0, 0, 64, 64, 'img.jpg') -- Draw a certain section dxDrawImage(400, 300, 128, 128, 'img.jpg') -- Draw the whole image to be able to identify the difference end) use this image Edited March 12, 2017 by Ayush Rathore Link to comment
coNolel Posted March 12, 2017 Share Posted March 12, 2017 function dxDrawBorderedImage( x, y, width, height, image, imageWidth, imageHeight, color1, _width, postGUI ) local _width = _width or 1 -- dxDrawRectangle ( x+1, y+1, width-1, height-1, color1, postGUI ) dxDrawImage ( (x+width)/2-imageWidth,(y+height)/2-(imageHeight), image) dxDrawLine ( x, y, x+width, y, color1, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color1, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color1, _width, postGUI ) -- Bottom dxDrawLine ( x+width, y, x+width, y+height, color1, _width, postGUI ) -- Right end try this ^^" 1 Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 (edited) 9 minutes ago, coNolel said: function dxDrawBorderedImage( x, y, width, height, image, imageWidth, imageHeight, color1, _width, postGUI ) local _width = _width or 1 -- dxDrawRectangle ( x+1, y+1, width-1, height-1, color1, postGUI ) dxDrawImage ( (x+width)/2-imageWidth,(y+height)/2-(imageHeight), image) dxDrawLine ( x, y, x+width, y, color1, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color1, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color1, _width, postGUI ) -- Bottom dxDrawLine ( x+width, y, x+width, y+height, color1, _width, postGUI ) -- Right end try this ^^" i mean it draws it but it's just a 1 image, i can't tell or it works or not. Can you just edit that dxDrawBorderedRectangle by just adding corner images and those lines itself to images aswell? Edited March 12, 2017 by Fist Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 1 minute ago, Fist said: i mean it draws it but it's just a 1 image, i can't tell or it works or not. Can you just edit that dxDrawBorderedRectangle by just adding corner images and those lines itself to images aswell. do u mean my post tell me Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 Just now, Ayush Rathore said: do u mean my post tell me i mean't his, but yours won't work for me 'cause those image parts are seprate images not 1 big image. Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 ok no problem 29 minutes ago, Fist said: i mean't his, but yours won't work for me 'cause those image parts are seprate images not 1 big image. 1 Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 @coNolel i actually did it by my self, it actually was way simplier than i thought. Thanks to your sample i managed to make it. Thanks man alot! 6 minutes ago, Ayush Rathore said: ok no problem thanks for trying to help tho. I appreciate people like that. 1 Link to comment
3aGl3 Posted March 12, 2017 Share Posted March 12, 2017 This is what you are looking for: function drawImageBox( x, y, w, h ) -- you should probably check here for valid size etc. -- w and h need to be at least 32, 48 would probably be even better dxDrawImage( x, y, 16, 16, "images/left-up.png" ) dxDrawImage( x+16, y, w-32, 16, "images/up.png" ) dxDrawImage( x+w-16,y, 16, 16, "images/right-up.png" ) dxDrawImage( x, y+16, 16, h-32, "images/left.png" ) dxDrawImage( x+16, y+16, w-32, h-32, "images/center.png" ) dxDrawImage( x+w-16,y+16, 16, h-32, "images/right.png" ) dxDrawImage( x, y+h-16, 16, 16, "images/left-down.png" ) dxDrawImage( x+16, y+h-16, w-32, 16, "images/down.png" ) dxDrawImage( x+w-16,y+h-16, 16, 16, "images/right-down.png" ) end Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 34 minutes ago, 3aGl3 said: This is what you are looking for: function drawImageBox( x, y, w, h ) -- you should probably check here for valid size etc. -- w and h need to be at least 32, 48 would probably be even better dxDrawImage( x, y, 16, 16, "images/left-up.png" ) dxDrawImage( x+16, y, w-32, 16, "images/up.png" ) dxDrawImage( x+w-16,y, 16, 16, "images/right-up.png" ) dxDrawImage( x, y+16, 16, h-32, "images/left.png" ) dxDrawImage( x+16, y+16, w-32, h-32, "images/center.png" ) dxDrawImage( x+w-16,y+16, 16, h-32, "images/right.png" ) dxDrawImage( x, y+h-16, 16, 16, "images/left-down.png" ) dxDrawImage( x+16, y+h-16, w-32, 16, "images/down.png" ) dxDrawImage( x+w-16,y+h-16, 16, 16, "images/right-down.png" ) end well, i already figured it out. But thanks anyway for your time, also do you know by any chance how to get longest string from table? Link to comment
3aGl3 Posted March 12, 2017 Share Posted March 12, 2017 Don't think there is a native function for that but this is how I'd do it: function getLongestString( table ) local longest for k, v in pairs( table ) do if not longest or string.len(v) > string.len(longest) then longest = v end end return longest end 1 Link to comment
Fist Posted March 12, 2017 Author Share Posted March 12, 2017 16 minutes ago, 3aGl3 said: Don't think there is a native function for that but this is how I'd do it: function getLongestString( table ) local longest for k, v in pairs( table ) do if not longest or string.len(v) > string.len(longest) then longest = v end end return longest end thanks mate. 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