1
0

tests.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. Test:y_bitmap_Fade1()
  65. {
  66. new
  67. Bitmap:ctx;
  68. ctx = Bitmap_Create(256, 256);
  69. for (new y = 0; y != 256; ++y)
  70. {
  71. for (new x = 0; x != 256; ++x)
  72. {
  73. Bitmap_WritePixel(ctx, x, y, Y_RED | (x * y / 256));
  74. }
  75. }
  76. Bitmap_Write(ctx, "y_bitmap_Fade1.bmp");
  77. Bitmap_Destroy(ctx);
  78. }
  79. Test:y_bitmap_Fade2()
  80. {
  81. new
  82. Bitmap:ctx;
  83. ctx = Bitmap_Create(256, 256);
  84. for (new y = 0; y != 256; ++y)
  85. {
  86. for (new x = 0; x != 256; ++x)
  87. {
  88. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  89. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  90. }
  91. }
  92. Bitmap_Write(ctx, "y_bitmap_Fade2.bmp");
  93. Bitmap_Destroy(ctx);
  94. }
  95. Test:y_bitmap_Rect1()
  96. {
  97. new
  98. Bitmap:ctx;
  99. ctx = Bitmap_Create(256, 256);
  100. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0xFF);
  101. Bitmap_Write(ctx, "y_bitmap_Rect1.bmp");
  102. Bitmap_Destroy(ctx);
  103. }
  104. Test:y_bitmap_Rect2()
  105. {
  106. new
  107. Bitmap:ctx;
  108. ctx = Bitmap_Create(256, 256);
  109. Bitmap_DrawRectangle(ctx, 64, 64, 128, 192, Y_YELLOW | 0x80);
  110. Bitmap_DrawRectangle(ctx, 128, 64, 192, 192, Y_ALICEBLUE | 0x80);
  111. Bitmap_Write(ctx, "y_bitmap_Rect2.bmp");
  112. Bitmap_Destroy(ctx);
  113. }
  114. Test:y_bitmap_Rect3()
  115. {
  116. new
  117. Bitmap:ctx;
  118. ctx = Bitmap_Create(256, 256);
  119. Bitmap_DrawRectangle(ctx, 64, 64, 148, 192, Y_YELLOW | 0x80);
  120. Bitmap_DrawRectangle(ctx, 108, 64, 192, 192, Y_ALICEBLUE | 0x80);
  121. Bitmap_Write(ctx, "y_bitmap_Rect3.bmp");
  122. Bitmap_Destroy(ctx);
  123. }
  124. Test:y_bitmap_FadeRect1()
  125. {
  126. new
  127. Bitmap:ctx;
  128. ctx = Bitmap_Create(256, 256);
  129. for (new y = 0; y != 256; ++y)
  130. {
  131. for (new x = 0; x != 256; ++x)
  132. {
  133. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  134. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  135. }
  136. }
  137. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40);
  138. Bitmap_Write(ctx, "y_bitmap_FadeRect1.bmp");
  139. Bitmap_Destroy(ctx);
  140. }
  141. Test:y_bitmap_Diagonal1()
  142. {
  143. new
  144. Bitmap:ctx;
  145. ctx = Bitmap_Create(256, 256);
  146. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL, STRIPE1 = 4, STRIPE2 = 4));
  147. for (new y = 0; y != 256; ++y)
  148. {
  149. for (new x = 0; x != 256; ++x)
  150. {
  151. //Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  152. new
  153. alpha = YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX};
  154. if (alpha == 255)
  155. Bitmap_WritePixel(ctx, x, y, X11_RED);
  156. else if (alpha == 0)
  157. Bitmap_WritePixel(ctx, x, y, X11_WHITE);
  158. else if (alpha > 127)
  159. Bitmap_WritePixel(ctx, x, y, X11_GREEN);
  160. else
  161. Bitmap_WritePixel(ctx, x, y, X11_BLUE);
  162. }
  163. }
  164. Bitmap_Write(ctx, "y_bitmap_Diagonal1.bmp");
  165. Bitmap_Destroy(ctx);
  166. }
  167. Test:y_bitmap_Diagonal2()
  168. {
  169. new
  170. Bitmap:ctx;
  171. ctx = Bitmap_Create(256, 256);
  172. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL, STRIPE1 = 2, STRIPE2 = 2));
  173. for (new y = 0; y != 256; ++y)
  174. {
  175. for (new x = 0; x != 256; ++x)
  176. {
  177. Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  178. }
  179. }
  180. Bitmap_Write(ctx, "y_bitmap_Diagonal2.bmp");
  181. Bitmap_Destroy(ctx);
  182. }
  183. Test:y_bitmap_Diagonal3()
  184. {
  185. new
  186. Bitmap:ctx;
  187. ctx = Bitmap_Create(256, 256);
  188. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL, STRIPE1 = 3, STRIPE2 = 3));
  189. for (new y = 0; y != 256; ++y)
  190. {
  191. for (new x = 0; x != 256; ++x)
  192. {
  193. Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  194. }
  195. }
  196. Bitmap_Write(ctx, "y_bitmap_Diagonal3.bmp");
  197. Bitmap_Destroy(ctx);
  198. }
  199. Test:y_bitmap_Diagonal4()
  200. {
  201. new
  202. Bitmap:ctx;
  203. ctx = Bitmap_Create(256, 256);
  204. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL, STRIPE1 = 2, STRIPE2 = 4));
  205. for (new y = 0; y != 256; ++y)
  206. {
  207. for (new x = 0; x != 256; ++x)
  208. {
  209. Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  210. }
  211. }
  212. Bitmap_Write(ctx, "y_bitmap_Diagonal4.bmp");
  213. Bitmap_Destroy(ctx);
  214. }
  215. Test:y_bitmap_Diagonal5()
  216. {
  217. new
  218. Bitmap:ctx;
  219. ctx = Bitmap_Create(256, 256);
  220. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL, STRIPE1 = 4, STRIPE2 = 2));
  221. for (new y = 0; y != 256; ++y)
  222. {
  223. for (new x = 0; x != 256; ++x)
  224. {
  225. Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  226. }
  227. }
  228. Bitmap_Write(ctx, "y_bitmap_Diagonal5.bmp");
  229. Bitmap_Destroy(ctx);
  230. }
  231. Test:y_bitmap_Diagonal6()
  232. {
  233. new
  234. Bitmap:ctx;
  235. ctx = Bitmap_Create(256, 256);
  236. _BMP_PAT@DIAGONAL(0, 0, 0, 0, PATTERN(DIAGONAL));
  237. for (new y = 0; y != 256; ++y)
  238. {
  239. for (new x = 0; x != 256; ++x)
  240. {
  241. Bitmap_WritePixel(ctx, x, y, Y_GREEN | (YSI_gBitmapAlpha[y % YSI_gBitmapAlphaY]{x % YSI_gBitmapAlphaX}));
  242. }
  243. }
  244. Bitmap_Write(ctx, "y_bitmap_Diagonal6.bmp");
  245. Bitmap_Destroy(ctx);
  246. }
  247. Test:y_bitmap_Pattern1()
  248. {
  249. new
  250. Bitmap:ctx;
  251. ctx = Bitmap_Create(256, 256);
  252. for (new y = 0; y != 256; ++y)
  253. {
  254. for (new x = 0; x != 256; ++x)
  255. {
  256. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  257. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  258. }
  259. }
  260. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(SOLID));
  261. Bitmap_Write(ctx, "y_bitmap_Pattern1.bmp");
  262. Bitmap_Destroy(ctx);
  263. }
  264. Test:y_bitmap_Pattern2()
  265. {
  266. new
  267. Bitmap:ctx;
  268. ctx = Bitmap_Create(256, 256);
  269. for (new y = 0; y != 256; ++y)
  270. {
  271. for (new x = 0; x != 256; ++x)
  272. {
  273. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  274. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  275. }
  276. }
  277. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(DIAGONAL));
  278. Bitmap_Write(ctx, "y_bitmap_Pattern2.bmp");
  279. Bitmap_Destroy(ctx);
  280. }
  281. Test:y_bitmap_Pattern3()
  282. {
  283. new
  284. Bitmap:ctx;
  285. ctx = Bitmap_Create(256, 256);
  286. for (new y = 0; y != 256; ++y)
  287. {
  288. for (new x = 0; x != 256; ++x)
  289. {
  290. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  291. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  292. }
  293. }
  294. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(DIAGONAL, STRIPE1 = 16));
  295. Bitmap_Write(ctx, "y_bitmap_Pattern3.bmp");
  296. Bitmap_Destroy(ctx);
  297. }
  298. Test:y_bitmap_Pattern4()
  299. {
  300. new
  301. Bitmap:ctx;
  302. ctx = Bitmap_Create(256, 256);
  303. for (new y = 0; y != 256; ++y)
  304. {
  305. for (new x = 0; x != 256; ++x)
  306. {
  307. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  308. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  309. }
  310. }
  311. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(DIAGONAL, STRIPE2 = 16));
  312. Bitmap_Write(ctx, "y_bitmap_Pattern4.bmp");
  313. Bitmap_Destroy(ctx);
  314. }
  315. Test:y_bitmap_Pattern5()
  316. {
  317. new
  318. Bitmap:ctx;
  319. ctx = Bitmap_Create(256, 256);
  320. for (new y = 0; y != 256; ++y)
  321. {
  322. for (new x = 0; x != 256; ++x)
  323. {
  324. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  325. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  326. }
  327. }
  328. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(DIAGONAL, STRIPE1 = 16, STRIPE2 = 8));
  329. Bitmap_Write(ctx, "y_bitmap_Pattern5.bmp");
  330. Bitmap_Destroy(ctx);
  331. }
  332. Test:y_bitmap_Pattern6()
  333. {
  334. new
  335. Bitmap:ctx;
  336. ctx = Bitmap_Create(256, 256);
  337. for (new y = 0; y != 256; ++y)
  338. {
  339. for (new x = 0; x != 256; ++x)
  340. {
  341. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  342. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  343. }
  344. }
  345. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(DIAGONAL, STRIPE1 = 16, STRIPE2 = 8, RIGHT));
  346. Bitmap_Write(ctx, "y_bitmap_Pattern6.bmp");
  347. Bitmap_Destroy(ctx);
  348. }
  349. Test:y_bitmap_Pattern7()
  350. {
  351. new
  352. Bitmap:ctx;
  353. ctx = Bitmap_Create(256, 256);
  354. for (new y = 0; y != 256; ++y)
  355. {
  356. for (new x = 0; x != 256; ++x)
  357. {
  358. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  359. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  360. }
  361. }
  362. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(STRIPED));
  363. Bitmap_Write(ctx, "y_bitmap_Pattern7.bmp");
  364. Bitmap_Destroy(ctx);
  365. }
  366. Test:y_bitmap_Pattern8()
  367. {
  368. new
  369. Bitmap:ctx;
  370. ctx = Bitmap_Create(256, 256);
  371. for (new y = 0; y != 256; ++y)
  372. {
  373. for (new x = 0; x != 256; ++x)
  374. {
  375. Bitmap_WritePixel(ctx, x, y, Y_RED | y);
  376. Bitmap_WritePixel(ctx, x, y, Y_GREEN | x);
  377. }
  378. }
  379. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_YELLOW | 0x40, .fillPattern = PATTERN(STRIPED, HORIZONTAL));
  380. Bitmap_Write(ctx, "y_bitmap_Pattern8.bmp");
  381. Bitmap_Destroy(ctx);
  382. }
  383. Test:y_bitmap_Border1()
  384. {
  385. new
  386. Bitmap:ctx;
  387. ctx = Bitmap_Create(256, 256);
  388. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE);
  389. Bitmap_Write(ctx, "y_bitmap_Border1.bmp");
  390. Bitmap_Destroy(ctx);
  391. }
  392. Test:y_bitmap_Border2()
  393. {
  394. new
  395. Bitmap:ctx;
  396. ctx = Bitmap_Create(256, 256);
  397. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE, .linePattern = PATTERN(SOLID, BORDER = 16));
  398. Bitmap_Write(ctx, "y_bitmap_Border2.bmp");
  399. Bitmap_Destroy(ctx);
  400. }
  401. Test:y_bitmap_Border3()
  402. {
  403. new
  404. Bitmap:ctx;
  405. ctx = Bitmap_Create(256, 256);
  406. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE, .linePattern = PATTERN(DIAGONAL, BORDER = 32));
  407. Bitmap_Write(ctx, "y_bitmap_Border3.bmp");
  408. Bitmap_Destroy(ctx);
  409. }
  410. Test:y_bitmap_Border4()
  411. {
  412. new
  413. Bitmap:ctx;
  414. ctx = Bitmap_Create(256, 256);
  415. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE, .linePattern = PATTERN(DOTTED));
  416. Bitmap_Write(ctx, "y_bitmap_Border4.bmp");
  417. Bitmap_Destroy(ctx);
  418. }
  419. Test:y_bitmap_Border5()
  420. {
  421. new
  422. Bitmap:ctx;
  423. ctx = Bitmap_Create(256, 256);
  424. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE, .linePattern = PATTERN(DOTTED, STRIPE1 = 16, STRIPE2 = 4));
  425. Bitmap_Write(ctx, "y_bitmap_Border5.bmp");
  426. Bitmap_Destroy(ctx);
  427. }
  428. Test:y_bitmap_Border6()
  429. {
  430. new
  431. Bitmap:ctx;
  432. ctx = Bitmap_Create(256, 256);
  433. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, 0, X11_ROYALBLUE, .linePattern = PATTERN(DOTTED, STRIPE1 = 1, STRIPE2 = 8));
  434. Bitmap_Write(ctx, "y_bitmap_Border6.bmp");
  435. Bitmap_Destroy(ctx);
  436. }
  437. Test:y_bitmap_Large1()
  438. {
  439. new
  440. Bitmap:ctx;
  441. ctx = Bitmap_Create(512, 512);
  442. Bitmap_DrawRectangle(ctx, 64, 64, 192, 192, Y_LAVENDER | 0xFF);
  443. Bitmap_Write(ctx, "y_bitmap_Large1.bmp");
  444. Bitmap_Destroy(ctx);
  445. }
  446. Test:y_bitmap_Large2()
  447. {
  448. new
  449. Bitmap:ctx;
  450. ctx = Bitmap_Create(512, 512);
  451. Bitmap_DrawRectangle(ctx, 0, 0, 256, 256, Y_LAVENDER | 0xFF);
  452. Bitmap_Write(ctx, "y_bitmap_Large2.bmp");
  453. Bitmap_Destroy(ctx);
  454. }
  455. Test:y_bitmap_Large3()
  456. {
  457. new
  458. Bitmap:ctx;
  459. ctx = Bitmap_Create(512, 512);
  460. Bitmap_DrawRectangle(ctx, 64, 64, 512, 512, Y_LAVENDER | 0xFF);
  461. Bitmap_Write(ctx, "y_bitmap_Large3.bmp");
  462. Bitmap_Destroy(ctx);
  463. }
  464. Test:y_bitmap_Large4()
  465. {
  466. new
  467. Bitmap:ctx;
  468. ctx = Bitmap_Create(512, 512);
  469. Bitmap_DrawRectangle(ctx, 64, 64, 70, 500, Y_LAVENDER | 0xFF);
  470. Bitmap_Write(ctx, "y_bitmap_Large4.bmp");
  471. Bitmap_Destroy(ctx);
  472. }
  473. Test:y_bitmap_Large5()
  474. {
  475. new
  476. Bitmap:ctx;
  477. ctx = Bitmap_Create(512, 512);
  478. Bitmap_DrawRectangle(ctx, 64, 64, 500, 70, Y_LAVENDER | 0xFF);
  479. Bitmap_Write(ctx, "y_bitmap_Large5.bmp");
  480. Bitmap_Destroy(ctx);
  481. }
  482. Test:y_bitmap_VLarge1()
  483. {
  484. new
  485. Bitmap:ctx;
  486. ctx = Bitmap_Create(1024, 1024);
  487. Bitmap_DrawRectangle(ctx, 256, 256, 768, 768, Y_MINTCREAM | 0xFF);
  488. Bitmap_Write(ctx, "y_bitmap_VLarge1.bmp");
  489. Bitmap_Destroy(ctx);
  490. }