Advertisement
DaxSoft

DCLL

Feb 1st, 2015
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.73 KB | None | 0 0
  1. #==============================================================================
  2. # * daxcore.dll
  3. #==============================================================================
  4. # Autor : Dax Aquatic X
  5. # Versão: i0.4
  6. # Requerimento : Dax Core
  7. # Site : www.dax-soft.weebly.com
  8. # Suporte : dax-soft@live.com
  9. #==============================================================================
  10. # Script que chama as funções da dll, 'daxcore.dll'.
  11. #==============================================================================
  12. # Conteúdo : • TAGS : Para facilitar a localização dos códigos e explicações. Para acessar
  13. # o comando para localizar, basta apertar Ctrl+F.
  14. #==============================================================================
  15. # i :
  16. # - DCLL :dcll
  17. # - Bitmap :bitmap
  18. #==============================================================================
  19. # • Adicionado comentário padrão. Veja o modo que agora os comentários dos
  20. # métodos estão.
  21. #==============================================================================
  22. # • [Classe do Retorno] : Explicação.
  23. # * Exemplo.(Se possível.)
  24. #==============================================================================
  25. Dax.register(:daxcore_dll, "Dax", 0.4, "08/01/15")
  26. $DCLL = "./daxcore.dll"
  27. raise("DLL não encontrada.") unless FileTest.exist?($DCLL)
  28. #==============================================================================
  29. # • DLLFUNC_DAXCORE
  30. #==============================================================================
  31. Dax.register(:dcll)
  32. module DCLL
  33. extend self
  34. extend API
  35. #----------------------------------------------------------------------------
  36. # • [INFO] : Versão da DLL.
  37. #----------------------------------------------------------------------------
  38. INFO = char("INFO", [], $DCLL).call.freeze
  39. #----------------------------------------------------------------------------
  40. # • [BitmapRGBAInvert] : Inverter as cores do bitmap.
  41. #----------------------------------------------------------------------------
  42. BitmapRGBAInvert = int("BitmapRGBAInvert", [:I], $DCLL)
  43. #----------------------------------------------------------------------------
  44. # • [BitmapToGrayscale] : Converte as cores do bitmap para cinza.
  45. #----------------------------------------------------------------------------
  46. BitmapToGrayscale = int("BitmapToGrayscale", [:I], $DCLL)
  47. #----------------------------------------------------------------------------
  48. # • [BitmapColorSaturation] : Saturação das cores..
  49. #----------------------------------------------------------------------------
  50. BitmapColorSaturation = int("BitmapColorSaturation", [:int, :int], $DCLL)
  51. #----------------------------------------------------------------------------
  52. # • [BitmapBrightness] : Brilho nas cores..
  53. #----------------------------------------------------------------------------
  54. BitmapColorBrightness = int("BitmapColorBrightness", [:I, :i], $DCLL)
  55. #----------------------------------------------------------------------------
  56. # • [BitmapColorContrast] : Contraste nas cores..
  57. #----------------------------------------------------------------------------
  58. BitmapColorContrast = int("BitmapColorContrast", [:I, :i], $DCLL)
  59. #----------------------------------------------------------------------------
  60. # • [BitmapColorize] : Colorir o bitmap.
  61. #----------------------------------------------------------------------------
  62. BitmapColorize = int("BitmapColorize", [:I, :int, :int, :int, :int], $DCLL)
  63. #----------------------------------------------------------------------------
  64. # • [BitmapFilter33] : Filtro[33]
  65. #----------------------------------------------------------------------------
  66. BitmapFilter33 = int("BitmapFilter33", [:I,:int,:int,:int,:int,:int,:int,:int,:int,:int,:int], $DCLL)
  67. #----------------------------------------------------------------------------
  68. # • [BitmapMonochrome] : Transforma as cores em uma escala só.
  69. #----------------------------------------------------------------------------
  70. BitmapMonochrome = int("BitmapMonochrome", [:I], $DCLL)
  71. #----------------------------------------------------------------------------
  72. # • [BitmapFilter34] : Filtro[34]
  73. #----------------------------------------------------------------------------
  74. BitmapFilter34 = int("BitmapFilter34", [:I,:int,:int,:int,:int,:int,:int,:int,:int,:int], $DCLL)
  75. #----------------------------------------------------------------------------
  76. # • [BitmapTint] : Preencher color bitmap. Tint
  77. #----------------------------------------------------------------------------
  78. BitmapTint= int("BitmapTint", [:I, :int, :int, :int, :int], $DCLL)
  79. #----------------------------------------------------------------------------
  80. # • [BitmapRGBABust] : Efeitos de cores livres. Você define.
  81. #----------------------------------------------------------------------------
  82. BitmapRGBABust = int("BitmapRGBABust", [:I, :long, :long, :long,
  83. :long, :long, :long, :long, :long, :long], $DCLL)
  84. #----------------------------------------------------------------------------
  85. # • [BitmapClearRect] : Limpa uma área retangular. Mesmo método do
  86. # Maker(classe Bitmap#clear_rect)
  87. # BitmapClearRect.call(object_id, x, y, width, height)
  88. #----------------------------------------------------------------------------
  89. BitmapClearRect = int("BitmapClearRect", [:long, :int, :int, :int, :int], $DCLL)
  90. #----------------------------------------------------------------------------
  91. # • [BitmapFillRect] : Preenche uma área retangular. Mesmo método do
  92. # Maker(classe Bitmap#fill_rect)
  93. # BitmapFillRect.call(object_id, x, y, width, height, red, green, blue, alpha)
  94. #----------------------------------------------------------------------------
  95. BitmapFillRect = int("BitmapFillRect", [:long, :int, :int, :int, :int,
  96. :int, :int, :int, :int], $DCLL)
  97. #----------------------------------------------------------------------------
  98. # • [BitmapBLT] : Realiza a mesma função que Bitmap#blt.
  99. # BitmapBLT.call(object_id, other_object_id, x, y, srcx, srcy, width, height,
  100. # opacity)
  101. #----------------------------------------------------------------------------
  102. BitmapBLT = int("BitmapBLT", [:long, :long, :int, :int, :int, :int,
  103. :int, :int, :int], $DCLL)
  104. #----------------------------------------------------------------------------
  105. # • [BitmapSimpleBLT] : Realiza a mesma função que Bitmap#blt, só que de
  106. # maneira mais simples.
  107. # BitmapBLT.call(object_id, other_object_id, x, y, srcx, srcy, width, height)
  108. #----------------------------------------------------------------------------
  109. BitmapSimpleBLT = int("BitmapSimpleBLT", [:long, :long, :int, :int, :int, :int,
  110. :int, :int], $DCLL)
  111. #----------------------------------------------------------------------------
  112. # • [BitmapBlendBLT] : Realiza a mesma função que o Bitmap#blt, só que
  113. # com a função de realizar 'blends' no bitmap.
  114. # BitmapBlendBLT.call(object_id, other_object_id, x, y, srcx, srcy, width, height,
  115. # blend, opacity)
  116. # Tipos de 'blend' :
  117. # 0 - Normal.
  118. # 1 - Adicionar
  119. # 2 - Subtrair.
  120. # 3 - Multiplicação.
  121. # 4 - Divisão.
  122. # 5 - Subexposição escura.
  123. # 6 - Luz indireta.
  124. # 7 - Subexposição de cores.
  125. # 8 - Superexposição linear #-1.
  126. # 9 - Superexposição linear.
  127. #----------------------------------------------------------------------------
  128. BitmapBlendBLT = int("BitmapBlendBLT", [:long, :long, :int, :int, :int, :int,
  129. :int, :int, :int, :int], $DCLL)
  130. #----------------------------------------------------------------------------
  131. # • [BitmapTransferBLT] : Realiza a mesma função que o Bitmap#blt, só que
  132. # você pode determinar o modo da transferência do bitmap.
  133. # BitmapTransferBLT.call(object_id, other_object_id, x, y, srcx, srcy,
  134. # width, height, transfer, opacity)
  135. # Tipos de 'transfers'
  136. # 0 - Normal
  137. # 1 - Fundo preenchido.
  138. #----------------------------------------------------------------------------
  139. BitmapTransferBLT = int("BitmapTransferBLT", [:long, :long, :int, :int, :int, :int,
  140. :int, :int, :int, :int], $DCLL)
  141. #----------------------------------------------------------------------------
  142. # • [BitmapTilemap] : Função de desenhar tiles no bitmap.
  143. # BitmapTilemap.call(data, priority)
  144. # data : Array que contém os ids dos tiles.
  145. # priority : Array que contém as prioridades dos tiles.
  146. # sizes : Array que contém o tamanho dos tiles.
  147. # tileset : Bitmap da imagem do tileset.
  148. # autotiles : Array que contém os bitmaps dos autotiles.
  149. # layer : Bitmap do layer.
  150. # ox : Coordenação em OX.
  151. # oy : Coordenação em OY.
  152. # pri : Prioridade padrão(0).
  153. #----------------------------------------------------------------------------
  154. BitmapTransitionIN = int("BitmapTransitionIN", [:int, :int, :int, :long,
  155. :long, :long, :int, :int,
  156. :int], $DCLL)
  157. #----------------------------------------------------------------------------
  158. # • [BitmapSplit] : Corta o bitmap com relação a outro.
  159. # BitmapSplit.call(object_id, other_object_id, x, y)
  160. #----------------------------------------------------------------------------
  161. BitmapSplit = int("BitmapSplit", [:long, :long, :int, :int], $DCLL)
  162. #----------------------------------------------------------------------------
  163. # • [BitmapRipple] : Efeito wave, efeito de onda, o efeito funciona
  164. # com relação ao outro bitmap.
  165. # BitmapRipple.call(object_id, other_object_id, amplitude, wavelenght, dir)
  166. #----------------------------------------------------------------------------
  167. BitmapRipple = int("BitmapRipple", [:long, :long, :int, :int, :int], $DCLL)
  168. #----------------------------------------------------------------------------
  169. # • [BitmapRippleCircle] : Efeito wave, efeito de onda, o efeito funciona
  170. # com relação ao outro bitmap.
  171. # BitmapRippleCircle.call(object_id, cx, cy, angle, width, change, amount)
  172. #----------------------------------------------------------------------------
  173. BitmapRippleCircle = int("BitmapRippleCircle", [:long, :int, :int, :int, :int,
  174. :int, :int], $DCLL)
  175. #----------------------------------------------------------------------------
  176. # • [BitmapGetPixel] : Mesma função que o Bitmap#get_pixel
  177. # BitmapGetPixel.call(object_id, x, y, index)
  178. # index dá cor. 0 - red, 1 - green, 2 - blue, 3 - alpha.
  179. #----------------------------------------------------------------------------
  180. BitmapGetPixel = int("BitmapGetPixel", [:long, :int, :int, :int], $DCLL)
  181. #----------------------------------------------------------------------------
  182. # • [BitmapGetPixelRGBA] : Mesma coisa do BitmapGetPixel, só que retorna
  183. # a uma classe Color.
  184. #----------------------------------------------------------------------------
  185. BitmapGetPixelRGBA = ->(object, x, y) {
  186. index = []
  187. 0.upto(3) { |i| index << BitmapGetPixel.call(object, x, y, i) }
  188. return Color.new(*index)
  189. }
  190. #----------------------------------------------------------------------------
  191. # • [BitmapDrawCircle] : Desenha um círculo.
  192. # BitmapDrawCircle.call(object_id, cx, cy, rad, thick,
  193. # start_angle, end_angle, r, g, b, a)
  194. #----------------------------------------------------------------------------
  195. BitmapDrawCircle = int("BitmapDrawCircle", [:long, :int, :int, :int, :int,
  196. :int, :int, :int, :int, :int,
  197. :int], $DCLL)
  198. #----------------------------------------------------------------------------
  199. # • [BitmapDrawEllipse] : Desenha uma elípse.
  200. # BitmapDrawEllipse.call(object_id, cx, cy, rx, ry, thick, start_angle,
  201. # end_angle, r, g, b, a)
  202. #----------------------------------------------------------------------------
  203. BitmapDrawEllipse = int("BitmapDrawEllipse", [:long, :int, :int, :int, :int,
  204. :int, :int, :int, :int, :int,
  205. :int, :int], $DCLL)
  206. #----------------------------------------------------------------------------
  207. # • [BitmapPixelize] : Pixalizar o bitmap.
  208. # BitmapPixelize.call(object_id, sizex, sizey)
  209. #----------------------------------------------------------------------------
  210. BitmapPixelize = int("BitmapPixelize", [:long, :int, :int], $DCLL)
  211. end
  212. #==============================================================================
  213. # • Pixel :pixel
  214. #==============================================================================
  215. class Bitmap
  216. include DCLL
  217. #----------------------------------------------------------------------------
  218. # • Verificar se o bitmap é válido.
  219. #----------------------------------------------------------------------------
  220. def valid_bitmap?(whats_bitmap=self)
  221. return false if whats_bitmap.nil? or whats_bitmap.disposed?
  222. return true
  223. end
  224. #----------------------------------------------------------------------------
  225. # • Mesma função do get_pixel. Só que em C++.
  226. #----------------------------------------------------------------------------
  227. def get_pixel(x, y)
  228. return unless valid_bitmap?
  229. BitmapGetPixelRGBA.call(__id__, x, y)
  230. end
  231. #----------------------------------------------------------------------------
  232. # • Pixalizar o objeto.
  233. # size : Tamanho geral ou sizex, sizey : Especificar tamanho.
  234. # pixelize(size) ou pixelize(sizex, sizey)
  235. #----------------------------------------------------------------------------
  236. def pixelize(*args)
  237. return unless valid_bitmap?
  238. size = args.size == 1 ? [args[0], args[0]] : args
  239. BitmapPixelize.call(__id__, size[0], size[1])
  240. end
  241. #----------------------------------------------------------------------------
  242. # • Efeito Wave(Efeito de onda no bitmap.)
  243. #----------------------------------------------------------------------------
  244. def ripple(other, amplitude, wavelenght, dir)
  245. return unless valid_bitmap? or valid_bitmap?(other)
  246. BitmapRipple.call(self.__id__, other.__id__, amplitude, wavelenght, dir)
  247. end
  248. #----------------------------------------------------------------------------
  249. # • Cortar o bitmap em relação ao outro.
  250. #----------------------------------------------------------------------------
  251. def split(other, x, y)
  252. return unless valid_bitmap? or valid_bitmap?(other)
  253. BitmapSplit.call(self.__id__, other.__id__, x, y)
  254. end
  255. #----------------------------------------------------------------------------
  256. # • Blend#blt
  257. #----------------------------------------------------------------------------
  258. def blend_blt(other_bitmap, x, y, srcx, srcy, width, height, blend, opacity)
  259. return unless valid_bitmap? or valid_bitmap?(other_bitmap)
  260. BitmapBlendBLT.call(self.__id__, other_bitmap.__id__, x, y, srcx, srcy,
  261. width, height, blend, opacity)
  262. end
  263. #----------------------------------------------------------------------------
  264. # • Transfer
  265. #----------------------------------------------------------------------------
  266. def transfer_blt(other_bitmap, x, y, srcx, srcy, width, height, transfer, opacity)
  267. return unless valid_bitmap? or valid_bitmap?(other_bitmap)
  268. BitmapTransferBLT.call(self.__id__, other_bitmap.__id__, x, y, srcx, srcy,
  269. width, height, transfer, opacity)
  270. end
  271. #----------------------------------------------------------------------------
  272. # • Inverter as cores do bitmap.
  273. #----------------------------------------------------------------------------
  274. def invert_rgba
  275. return unless valid_bitmap?
  276. BitmapRGBAInvert.call(self.__id__)
  277. end
  278. alias invert_rgba negative
  279. #----------------------------------------------------------------------------
  280. # • Converter as cores para cinza.
  281. #----------------------------------------------------------------------------
  282. def grayscale
  283. return unless valid_bitmap?
  284. BitmapToGrayscale.call(self.__id__)
  285. end
  286. #----------------------------------------------------------------------------
  287. # • [BitmapRGBABust] : Efeitos de cores livres. Você define.
  288. #----------------------------------------------------------------------------
  289. def rgbaBust(*args)
  290. return unless valid_bitmap?
  291. BitmapRGBABust.call(self.__id__, *args)
  292. end
  293. #----------------------------------------------------------------------------
  294. # • Efeito de escuridão vermelha no bitmap.
  295. #----------------------------------------------------------------------------
  296. def darkness_red
  297. rgbaBust(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.502)
  298. end
  299. #----------------------------------------------------------------------------
  300. # • Efeito de escuridão azul no bitmap.
  301. #----------------------------------------------------------------------------
  302. def darkness_blue
  303. rgbaBust(0.0, 0.0, 1.274, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
  304. end
  305. #----------------------------------------------------------------------------
  306. # • Efeito de escuridão verde no bitmap.
  307. #----------------------------------------------------------------------------
  308. def darkness_green
  309. rgbaBust(0.0, 0.0, 0.0, 0.0, 0.0, 1.311, 0.0, 0.0, 0.0)
  310. end
  311. #----------------------------------------------------------------------------
  312. # • Efeito de prateado-sketch.
  313. #----------------------------------------------------------------------------
  314. def silver_z
  315. rgbaBust(1.474, 1.940, 0.923, 1.892, 0.109, 0.860, 1.083, -0.086, 0.904)
  316. end
  317. #----------------------------------------------------------------------------
  318. # • Efeito roxo avermelhado.
  319. #----------------------------------------------------------------------------
  320. def pink_redness
  321. rgbaBust(1.664, -0.981, -0.433, -0.814, -0.916, -0.756, 1.093, 0.574, 1.953)
  322. end
  323. #----------------------------------------------------------------------------
  324. # • Efeito cor de cobre-clara.
  325. #----------------------------------------------------------------------------
  326. def copper_lightness
  327. rgbaBust(-0.650, -0.784, 1.440, 1.875, 0.386, -0.711, 1.291, 1.514, 0.293)
  328. end
  329. #----------------------------------------------------------------------------
  330. # • Efeito [rsh4]
  331. #----------------------------------------------------------------------------
  332. def rsh4
  333. rgbaBust(1.865, 0.875, 0.967, -0.899, 0.954, 1.269, 1.115, 1.633, -1.858)
  334. end
  335. #----------------------------------------------------------------------------
  336. # • Efeito de laranja mais escuro.
  337. #----------------------------------------------------------------------------
  338. def darkness_orange
  339. rgbaBust(0.712, -0.732, -0.965, -0.137, -0.345, 1.231, -1.883, 1.513, 1.967)
  340. end
  341. #----------------------------------------------------------------------------
  342. # • Efeito rsh1
  343. #----------------------------------------------------------------------------
  344. def rsh1
  345. rgbaBust(1.7144, 1.835, -0.821, 1.457, -1.579, 1.892, 1.461, 1.164, 0.112)
  346. end
  347. #----------------------------------------------------------------------------
  348. # • Efeito dá cor se parecer que está embaixo d'água.
  349. #----------------------------------------------------------------------------
  350. def color_water
  351. rgbaBust(0.421, 0.409, 1.342, 1.947, 0.515, -0.348, 0.055, 0.623, -0.906)
  352. end
  353. #----------------------------------------------------------------------------
  354. # • Efeito rsh3
  355. #----------------------------------------------------------------------------
  356. def rsh3
  357. rgbaBust(-0.214, 1.070, -0.652, -1.807, 1.493, 1.086, -0.501, 1.744, -0.526)
  358. end
  359. #----------------------------------------------------------------------------
  360. # • Efeito rsh5
  361. #----------------------------------------------------------------------------
  362. def rsh5
  363. rgbaBust(1.483, -0.677, -0.826, 0.502, 1.773, -0.707, 1.147, -0.902, 0.227)
  364. end
  365. #----------------------------------------------------------------------------
  366. # • Efeito rsh0
  367. #----------------------------------------------------------------------------
  368. def rsh0
  369. rgbaBust(-1.060, 0.447, 0.643, 0.978, 0.517, 1.407, -0.876, 0.069, 1.943)
  370. end
  371. #----------------------------------------------------------------------------
  372. # • Método de saturação.
  373. # amount : Quantidade. 0.0 minímo : 255.0 máximo.
  374. #----------------------------------------------------------------------------
  375. def saturation(amount=0.0)
  376. return unless valid_bitmap?
  377. BitmapColorSaturation.call(self.__id__, (amount <= 0.0 ? amount = 0.0 : amount >= 255.0 ? amount = 255.0 : amount) * 1000)
  378. end
  379. #----------------------------------------------------------------------------
  380. # • Método de brilho.
  381. # amount : Quantidade.
  382. #----------------------------------------------------------------------------
  383. def brightness(amount=0)
  384. return unless valid_bitmap?
  385. BitmapColorBrightness.call(self.__id__, amount)
  386. end
  387. #----------------------------------------------------------------------------
  388. # • Método de contraste.
  389. # amount : Quantidade.
  390. #----------------------------------------------------------------------------
  391. def contrast(amount=0)
  392. return unless valid_bitmap?
  393. BitmapColorContrast.call(self.__id__, amount)
  394. end
  395. #----------------------------------------------------------------------------
  396. # • Filtro 33.
  397. #----------------------------------------------------------------------------
  398. def filter33(*args)
  399. return unless valid_bitmap?
  400. BitmapFilter33.call(self.__id__, *args)
  401. end
  402. #----------------------------------------------------------------------------
  403. # • Filtro 34.
  404. #----------------------------------------------------------------------------
  405. def filter34(*args)
  406. return unless valid_bitmap?
  407. BitmapFilter34.call(self.__id__, *args)
  408. end
  409. #----------------------------------------------------------------------------
  410. # • Filtro 33 : Efeito de blur.
  411. #----------------------------------------------------------------------------
  412. def blur
  413. filter33(0,1,0,1,1,1,0,1,0,5)
  414. end
  415. #----------------------------------------------------------------------------
  416. # • Filtro 33 : Efeito de blur mais intenso.
  417. #----------------------------------------------------------------------------
  418. def blur!
  419. filter33(1,1,1,1,1,1,1,1,1,9)
  420. end
  421. #----------------------------------------------------------------------------
  422. # • Filtro 33 : Sharpen
  423. #----------------------------------------------------------------------------
  424. def sharpen
  425. filter33(0,-1,0,-1,5,-1,0,-1,0,1)
  426. end
  427. #----------------------------------------------------------------------------
  428. # • Filtro 33 : Sharpen mais intenso.
  429. #----------------------------------------------------------------------------
  430. def sharpen!
  431. filter33(-1,-1,-1,-1,9,-1,-1,-1,-1,1)
  432. end
  433. #----------------------------------------------------------------------------
  434. # • Filtro 33 : Detectar as bordas.
  435. #----------------------------------------------------------------------------
  436. def detect_edges
  437. filter33(0,-1,0,-1,4,-1,0,-1,0,1)
  438. end
  439. #----------------------------------------------------------------------------
  440. # • Filtro 33 : Efeito emboss("modelar")
  441. #----------------------------------------------------------------------------
  442. def emboss
  443. filter33(-2,-1,0,-1,1,1,0,1,2,1)
  444. end
  445. #----------------------------------------------------------------------------
  446. # • Monochrome : Converte as cores em uma escala só.
  447. #----------------------------------------------------------------------------
  448. def monochrome
  449. return unless valid_bitmap?
  450. BitmapMonochrome.call(self.__id__)
  451. end
  452. #----------------------------------------------------------------------------
  453. # • Colorize : Colorir o bitmap.
  454. #----------------------------------------------------------------------------
  455. def colorize(amount, red, green, blue)
  456. return unless valid_bitmap?
  457. BitmapColorize.call(self.__id__, amount, red, green, blue)
  458. end
  459. #----------------------------------------------------------------------------
  460. # • Tint : Preencher bitmap.
  461. #----------------------------------------------------------------------------
  462. def tint(amount, red, green, blue)
  463. return unless valid_bitmap?
  464. BitmapTint.call(self.__id__, amount, red, green, blue)
  465. end
  466. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement