ID:1423552
 
(See the best response by Ss4toby.)
Is there a way to display an atom's bounds? I tried to use DrawBox() but it didn't work well, so I wondered what should I do to draw something on an atom's bounds so I can properly see how far it goes.

Thank you :)
DrawBox should work. Maybe you used it incorrectly?
Best response
There are actually several ways you could go about doing this. First, you could use draw box, but that would require a blank icon being rescaled, and then a box being draw on it. Which isn't very efficient. Another option is to Scale() the icon, which "should" be more efficient than scaling and drawing, but don't hold me to that (I have not run any tests).

The option that I feel is best, is to utilize BYOND's new matrix datum. The matrix is a datum used to manipulate icons through the transform variable (every atom has it). With transform, you can scale and rotate icons without creating cache (files that players must download in the middle of the game).

Not only does matrix help to prevent unwanted cache, but it also seems to be much more efficient than icon manipulation. However, it is limited so icon manipulation is still needed in some cases.

Now that I've given a long winded rant to justify this script, here ya go:
mob/verb/Bounds()
var/obj/o=new
var/icon/i='boundsSize16.dmi'
var/iconWidth=16
var/iconHeight=16
/*
Because scaling doesn't create good looking icons when done too big,
it is idea to have a buffering zone and switch between different sized icons.
This will allow better quaulity.
*/

var/bigSide=bound_height
if(bound_width>bound_height)
bigSide=bound_width
if(bigSide>16)
i='boundsSize32.dmi'
iconWidth=32
iconHeight=32
if(bigSide>32)
i='boundsSize48.dmi'
iconWidth=48
iconHeight=48
if(bigSide>48)
i='boundsSize64.dmi'
iconWidth=64
iconHeight=64
o.icon=i
//Matrix really is a beautiful thing. With it, you can manipulate icons without generating cache.
//Also, it is extremely fast in comparison. Because icon manipulation also is CPU costly, even simply
//creating a new icon can cause CPU icon('')
var/matrix/m=new
var/xPerc=bound_width/iconWidth//Divide by size of icon. Meaning, width of image, not the actual icon.Width()
var/yPerc=bound_height/iconHeight
o.transform=m.Scale(xPerc,yPerc)
//Because this is strictly visual and it's being applied as an underlay, pixel_x and y are essentual.
//Honestly, since your using an obj, it could go on as an overlay. To alter layering simply apply layer
//E.G. o.layer=10
o.pixel_x=bound_x+1
o.pixel_y=bound_y+1
src.underlays+=o


*EDIT* The script I've provided is designed for square blocks, you will need to make alterations if you wish to have rectangles. Also, be sure that the icons are correctly sized when you create them, elsewise the system will be faulty and your display wont be accurate.