bgrascript.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. // SPDX-License-Identifier: LGPL-3.0-linking-exception
  2. {
  3. Created by BGRA Controls Team
  4. Dibo, Circular, lainz (007) and contributors.
  5. For detailed information see readme.txt
  6. Site: https://sourceforge.net/p/bgra-controls/
  7. Wiki: http://wiki.lazarus.freepascal.org/BGRAControls
  8. Forum: http://forum.lazarus.freepascal.org/index.php/board,46.0.html
  9. }
  10. unit BGRAScript;
  11. {$DEFINE RO_FPC_MODE_SET}
  12. {$I bgracontrols.inc}
  13. { $define debug}
  14. interface
  15. uses
  16. Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Dialogs;
  17. {Template}
  18. procedure SynCompletionList(itemlist: TStrings);
  19. {Scripting}
  20. function ScriptCommand(command: string; var bitmap: TBGRABitmap;
  21. var variables: TStringList; var line: integer): boolean;
  22. function ScriptCommandList(commandlist: TStrings; var bitmap: TBGRABitmap): boolean;
  23. {Tools}
  24. function StrToDrawMode(mode: string): TDrawMode;
  25. implementation
  26. procedure SynCompletionList(itemlist: TStrings);
  27. begin
  28. with itemlist do
  29. begin
  30. {Assign key values}
  31. Add('let key "value"');
  32. {Goto line}
  33. Add('goto 10');
  34. {Messages}
  35. Add('print "Message"');
  36. Add('input "Title","Message","Default value",result');
  37. {Read Values}
  38. Add('GetWidth width');
  39. Add('GetHeight height');
  40. {TFPCustomImage override}
  41. Add('SetSize 320,240');
  42. {Loading functions}
  43. Add('SaveToFile "file.png"');
  44. {Loading functions}
  45. Add('SetHorizLine 0,0,100,"rgba(0,0,0,1)"');
  46. Add('XorHorizLine 0,0,100,"rgba(0,0,0,1)"');
  47. Add('DrawHorizLine 0,0,100,"rgba(0,0,0,1)"');
  48. Add('FastBlendHorizLine 0,0,100,"rgba(0,0,0,1)"');
  49. Add('AlphaHorizLine 0,0,100,"rgba(0,0,0,1)"');
  50. Add('SetVertLine 0,0,100,"rgba(0,0,0,1)"');
  51. Add('XorVertLine 0,0,100,"rgba(0,0,0,1)"');
  52. Add('DrawVertLine 0,0,100,"rgba(0,0,0,1)"');
  53. Add('FastBlendVertLine 0,0,100,"rgba(0,0,0,1)"');
  54. Add('AlphaVertLine 0,0,100,"rgba(0,0,0,1)"');
  55. Add('DrawHorizLinediff 0,0,100,"rgba(0,0,0,1)","rgba(255,255,255,1)",128');
  56. //--
  57. Add('FillTransparent');
  58. Add('Rectangle 0,0,100,100,"rgba(0,0,0,1)","rgba(255,255,255,1)","dmDrawWithTransparency"');
  59. Add('RectangleAntiAlias "0,5","0,5","99,5","99,5","rgba(0,0,0,1)","1,5","rgba(255,255,255,1)"');
  60. {BGRA bitmap functions}
  61. Add('RotateCW');
  62. Add('RotateCCW');
  63. Add('Negative');
  64. Add('NegativeRect 0,0,100,100');
  65. Add('LinearNegative');
  66. Add('LinearNegativeRect 0,0,100,100');
  67. Add('InplaceGrayscale');
  68. Add('InplaceGrayscaleRect 0,0,100,100');
  69. Add('SwapRedBlue');
  70. Add('GrayscaleToAlpha');
  71. Add('AlphaToGrayscale');
  72. Add('ApplyGlobalOpacity 128');
  73. Add('ConvertToLinearRGB');
  74. Add('ConvertFromLinearRGB');
  75. Add('DrawCheckers 0,0,100,100,"rgba(100,100,100,255)","rgba(0,0,0,0)"');
  76. {Custom functions}
  77. Add('VerticalFlip 0,0,100,100');
  78. Add('HorizontalFlip 0,0,100,100');
  79. Add('BlendBitmap 0,0,"file.png","boTransparent"');
  80. Add('BlendBitmapOver 0,0,"file.png","boTransparent",255,"False"');
  81. Add('ApplyBitmapMask "file.png",0,0,100,100,0,0');
  82. {Filters}
  83. Add('FilterFastBlur 5,"False"');
  84. Add('FilterSmooth "False"');
  85. Add('FilterSharpen 5,"False"');
  86. Add('FilterContour');
  87. Add('FilterEmboss "1,5"');
  88. Add('FilterNormalize "True"');
  89. Add('FilterSphere "True"');
  90. Add('FilterCylinder "True"');
  91. Add('FilterPlane "True"');
  92. end;
  93. end;
  94. function ScriptCommand(command: string; var bitmap: TBGRABitmap;
  95. var variables: TStringList; var line: integer): boolean;
  96. function ParamCheck(passed, mustbe: integer): boolean;
  97. begin
  98. Result := True;
  99. if passed <> mustbe then
  100. Result := False;
  101. {$IFDEF INDEBUG}
  102. if not Result then
  103. begin
  104. writeln('>> Wrong number of parameters: ' + IntToStr(passed));
  105. writeln('>> Must be: ' + IntToStr(mustbe));
  106. end;
  107. {$endif}
  108. end;
  109. function ParamCheckAtLeast(passed, mustbe: integer): boolean;
  110. begin
  111. Result := True;
  112. if passed < mustbe then
  113. Result := False;
  114. {$IFDEF INDEBUG}
  115. if not Result then
  116. begin
  117. writeln('>> Wrong number of parameters: ' + IntToStr(passed));
  118. writeln('>> At least must be: ' + IntToStr(mustbe));
  119. end;
  120. {$endif}
  121. end;
  122. var
  123. list: TStringList;
  124. passed: integer;
  125. tmpbmp1: TBGRABitmap;
  126. i: integer;
  127. a: string;
  128. begin
  129. { $ifdef debug}
  130. //writeln('---Script-Command---');
  131. { $endif}
  132. Result := True;
  133. list := TStringList.Create;
  134. list.CommaText := command;
  135. passed := list.Count;
  136. {Replace values in variable names}
  137. for i := 0 to list.Count - 1 do
  138. if variables.Values[list[i]] <> '' then
  139. list[i] := variables.Values[list[i]];
  140. case LowerCase(list[0]) of
  141. {Assign key values}
  142. 'let':
  143. begin
  144. Result := ParamCheck(passed, 3);
  145. if Result then
  146. variables.Add(list[1] + '=' + list[2]);
  147. end;
  148. {Messages}
  149. 'input':
  150. begin
  151. Result := ParamCheck(passed, 5);
  152. if Result then
  153. begin
  154. a := InputBox(list[1],list[2],list[3]);
  155. variables.Add(list[4] + '=' + a);
  156. end;
  157. end;
  158. 'print':
  159. begin
  160. Result := ParamCheckAtLeast(passed, 2);
  161. if Result then
  162. begin
  163. a := '';
  164. for i:=1 to passed -1 do
  165. a := a + list[i];
  166. ShowMessage(a);
  167. end;
  168. end;
  169. {GoTo}
  170. 'goto':
  171. begin
  172. Result := ParamCheck(passed,2);
  173. if Result then
  174. begin
  175. line := StrToInt(list[1]) - 2;
  176. if line < 0 then
  177. line := -1;
  178. end;
  179. end;
  180. {Read values}
  181. 'getwidth':
  182. begin
  183. Result := ParamCheck(passed, 2);
  184. if Result then
  185. variables.Add(list[1] + '=' + IntToStr(bitmap.Width));
  186. end;
  187. 'getheight':
  188. begin
  189. Result := ParamCheck(passed, 2);
  190. if Result then
  191. variables.Add(list[1] + '=' + IntToStr(bitmap.Height));
  192. end;
  193. {TFPCustomImage override}
  194. 'setsize':
  195. begin
  196. Result := ParamCheck(passed, 3);
  197. if Result then
  198. bitmap.SetSize(StrToInt(list[1]), StrToInt(list[2]));
  199. end;
  200. {Loading functions}
  201. 'savetofile':
  202. begin
  203. Result := ParamCheck(passed, 2);
  204. if Result then
  205. bitmap.SaveToFile(list[1]);
  206. end;
  207. {Pixel functions}
  208. {Loading functions}
  209. {* Horiz *}
  210. 'sethorizline':
  211. begin
  212. Result := ParamCheck(passed, 5);
  213. if Result then
  214. bitmap.SetHorizLine(StrToInt(list[1]), StrToInt(list[2]),
  215. StrToInt(list[3]), StrToBGRA(list[4]));
  216. end;
  217. 'xorhorizline':
  218. begin
  219. Result := ParamCheck(passed, 5);
  220. if Result then
  221. bitmap.XorHorizLine(StrToInt(list[1]), StrToInt(list[2]),
  222. StrToInt(list[3]), StrToBGRA(list[4]));
  223. end;
  224. 'drawhorizline':
  225. begin
  226. Result := ParamCheck(passed, 5);
  227. if Result then
  228. bitmap.DrawHorizLine(StrToInt(list[1]), StrToInt(list[2]),
  229. StrToInt(list[3]), StrToBGRA(list[4]));
  230. end;
  231. 'fastblendhorizline':
  232. begin
  233. Result := ParamCheck(passed, 5);
  234. if Result then
  235. bitmap.FastBlendHorizLine(StrToInt(list[1]), StrToInt(list[2]),
  236. StrToInt(list[3]), StrToBGRA(list[4]));
  237. end;
  238. 'alphahorizline':
  239. begin
  240. Result := ParamCheck(passed, 5);
  241. if Result then
  242. bitmap.AlphaHorizLine(StrToInt(list[1]), StrToInt(list[2]),
  243. StrToInt(list[3]), StrToInt(list[4]));
  244. end;
  245. {* Vert *}
  246. 'setvertline':
  247. begin
  248. Result := ParamCheck(passed, 5);
  249. if Result then
  250. bitmap.SetVertLine(StrToInt(list[1]), StrToInt(list[2]),
  251. StrToInt(list[3]), StrToBGRA(list[4]));
  252. end;
  253. 'xorvertline':
  254. begin
  255. Result := ParamCheck(passed, 5);
  256. if Result then
  257. bitmap.XorVertLine(StrToInt(list[1]), StrToInt(list[2]),
  258. StrToInt(list[3]), StrToBGRA(list[4]));
  259. end;
  260. 'drawvertline':
  261. begin
  262. Result := ParamCheck(passed, 5);
  263. if Result then
  264. bitmap.DrawVertLine(StrToInt(list[1]), StrToInt(list[2]),
  265. StrToInt(list[3]), StrToBGRA(list[4]));
  266. end;
  267. 'fastblendvertline':
  268. begin
  269. Result := ParamCheck(passed, 5);
  270. if Result then
  271. bitmap.FastBlendVertLine(StrToInt(list[1]), StrToInt(list[2]),
  272. StrToInt(list[3]), StrToBGRA(list[4]));
  273. end;
  274. 'alphavertline':
  275. begin
  276. Result := ParamCheck(passed, 5);
  277. if Result then
  278. bitmap.AlphaVertLine(StrToInt(list[1]), StrToInt(list[2]),
  279. StrToInt(list[3]), StrToInt(list[4]));
  280. end;
  281. {* Misc *}
  282. 'drawhorizlinediff':
  283. begin
  284. Result := ParamCheck(passed, 7);
  285. if Result then
  286. bitmap.DrawHorizLineDiff(StrToInt(list[1]), StrToInt(list[2]),
  287. StrToInt(list[3]), StrToBGRA(list[4]), StrToBGRA(list[5]), StrToInt(list[6]));
  288. end;
  289. //---
  290. 'filltransparent':
  291. begin
  292. Result := ParamCheck(passed, 1);
  293. if Result then
  294. bitmap.FillTransparent;
  295. end;
  296. 'rectangle':
  297. begin
  298. Result := ParamCheck(passed, 8);
  299. if Result then
  300. bitmap.Rectangle(StrToInt(list[1]), StrToInt(list[2]), StrToInt(
  301. list[3]), StrToInt(list[4]), StrToBGRA(list[5]), StrToBGRA(list[6]),
  302. StrToDrawMode(list[7]));
  303. end;
  304. 'rectangleantialias':
  305. begin
  306. Result := ParamCheck(passed, 8);
  307. if Result then
  308. bitmap.RectangleAntialias(StrToFloat(list[1]), StrToFloat(list[2]),
  309. StrToFloat(list[3]), StrToFloat(list[4]), StrToBGRA(list[5]),
  310. StrToFloat(list[6]), StrToBGRA(list[7]));
  311. end;
  312. {BGRA bitmap functions}
  313. 'verticalflip':
  314. begin
  315. Result := ParamCheck(passed, 5);
  316. if Result then
  317. bitmap.VerticalFlip(Rect(StrToInt(list[1]), StrToInt(list[2]),
  318. StrToInt(list[3]), StrToInt(list[4])));
  319. end;
  320. 'horizontalflip':
  321. begin
  322. Result := ParamCheck(passed, 5);
  323. if Result then
  324. bitmap.HorizontalFlip(Rect(StrToInt(list[1]), StrToInt(list[2]),
  325. StrToInt(list[3]), StrToInt(list[4])));
  326. end;
  327. 'rotatecw':
  328. begin
  329. Result := ParamCheck(passed, 1);
  330. if Result then
  331. try
  332. tmpbmp1 := bitmap.RotateCW as TBGRABitmap;
  333. bitmap.FillTransparent;
  334. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  335. finally
  336. tmpbmp1.Free;
  337. end;
  338. end;
  339. 'rotateccw':
  340. begin
  341. Result := ParamCheck(passed, 1);
  342. if Result then
  343. try
  344. tmpbmp1 := bitmap.RotateCCW as TBGRABitmap;
  345. bitmap.FillTransparent;
  346. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  347. finally
  348. tmpbmp1.Free;
  349. end;
  350. end;
  351. 'negative':
  352. begin
  353. Result := ParamCheck(passed, 1);
  354. if Result then
  355. bitmap.Negative;
  356. end;
  357. 'negativerect':
  358. begin
  359. Result := ParamCheck(passed, 5);
  360. if Result then
  361. bitmap.NegativeRect(Rect(StrToInt(list[1]), StrToInt(list[2]),
  362. StrToInt(list[3]), StrToInt(list[4])));
  363. end;
  364. 'linearnegative':
  365. begin
  366. Result := ParamCheck(passed, 1);
  367. if Result then
  368. bitmap.LinearNegative;
  369. end;
  370. 'linearnegativerect':
  371. begin
  372. Result := ParamCheck(passed, 5);
  373. if Result then
  374. bitmap.LinearNegativeRect(Rect(StrToInt(list[1]), StrToInt(list[2]),
  375. StrToInt(list[3]), StrToInt(list[4])));
  376. end;
  377. 'inplacegrayscale':
  378. begin
  379. Result := ParamCheck(passed, 1);
  380. if Result then
  381. bitmap.InplaceGrayscale;
  382. end;
  383. 'inplacegrayscalerect':
  384. begin
  385. Result := ParamCheck(passed, 5);
  386. if Result then
  387. bitmap.InplaceGrayscale(Rect(StrToInt(list[1]), StrToInt(list[2]),
  388. StrToInt(list[3]), StrToInt(list[4])));
  389. end;
  390. 'swapredblue':
  391. begin
  392. Result := ParamCheck(passed, 1);
  393. if Result then
  394. bitmap.SwapRedBlue;
  395. end;
  396. 'grayscaletoalpha':
  397. begin
  398. Result := ParamCheck(passed, 1);
  399. if Result then
  400. bitmap.GrayscaleToAlpha;
  401. end;
  402. 'alphatograyscale':
  403. begin
  404. Result := ParamCheck(passed, 1);
  405. if Result then
  406. bitmap.AlphaToGrayscale;
  407. end;
  408. 'applyglobalopacity':
  409. begin
  410. Result := ParamCheck(passed, 2);
  411. if Result then
  412. bitmap.ApplyGlobalOpacity(StrToInt(list[1]));
  413. end;
  414. 'converttolinearrgb':
  415. begin
  416. Result := ParamCheck(passed, 1);
  417. if Result then
  418. bitmap.ConvertToLinearRGB;
  419. end;
  420. 'convertfromlinearrgb':
  421. begin
  422. Result := ParamCheck(passed, 1);
  423. if Result then
  424. bitmap.ConvertFromLinearRGB;
  425. end;
  426. 'drawcheckers':
  427. begin
  428. Result := ParamCheck(passed, 7);
  429. if Result then
  430. bitmap.DrawCheckers(Rect(StrToInt(list[1]), StrToInt(list[2]),
  431. StrToInt(list[3]), StrToInt(list[4])), StrToBGRA(list[5]), StrToBGRA(list[6]));
  432. end;
  433. {Filters}
  434. {Custom Functions}
  435. 'blendbitmap':
  436. begin
  437. Result := ParamCheck(passed, 5);
  438. if Result then
  439. try
  440. tmpbmp1 := TBGRABitmap.Create(list[3]);
  441. bitmap.BlendImage(StrToInt(list[1]), StrToInt(list[2]), tmpbmp1,
  442. StrToBlendOperation(list[4]));
  443. finally
  444. tmpbmp1.Free;
  445. end;
  446. end;
  447. 'blendbitmapover':
  448. begin
  449. Result := ParamCheck(passed, 7);
  450. if Result then
  451. try
  452. tmpbmp1 := TBGRABitmap.Create(list[3]);
  453. bitmap.BlendImageOver(StrToInt(list[1]), StrToInt(list[2]),
  454. tmpbmp1, StrToBlendOperation(list[4]), StrToInt(list[5]),
  455. StrToBool(list[6]));
  456. finally
  457. tmpbmp1.Free;
  458. end;
  459. end;
  460. 'applybitmapmask':
  461. begin
  462. Result := ParamCheck(passed, 8);
  463. if Result then
  464. try
  465. tmpbmp1 := TBGRABitmap.Create(list[1]);
  466. bitmap.ApplyMask(tmpbmp1, Rect(StrToInt(list[2]), StrToInt(
  467. list[3]), StrToInt(list[4]), StrToInt(list[5])), Point(
  468. StrToInt(list[6]), StrToInt(list[7])));
  469. finally
  470. tmpbmp1.Free;
  471. end;
  472. end;
  473. 'filterfastblur':
  474. begin
  475. Result := ParamCheck(passed, 3);
  476. if Result then
  477. begin
  478. tmpbmp1 := bitmap.FilterBlurRadial(StrToInt(list[1]), rbFast) as TBGRABitmap;
  479. if StrToBool(list[2]) then
  480. bitmap.FillTransparent;
  481. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  482. tmpbmp1.Free;
  483. end;
  484. end;
  485. 'filtersmooth':
  486. begin
  487. Result := ParamCheck(passed, 2);
  488. if Result then
  489. begin
  490. tmpbmp1 := bitmap.FilterSmooth as TBGRABitmap;
  491. if StrToBool(list[1]) then
  492. bitmap.FillTransparent;
  493. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  494. tmpbmp1.Free;
  495. end;
  496. end;
  497. 'filtersharpen':
  498. begin
  499. Result := ParamCheck(passed, 3);
  500. if Result then
  501. begin
  502. tmpbmp1 := bitmap.FilterSharpen(StrToInt(list[1])) as TBGRABitmap;
  503. if StrToBool(list[2]) then
  504. bitmap.FillTransparent;
  505. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  506. tmpbmp1.Free;
  507. end;
  508. end;
  509. 'filtercontour':
  510. begin
  511. Result := ParamCheck(passed, 1);
  512. if Result then
  513. begin
  514. tmpbmp1 := bitmap.FilterContour as TBGRABitmap;
  515. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  516. tmpbmp1.Free;
  517. end;
  518. end;
  519. 'filteremboss':
  520. begin
  521. Result := ParamCheck(passed, 2);
  522. if Result then
  523. begin
  524. tmpbmp1 := bitmap.FilterEmboss(StrToFloat(list[1])) as TBGRABitmap;
  525. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  526. tmpbmp1.Free;
  527. end;
  528. end;
  529. 'filternormalize':
  530. begin
  531. Result := ParamCheck(passed, 2);
  532. if Result then
  533. begin
  534. tmpbmp1 := bitmap.FilterNormalize(StrToBool(list[1])) as TBGRABitmap;
  535. bitmap.FillTransparent;
  536. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  537. tmpbmp1.Free;
  538. end;
  539. end;
  540. 'filtersphere':
  541. begin
  542. Result := ParamCheck(passed, 2);
  543. if Result then
  544. begin
  545. tmpbmp1 := bitmap.FilterSphere as TBGRABitmap;
  546. if StrToBool(list[1]) then
  547. bitmap.FillTransparent;
  548. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  549. tmpbmp1.Free;
  550. end;
  551. end;
  552. 'filtercylinder':
  553. begin
  554. Result := ParamCheck(passed, 2);
  555. if Result then
  556. begin
  557. tmpbmp1 := bitmap.FilterCylinder as TBGRABitmap;
  558. if StrToBool(list[1]) then
  559. bitmap.FillTransparent;
  560. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  561. tmpbmp1.Free;
  562. end;
  563. end;
  564. 'filterplane':
  565. begin
  566. Result := ParamCheck(passed, 2);
  567. if Result then
  568. begin
  569. tmpbmp1 := bitmap.FilterPlane as TBGRABitmap;
  570. if StrToBool(list[1]) then
  571. bitmap.FillTransparent;
  572. bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
  573. tmpbmp1.Free;
  574. end;
  575. end;
  576. '//':
  577. begin
  578. // comment
  579. end;
  580. '{':
  581. begin
  582. { comment }
  583. end;
  584. else
  585. begin
  586. {$IFDEF INDEBUG}
  587. writeln('>> Command "' + list[0] + '" not found.');
  588. {$endif}
  589. Result := False;
  590. end;
  591. end;
  592. {$IFDEF INDEBUG}
  593. if not Result then
  594. writeln('>> ERROR');
  595. for i := 0 to list.Count - 1 do
  596. writeln(' ' + list[i]);
  597. writeln('____________________');
  598. {$endif}
  599. list.Free;
  600. end;
  601. function ScriptCommandList(commandlist: TStrings; var bitmap: TBGRABitmap): boolean;
  602. var
  603. line: integer;
  604. variables: TStringList;
  605. begin
  606. {$IFDEF INDEBUG}
  607. //writeln('----SCRIPT--LIST----');
  608. writeln(' Executing ' + IntToStr(commandlist.Count) + ' lines...');
  609. writeln('____________________');
  610. {$endif}
  611. variables := TStringList.Create;
  612. {Result := True;
  613. for i := 0 to commandlist.Count - 1 do
  614. if commandlist[i] <> '' then
  615. ScriptCommand(commandlist[i], bitmap, variables);
  616. }
  617. Result := True;
  618. line := 0;
  619. repeat
  620. if commandlist[line] <> '' then
  621. ScriptCommand(commandlist[line], bitmap, variables, line);
  622. Inc(line);
  623. until line > commandList.Count;
  624. variables.Free;
  625. {$IFDEF INDEBUG}
  626. //writeln('----SCRIPT--LIST----');
  627. writeln(' END');
  628. writeln('____________________');
  629. {$endif}
  630. end;
  631. function StrToDrawMode(mode: string): TDrawMode;
  632. begin
  633. case LowerCase(mode) of
  634. 'dmset': Result := dmSet;
  635. 'dmsetexcepttransparent': Result := dmSetExceptTransparent;
  636. 'dmlinearblend': Result := dmLinearBlend;
  637. 'dmdrawwithtransparency': Result := dmDrawWithTransparency;
  638. 'dmxor': Result := dmXor;
  639. else
  640. Result := dmDrawWithTransparency;
  641. end;
  642. end;
  643. end.