Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. class Bitmap
  2.  
  3. def initialize(param1, param2 = 0)
  4. @filepath = ''
  5. @width = 0
  6. @height = 0
  7.  
  8. if param2 == 0
  9. prefix = ".png"
  10.  
  11. if !FileTest.exist?("#{param1}#{prefix}")
  12. prefix = ".jpg"
  13. end
  14.  
  15. @filepath = "#{param1}#{prefix}"
  16. size = Graphics.load_texture(@filepath)
  17.  
  18. @width = size[0]
  19. @height = size[1]
  20. else
  21. @width = param1
  22. @height = param2
  23. end
  24.  
  25. @draws = []
  26. @font = Font.new
  27. @text_size = TextSize.new
  28. end
  29.  
  30. def filepath
  31. @filepath
  32. end
  33.  
  34. def clear
  35. p "LIMPOI"
  36. draws.each{|draw|;
  37. draw = nil
  38. }
  39. @draws = []
  40. end
  41.  
  42. def newDraw(draw)
  43. @draws = [] if @draws.nil?
  44. @draws.push(draw)
  45. end
  46.  
  47. def draws
  48. @draws
  49. end
  50.  
  51. def fill_rect(rect, color)
  52.  
  53. end
  54.  
  55. def fill_rect(x = 0, y = 0, width = 0, height = 0, color = Color.new(250,250,250))
  56.  
  57. end
  58.  
  59. def draw_text(param1, param2, param3, param4 = 0, param5 = "", center = 0, bold = false, underlined = false, regular = false, italic = false)
  60. if param4 == 0
  61. Draw.new(self, Graphics::DRAW_TYPE_TEXT, param1.x, param1.y, param1.width, param1.height, "", Rect.new(0,0,0,0), self.font.color, param2, 14)
  62. else
  63. Draw.new(self, Graphics::DRAW_TYPE_TEXT, param1, param2, param3, param4, "", Rect.new(0,0,0,0), self.font.color, param5, 14)
  64. end
  65.  
  66. end
  67.  
  68. #def draw_text(rect, text, center)
  69. # Draw.new(self, Graphics::DRAW_TYPE_TEXT, rect.x, rect.y, rect.width, rect.height, "", Rect.new(0,0,0,0), self.font.color, text)
  70. #end
  71.  
  72. def rect
  73. Rect.new(0,0,0,0)
  74. end
  75.  
  76. def blt(x, y, bitmap, rect)
  77. return if bitmap.filepath.size <= 1
  78. p bitmap
  79. Draw.new(self, Graphics::DRAW_TYPE_NORMAL, x, y, self.width, self.height, bitmap.filepath, rect)
  80. end
  81.  
  82. def width
  83. @width
  84. end
  85.  
  86. def width=(v)
  87. @width = v
  88. end
  89.  
  90. def height
  91. @height
  92. end
  93.  
  94. def height=(v)
  95. @height = v
  96. end
  97.  
  98. def font
  99. @font
  100. end
  101.  
  102. def font=(v)
  103. @font = v
  104. end
  105.  
  106. def text_size(str)
  107. @text_size
  108. end
  109.  
  110. def gradient_fill_rect(temp_rect = nil, back_color2 = nil, back_color1 = nil)
  111. end
  112. end
  113.  
  114. class Draw
  115. def initialize(bitmap, type = 0, x = 0, y = 0, width = 0, height = 0, filepath = '', rect = Rect.new(0,0,0,0), color = Color.new(255,255,255,255), text = "", size = 14)
  116. @type = type
  117.  
  118. @x = x
  119. @y = y
  120.  
  121. @r = color.red
  122. @g = color.green
  123. @b = color.blue
  124. @a = color.alpha
  125.  
  126. @text = text
  127. @size = size
  128.  
  129. if @type == 0
  130. p filepath
  131. end
  132.  
  133. @filepath = filepath
  134. @rect = rect
  135. bitmap.newDraw(self)
  136. end
  137. def type
  138. @type
  139. end
  140. def x
  141. @x
  142. end
  143. def y
  144. @y
  145. end
  146. def r
  147. @r
  148. end
  149. def g
  150. @g
  151. end
  152. def b
  153. @b
  154. end
  155. def a
  156. @a
  157. end
  158. def filepath
  159. @filepath
  160. end
  161. def rect
  162. @rect
  163. end
  164. def text
  165. @text
  166. end
  167. def size
  168. @size
  169. end
  170. def bold
  171. 0
  172. end
  173. def underlined
  174. 0
  175. end
  176. def italic
  177. 0
  178. end
  179. def regular
  180. 0
  181. end
  182. end
  183.  
  184. class TextSize
  185. def initialize
  186. @height = 0
  187. @width = 0
  188. end
  189.  
  190. def height
  191. @height
  192. end
  193.  
  194. def width
  195. @width
  196. end
  197. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement