Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client/verb
- ResizeIcon(oi as icon)
- var/icon/I = new(oi)
- var/ow = I.Width(), oh = I.Height()
- var/nw,nh
- var/inp
- do
- inp = input(usr,"Please supply the new icon size (old: [ow] [oh]) \[format: WxH or just S]","Resize Icon") as text|null
- if(inp==null) return
- nw = text2num(inp)
- if(nw==null)
- alert(usr,"Please supply a number in pixels for the icon size.","Error","OK")
- inp = null
- else if(nw!=round(nw))
- alert(usr,"Decimal values are not valid.","Error","OK")
- inp = null
- else if(nw<0)
- alert(usr,"The value must be greater than 0.","Error","OK")
- inp = null
- else if(nw>1024)
- alert(usr,"The value must be no greater than 1024.","Error","OK")
- inp = null
- else
- nh = findtext(inp,"x")
- if(nh&&nh<length(inp))
- nh = text2num(copytext(inp,nh+1))
- if(nh==null)
- alert(usr,"Please supply a number in pixels for the icon size.","Error","OK")
- inp = null
- else if(nh!=round(nh))
- alert(usr,"Decimal values are not valid.","Error","OK")
- inp = null
- else if(nh<0)
- alert(usr,"The value must be greater than 0.","Error","OK")
- inp = null
- else if(nh>1024)
- alert(usr,"The value must be no greater than 1024.","Error","OK")
- inp = null
- else
- nh = nw
- while(inp==null)
- inp = null
- var/anchor = 0
- do
- inp = alert(usr,"Do you want to anchor the icon?","Yes","No")
- if(inp=="Yes")
- inp = input(usr,"Select a direction for the anchor. Type a direction.","Anchor Point") as text|null
- if(inp==null) break
- switch(lowertext(inp))
- if("n","north","1","top","t")
- anchor = 1
- if("s","south","2","bottom","b")
- anchor = 2
- if("e","east","4","right","r")
- anchor = 4
- if("w","west","8","left","l")
- anchor = 8
- if("ne","northeast","north east","5","top right","topright","tr")
- anchor = 5
- if("nw","northwest","north west","9","top left","topleft","tl")
- anchor = 9
- if("se","southeast","south east","6","bottom right","bottomright","br")
- anchor = 6
- if("sw","southwest","south west","10","bottom left","bottomleft","bl")
- anchor = 10
- if("center","middle","none")
- anchor = 0
- else
- alert(usr,"Invalid input","Error","OK")
- inp = null
- while(inp==null)
- var/dw = nw - ow
- var/dh = nh - oh
- switch(anchor)
- if(0)
- I.Crop(1 - round(dw/2),1 - round(dh/2),ow - round(-dw/2),oh - round(-dh/2))
- if(1)
- I.Crop(1 - round(dw/2),1 - dh,ow - round(-dw/2),oh)
- if(2)
- I.Crop(1 - round(dw/2),1,ow - round(-dw/2),nh)
- if(4)
- I.Crop(1 - dw,1 - round(dh/2),ow,oh - round(-dh/2))
- if(8)
- I.Crop(1,1 - round(dh/2),nw,oh - round(-dh/2))
- if(5)
- I.Crop(1 - dw,1 - dh,ow,oh)
- if(9)
- I.Crop(1,1 - dh,nw,oh)
- if(6)
- I.Crop(1 - dw,1,ow,nh)
- if(10)
- I.Crop(1,1,nw,nh)
- usr << ftp(I)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement