ID:157713
 
proc
scale(atom/O, px,py)
var/icon/I = new(O.icon)
I.Scale(px,py)
O.icon=I


Basically, I want the icon to stay in the center, instead of being offset to the right. Got any ideas?

Edit:
So, I looked into it some more. And found out the icon is anchored to the south-west corner. Is there a way to change this?
Use Shift() after scaling it. The amount you need to shift it by should be (px % world.icon_size)/2
In response to Garthor
It doesn't seem to make a different.

proc
scale(atom/O, px,py)
var/icon/I = new(O.icon)
I.Scale(px,py)
I.Shift(WEST, (px % world.icon_size)/2)
O.icon=I


Also, when I call scale, I usually do something like;

var/size=round(mastery, 32)
if(size>578)
size=578
if(size<32)
size=32
scale(usr.Ball, size, size)
In response to Strong123488
WEST is not the correct direction. You want NORTHEAST.

Of course, I realize at this point I've misinterpreted what you want. What you actually want to be doing instead of messing with the icon is mess with O's pixel_x and pixel_y values. You'll want -(px-world.icon_size)/2 and -(py-world.icon_size)/2 for those.
In response to Garthor
Ah, thankyou very much! You've been really helpful, thanks. :)

If you could help me with figuring out one last thing, I'd be one very happy chap.

usr.Ball.loc=locate(usr.x, usr.y+1, usr.z)

Basically, this will make the ball appear directly above the player when the ball is 32x32. When I scale it to larger sizes, what would be a good flexible formula for making the very bottom of the ball being directly above the player?

I was thinking something like..
usr.y+1+(usr.Ball.pixel_y*-1)

Since that turns the negative pixel_y into a positive. But it's not right, at all.

Thanks again for your help.
In response to Strong123488
First, only pixel_size can help you.
Second you need to figure out what value is needed.

proc/return_pixel_x(obj/O)
var/icon/I=new(O.icon)
var/w=I.Width()
var/x_re=0
x_re=w/2
x_re-=(-((w/32)-1)*16)
x_re=-x_re
return x_re
proc/return_pixel_y(obj/O) // i dont think you ll need this
var/icon/I=new(O.icon)
var/h=I.Height()
var/y_re=0
y_re=w/2
y_re-=(-((h/32)-1)*16)
y_re=-y_re
return y_re


//Using the proc
proc/Scale_Obj(obj/O)
/// bllaaaa scale the object here
Center_Obj(O)
return
proc/Center_Obj(obj/O)
//O.pixel_y=return_pixel_y(O) // may want this prbbly bo
O.pixel_x=return_pixel_x(O) //
return


This is what I understood from your want so I only think you need this.