bgrascript.pas 19 KB

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