Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. client/verb
  2. ResizeIcon(oi as icon)
  3. var/icon/I = new(oi)
  4. var/ow = I.Width(), oh = I.Height()
  5. var/nw,nh
  6. var/inp
  7. do
  8. inp = input(usr,"Please supply the new icon size (old: [ow] [oh]) \[format: WxH or just S]","Resize Icon") as text|null
  9. if(inp==null) return
  10. nw = text2num(inp)
  11. if(nw==null)
  12. alert(usr,"Please supply a number in pixels for the icon size.","Error","OK")
  13. inp = null
  14. else if(nw!=round(nw))
  15. alert(usr,"Decimal values are not valid.","Error","OK")
  16. inp = null
  17. else if(nw<0)
  18. alert(usr,"The value must be greater than 0.","Error","OK")
  19. inp = null
  20. else if(nw>1024)
  21. alert(usr,"The value must be no greater than 1024.","Error","OK")
  22. inp = null
  23. else
  24. nh = findtext(inp,"x")
  25. if(nh&&nh<length(inp))
  26. nh = text2num(copytext(inp,nh+1))
  27. if(nh==null)
  28. alert(usr,"Please supply a number in pixels for the icon size.","Error","OK")
  29. inp = null
  30. else if(nh!=round(nh))
  31. alert(usr,"Decimal values are not valid.","Error","OK")
  32. inp = null
  33. else if(nh<0)
  34. alert(usr,"The value must be greater than 0.","Error","OK")
  35. inp = null
  36. else if(nh>1024)
  37. alert(usr,"The value must be no greater than 1024.","Error","OK")
  38. inp = null
  39. else
  40. nh = nw
  41. while(inp==null)
  42. inp = null
  43. var/anchor = 0
  44. do
  45. inp = alert(usr,"Do you want to anchor the icon?","Yes","No")
  46. if(inp=="Yes")
  47. inp = input(usr,"Select a direction for the anchor. Type a direction.","Anchor Point") as text|null
  48. if(inp==null) break
  49. switch(lowertext(inp))
  50. if("n","north","1","top","t")
  51. anchor = 1
  52. if("s","south","2","bottom","b")
  53. anchor = 2
  54. if("e","east","4","right","r")
  55. anchor = 4
  56. if("w","west","8","left","l")
  57. anchor = 8
  58. if("ne","northeast","north east","5","top right","topright","tr")
  59. anchor = 5
  60. if("nw","northwest","north west","9","top left","topleft","tl")
  61. anchor = 9
  62. if("se","southeast","south east","6","bottom right","bottomright","br")
  63. anchor = 6
  64. if("sw","southwest","south west","10","bottom left","bottomleft","bl")
  65. anchor = 10
  66. if("center","middle","none")
  67. anchor = 0
  68. else
  69. alert(usr,"Invalid input","Error","OK")
  70. inp = null
  71. while(inp==null)
  72.  
  73. var/dw = nw - ow
  74. var/dh = nh - oh
  75. switch(anchor)
  76. if(0)
  77. I.Crop(1 - round(dw/2),1 - round(dh/2),ow - round(-dw/2),oh - round(-dh/2))
  78. if(1)
  79. I.Crop(1 - round(dw/2),1 - dh,ow - round(-dw/2),oh)
  80. if(2)
  81. I.Crop(1 - round(dw/2),1,ow - round(-dw/2),nh)
  82. if(4)
  83. I.Crop(1 - dw,1 - round(dh/2),ow,oh - round(-dh/2))
  84. if(8)
  85. I.Crop(1,1 - round(dh/2),nw,oh - round(-dh/2))
  86. if(5)
  87. I.Crop(1 - dw,1 - dh,ow,oh)
  88. if(9)
  89. I.Crop(1,1 - dh,nw,oh)
  90. if(6)
  91. I.Crop(1 - dw,1,ow,nh)
  92. if(10)
  93. I.Crop(1,1,nw,nh)
  94. usr << ftp(I)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement