Author Topic: DrawFrame - animation sub using DRAW  (Read 6687 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: DrawFrame - animation sub using DRAW
« Reply #15 on: January 20, 2020, 03:09:30 pm »
Quote
@bplus: I see you actualy even did not use the original DRAW there, instead you invented completely new language and treated all graphics by yourself. That is quite an advantage over using DRAW, where some limitations I cannot bypass - e.g.  I can't turn the direction in decimals (TA10.25 doesn't work), which makes turning large object choppy.


Yes very perceptive! Only one who has tried this can appreciate it, it may work to your advantage too but I am afraid we will run out of single letter commands and have to move to 2 letters or better yet whole words of variable length, specially if want mouse or rnd functions added and keep frames control pen size and, of course, way more variables! :-))

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: DrawFrame - animation sub using DRAW
« Reply #16 on: January 20, 2020, 06:32:00 pm »
following your post I met this
Quote
  I can't turn the direction in decimals (TA10.25 doesn't work), which makes turning large object choppy.
what do you mean in specific? I find your ideas very interesting!
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. CONST Black = _RGBA32(0, 0, 0, 255), White = _RGBA32(255, 255, 255, 255), Red = _RGBA32(200, 0, 0, 255), Blu = _RGBA32(0, 255, 255, 255), Green = _RGBA32(0, 255, 0, 255)
  3. FOR b = 1 TO 4 STEP 1
  4.     IF b = 1 THEN
  5.         DRAW "c" + STR$(White) + "BM-200,-100"
  6.     ELSEIF b = 2 THEN
  7.         DRAW "c" + STR$(Red) + "BM+400,+300"
  8.     ELSEIF b = 3 THEN
  9.         DRAW "c" + STR$(Blu) + "BM-200,+0"
  10.     ELSEIF b = 4 THEN
  11.         DRAW "c" + STR$(Green) + "BM-200,-100"
  12.     END IF
  13.     FOR a = 0 TO 360 STEP .25 '.5
  14.         LOCATE 1, 1: PRINT a; "    "
  15.         DRAW "TA" + STR$(a) + "M+50,+50BM-50,-50"
  16.         _DELAY .02
  17.     NEXT
  18. NEXT/code]
  19.  
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: DrawFrame - animation sub using DRAW
« Reply #17 on: January 20, 2020, 06:51:00 pm »
@Bplus
your tt is very fine duplicate of DRAW (?) or  very fine alternative to DRAW (?).
Thanks to share.
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: DrawFrame - animation sub using DRAW
« Reply #18 on: January 20, 2020, 07:12:31 pm »
You guys might want to add a simple SCALE command to your work.

“U1R1D1L1” — this would draw a simple 1 unit box...
Add a Scale command in front of it “^100” + “U1R1D1L” would draw a 100x100 box on the screen, as the “^” represents a scale amount for all commands after.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: DrawFrame - animation sub using DRAW
« Reply #19 on: January 20, 2020, 07:30:36 pm »
You guys might want to add a simple SCALE command to your work.

“U1R1D1L1” — this would draw a simple 1 unit box...
Add a Scale command in front of it “^100” + “U1R1D1L” would draw a 100x100 box on the screen, as the “^” represents a scale amount for all commands after.

Well I did use scale outside of the drawstrings commands so that I could use same strings at different scales, see reply #11 code lines 90-100.

@ TempodiBasic, Thanks, yes, I would say alternate to DRAW since it is not being used in tt SUB.
« Last Edit: January 20, 2020, 07:33:28 pm by bplus »

Offline dajan

  • Newbie
  • Posts: 41
    • View Profile
Re: DrawFrame - animation sub using DRAW
« Reply #20 on: January 21, 2020, 04:59:08 am »
what do you mean in specific?

TempodiBasic, bingo! Of course TA works with decimals, thanks a lot for pointing that out.  I tried and gave up, but now I realize I have probbably tried with such small numbers, that I have been feeding TA parameter with exponential number format and the DRAW went crazy.
I have fix that now, and the tree limbs swinging is WAY smoother, it is especially noticable in slow motion speeds.

And as a bonus, here's a new short clip with dog, I'll be teaching him new tricks, eventually:

Code: QB64: [Select]
  1.  
  2. '----------------------------------------------------------------------------------------------------------------------------------------------------
  3. ' The Tree string
  4. '----------------------------------------------------------------------------------------------------------------------------------------------------
  5. leaf1$ = "Q1:17;* (V30 K11:17;17.5 S1%;!40% K11:17.5;19 S!40%;50% V-90 K12 V-10;10 U50 V-800U20 V30U20 V30U20 V20U40 V20U40 V20U50 V100U50 V20U40 V20U40 V20U20 V30U20 V30U20 V-800 K12 U50;47 V180 K12 V10;-10 V90 V-30 S100%)"
  6. smallimb2$ = "Q2:7;* (V-90 K22:7;14 S1%;100% U100 K23:40;44 BM+0,+0;-4000,-100 K12:22;22.2# Q1 K23 BM+0,+0;+4000,+100 K22 S1%;100% U200 K23:47;49 BM+0,+0;-4000,-100 K12:22.1;22.3# Q1 K23 BM+0,+0;+4000,+100 K22 S1%;100% U100 V90 U10 V90 V-90 K23:49;51 BM+0,+0;-4000,-100 K12:22.2;22.4# Q1 K23 BM+0,+0;+4000,+100 K22 S1%;100% V90 U200 V-60 K23:49.5;51.5 BM+0,+0;-4000,-100 K12:22.3;22.5# Q1 K23 BM+0,+0;+4000,+100 K22 S1%;100% V60 U200 V-90 S100%)"
  7. biglimb3$ = "Q3:4;* (V-88 K31:4.0;11 S1%;100% U250 K32:25;25.4# V30;50 Q2 K32 V-30;-50 K31 S1%;100% U200 V88 K33:25.1;25.5# V-35;-15 Q2 K33 V35;15 V88 K34:25.2;25.6# V-40;-20 Q2 K34 V40;20 K31 S1%;100% U450 V92 V-180 S100%)"
  8. trunk4$ = "Q4 (K41:0;10 S1%;100% U500 K42:28.9;29.3# V30;40 Q3 K42 V-30;-40 K41 S1%;100% U400 V88 K43:29;29.4# V0;5 Q3 K43 V0;-5 V88 K41 S1%;100% U200 K44:29.1;29.5# V-30;-20 Q3 K44 V30;20 K41 S1%;100% M+0,+0;-10,-10 K45:17;17.6 M+0,+0;-25,-20 U700 V92 V92 S100%)"
  9. cloud5$ = "Q51:17; (Q5*8(U30-V30) S150% V200 Q5*6 S130% V230 Q5*6 S120% V210 Q5*8 S160% V220 Q5*6 S160% V235 Q5*6) S2"
  10. clip$ = "S2 BM1200,1000" + leaf1$ + smallimb2$ + biglimb3$ + "K1:0;10#C35;52 L400 K101:24.9;25.3# M-3,-0;+3,+0 " + trunk4$ + " K101 M+3,+0;-3,-0 M910,1000 L400 K102:17;23 BM2500,50;1400,100 TA90 K51:0;0.3# S2;2.05 " + cloud5$ + " TA0 K103:20;30 BM0,0 BM-800,+100;+500,+300 TA90 K51:0;0.3# S3;3.05 Q51"
  11.  
  12. '----------------------------------------------------------------------------------------------------------------------------------------------------
  13. ' Examples of clip strings
  14. '----------------------------------------------------------------------------------------------------------------------------------------------------
  15. 'clip$ = "BM500,300 Q1*12( U20 V30 )" '1 circle
  16. 'clip$ = "B M500,300 Q2*6( BU100 Q1*12( U20 V30 ) BD100 V60 )" '6 circles queued in round
  17. 'clip$ = "B M500,300 K1:0;3# V0;360 Q2*6( BU50 Q1*12( U10 V30 ) BD50 V60 )" '6 circles queued in round rotating
  18. 'clip$ = "B M500,300 K1:0;3* V0;360 Q2*6( K2:0;2# BU50;200 Q1*12( U10 V30 ) BD50;200 V60 )" '6 circles queued in round rotating and swingigng towards centre
  19. 'clip$ = "B M500,300 K2:0;2# K1:0;3* V0;360 Q2*6( K2_2:+0.2;+0.2# BU50;200 Q1*12( U10 V30 ) BD50;200 V60 )" '6 circles queued in round rotating and swingigng towards centre in different phase
  20. 'clip$ = "B M500,300 K2:0;1# K1:0;3* V0;360 Q2*6( K2_2:+0.2;+0.2# BU50;200 S100%;300% Q1*12( U10 V30 ) S100% BD50;200 V60 )" '6 circles queued in round rotating and swingigng towards centre in different phase changing size
  21.  
  22. '----------------------------------------------------------------------------------------------------------------------------------------------------
  23. ' The Dog string
  24. '----------------------------------------------------------------------------------------------------------------------------------------------------
  25. ' Q0 - dog positioning
  26. ' Q2 - dog walking
  27. ' Q3 - dog head shape, Q31 - head running
  28. ' Q4 - dog ear shape, Q41 - ear running
  29. ' Q5 - dog tail shape, Q51 - tail running
  30. ' Q7 - dog foot shape, Q71 - foot running
  31.  
  32. clip$ = "S2 BM1900,518 L3500 Q0*(K0:0;10 BM1800,400;300,400 TA0)  Q7*(L40 D20 R40 U20)  Q71*(BM+20,+180 K71_71:-0.5;-0.5* K72_71:+0;-0.5# K71 V0;360 BD40 V360;0 K72 V-10;30 Q7) K41:0;0.25#"+_
  33.         "Q4*(L40M+20,-40M+20,40) Q41*(K41_41:+0.05;+0.05# V-35;15 Q4 V35;-15) " + _
  34.         "Q5*(R50 U40 L50 D40) Q51*(K51:0;0.25#  V10;30 BM+100,-40 Q5)" + _
  35.         "Q3*(BM-20,-110 L200D120R200U120 BM-70,+30 R20D20L20U20 BM-120,-20 R30D30L30U30)  Q31*(K32:4;4.5 V0;50 K33_32:+3;+2.8 V!0;-50 K32 BM+0,0;-50,20 K33 BM+0,0;+50,-20 K31:0;0.25# BD-20;10 Q3 BM+140,-30 Q41 BR60 Q41) "+ _
  36.         "Q2(Q0 K21:-0.125;0.125# BU0;40 D150R250U150L250 BM+200,+70 Q51 K71:0;1* Q0 Q71 Q0 Q71 Q0BM+250,0 Q71 Q0BM+250,+0 Q71 Q0 Q31)"
  37.  
  38. '----------------------------------------------------------------------------------------------------------------------------------------------------
  39. SCREEN _NEWIMAGE(1920, 1080, 256)
  40.  
  41. DrawPlayer clip$, 0, 60, 30, _WIDTH / 1920, 1
  42.  
  43. '----------------------------------------------------------------------------------------------------------------------------------------------------
  44. 'Player demonstration
  45. '----------------------------------------------------------------------------------------------------------------------------------------------------
  46. SUB DrawPlayer (movie$, playfromtime, playtotime, fps, size, speed)
  47.     t = playfromtime * fps
  48.     dir = 1
  49.     DO
  50.         CLS
  51.         _PRINTSTRING (0, 5), "size:" + STR$(RoundDec(size, 2)) + "   speed:" + STR$(dir * speed) + "x  time:" + STR$(RoundDec(t / fps * speed, 2))
  52.         DrawFrame movie$, t / fps * speed, size
  53.         IF k = 32 THEN SLEEP: k = _KEYHIT: k = _KEYHIT
  54.         IF k = 20480 AND speed > 0.1 THEN speed = speed / 2: t = t * 2
  55.         IF k = 18432 AND speed < 100 THEN speed = speed * 2: t = t / 2
  56.         IF k = 19200 THEN t = t - 2 * fps
  57.         IF k = 19712 THEN t = t + 2 * fps
  58.         IF k = 43 THEN size = size + 0.01
  59.         IF k = 45 THEN size = size - 0.01
  60.         IF k = 114 THEN dir = -dir
  61.         t = t + dir
  62.         IF size > 10 THEN size = 10
  63.         IF size < 0.01 THEN size = 0.01
  64.         IF t > playtotime * fps / speed THEN t = playtotime * fps / speed
  65.         IF t < 0 THEN t = 0
  66.         k = _KEYHIT
  67.         _DISPLAY
  68.         _LIMIT fps
  69.     LOOP UNTIL _KEYDOWN(27)
  70.  
  71. '----------------------------------------------------------------------------------------------------------------------------------------------------
  72. 'Sub & Function definitions
  73. '----------------------------------------------------------------------------------------------------------------------------------------------------
  74. SUB DrawFrame (SrcStrOrig AS STRING, frametime AS SINGLE, size AS SINGLE)
  75.  
  76.     CONST CMD_LEN_MAX = 1000 'max. command sequence length definable using statement Q()
  77.  
  78.     TYPE TKFset 'Key frame set type
  79.         id AS INTEGER
  80.         defined AS _BYTE
  81.         timestart AS SINGLE
  82.         timeend AS SINGLE
  83.         repeat AS STRING * 1
  84.         repeatcount AS INTEGER
  85.     END TYPE
  86.  
  87.     TYPE TCmdSeq 'Command Sequence
  88.         id AS INTEGER
  89.         CmdStr AS STRING * CMD_LEN_MAX
  90.         defined AS _BYTE
  91.         startpos AS LONG
  92.         endpos AS LONG
  93.         timestart AS SINGLE
  94.         timeend AS SINGLE
  95.         repeatcount AS INTEGER
  96.     END TYPE
  97.  
  98.     TYPE TDrawState 'global Draw state
  99.         SrcLen AS LONG 'Source string length
  100.         SrcPos AS LONG 'Source string last read char position
  101.         ActKFSetIdx AS INTEGER 'KFset index applied to actual statement if KF enabled
  102.         ActTA AS SINGLE 'Actual parameter value of previous TA statement (in degrees)
  103.         ActS AS SINGLE 'Actual parameter value of previous "S" statement usage
  104.         ErrDsc AS STRING * 50 'Error description
  105.     END TYPE
  106.  
  107.     DIM KFset(0 TO 999) AS TKFset
  108.     DIM CmdSeq(0 TO 99) AS TCmdSeq
  109.     DIM DS AS TDrawState
  110.     DIM char AS STRING * 1
  111.     DIM prevchar AS STRING * 1
  112.     DIM TrgStr AS STRING
  113.     DIM c$, code$, label$, x1$, y1$, x2$, y2$, sgnx1$, sgny1$, rep$, repcnt$, par$, exclfrom$, exclto$, csstart$, percx1$, percx2$
  114.     DIM x AS SINGLE, y AS SINGLE, x1 AS SINGLE, y1 AS SINGLE, x2 AS SINGLE, y2 AS SINGLE, kid AS INTEGER, csid AS INTEGER
  115.     DIM readstate AS _BYTE
  116.     DIM stat$, ParseStatement$ ' Actual statement being read from source draw string
  117.     DIM SrcStr AS STRING
  118.  
  119.     SrcStr = SrcStrOrig
  120.     TrgStr = ""
  121.     stat$ = ""
  122.     prevchar = ""
  123.     SrcStr = SrcStr + "&"
  124.     DS.SrcLen = LEN(SrcStr)
  125.     DS.SrcPos = 0
  126.     DS.ActKFSetIdx = 0
  127.     DS.ActTA = 0
  128.     DS.ActS = 4
  129.  
  130.     DO 'read statement
  131.         DS.SrcPos = DS.SrcPos + 1
  132.         char = MID$(SrcStr, DS.SrcPos, 1)
  133.         IF (ASC(char) >= 64 AND ASC(char) <= 90 AND NOT (char = "A" AND prevchar = "T")) OR char = "&" THEN
  134.             '-------------------------------------------Parser begin-----------------------------------------------------------
  135.             stat$ = stat$ + "&"
  136.             ParseStatement$ = ""
  137.             readstate = 0
  138.             KFenabled = 0
  139.             omitstate = 0
  140.             par$ = "": code$ = "": label$ = "": x1$ = "": y1$ = "": x2$ = "": y2$ = "": sgnx1$ = "": sgny1$ = "": sgnx2$ = ""
  141.             rep$ = "": repcnt$ = "": par$ = "": exclfrom$ = "": exclto$ = "": csstart$ = "": percx1$ = "": percx2$ = "": rel$ = "": krel$ = ""
  142.             x = 0: y = 0: x1 = 0: y1 = 0: x2 = 0: y2 = 0: kid = 0: csid = 0
  143.  
  144.             FOR i = 1 TO LEN(stat$)
  145.                 c$ = MID$(stat$, i, 1)
  146.                 SELECT CASE readstate
  147.                     CASE 0:
  148.                         SELECT CASE c$
  149.                             CASE "A" TO "Z":
  150.                                 code$ = code$ + c$
  151.                             CASE "_":
  152.                                 label$ = par$: par$ = "": rel$ = c$: readstate = 11
  153.                             CASE ":":
  154.                                 label$ = par$: par$ = "": readstate = 1
  155.                             CASE ",":
  156.                                 x1$ = par$: par$ = "": readstate = 2
  157.                             CASE ";":
  158.                                 x1$ = par$: par$ = "": readstate = 3
  159.                                 KFenabled = 1
  160.                             CASE "!":
  161.                                 exclfrom$ = c$
  162.                             CASE "+", "-":
  163.                                 par$ = par$ + c$
  164.                                 sgnx1$ = c$
  165.                             CASE "0" TO "9", ".":
  166.                                 par$ = par$ + c$
  167.                             CASE "%":
  168.                                 percx1$ = percx1$ + c$
  169.                             CASE "*":
  170.                                 label$ = par$: par$ = "": rep$ = c$: readstate = 5
  171.                             CASE "(":
  172.                                 label$ = par$: csstart$ = c$: readstate = 10
  173.                             CASE "&", ")":
  174.                                 x1$ = par$: par$ = "": readstate = 10
  175.                             CASE ELSE: readstate = 99
  176.                         END SELECT
  177.                     CASE 11:
  178.                         SELECT CASE c$
  179.                             CASE "0" TO "9":
  180.                                 par$ = par$ + c$
  181.                             CASE ":":
  182.                                 krel$ = par$: par$ = "": readstate = 1
  183.                             CASE ELSE: readstate = 99
  184.                         END SELECT
  185.                     CASE 1:
  186.                         SELECT CASE c$
  187.                             CASE ",":
  188.                                 x1$ = par$: par$ = "": readstate = 2
  189.                             CASE ";":
  190.                                 x1$ = par$: par$ = "": readstate = 3
  191.                                 KFenabled = 1
  192.                             CASE "!":
  193.                                 exclfrom$ = c$
  194.                             CASE "+", "-":
  195.                                 par$ = par$ + c$
  196.                                 sgnx1$ = c$
  197.                             CASE "0" TO "9", ".":
  198.                                 par$ = par$ + c$
  199.                             CASE "%":
  200.                                 percx1$ = percx1$ + c$
  201.                             CASE "(":
  202.                                 x1$ = par$: csstart$ = c$: readstate = 10
  203.                             CASE "&", ")":
  204.                                 x1$ = par$: par$ = "": readstate = 10
  205.                             CASE ELSE: readstate = 99
  206.                         END SELECT
  207.                     CASE 2:
  208.                         SELECT CASE c$
  209.                             CASE ";":
  210.                                 y1$ = par$: par$ = "": readstate = 3
  211.                                 KFenabled = 1
  212.                             CASE "+", "-":
  213.                                 par$ = par$ + c$
  214.                                 sgny1$ = c$
  215.                             CASE "0" TO "9", ".":
  216.                                 par$ = par$ + c$
  217.                             CASE "&", ")":
  218.                                 y1$ = par$: par$ = "": readstate = 10
  219.                             CASE ELSE: readstate = 99
  220.                         END SELECT
  221.                     CASE 3:
  222.                         SELECT CASE c$
  223.                             CASE ",":
  224.                                 x2$ = par$: par$ = "": readstate = 4
  225.                             CASE "#":
  226.                                 x2$ = par$: par$ = "": rep$ = c$: readstate = 5
  227.                             CASE "*":
  228.                                 x2$ = par$: par$ = "": rep$ = c$: readstate = 5
  229.                             CASE "!":
  230.                                 exclto$ = c$
  231.                             CASE "+", "-":
  232.                                 par$ = par$ + c$
  233.                                 sgnx2$ = c$
  234.                             CASE "0" TO "9", ".":
  235.                                 par$ = par$ + c$
  236.                             CASE "%":
  237.                                 percx2$ = percx2$ + c$
  238.                             CASE "(":
  239.                                 x2$ = par$: csstart$ = c$: readstate = 10
  240.                             CASE "&", ")":
  241.                                 x2$ = par$: par$ = "": readstate = 10
  242.                             CASE ELSE: readstate = 99
  243.                         END SELECT
  244.                     CASE 4:
  245.                         SELECT CASE c$
  246.                             CASE "#":
  247.                                 y2$ = par$: par$ = "": rep$ = c$: readstate = 5
  248.                             CASE "*":
  249.                                 y2$ = par$: par$ = "": rep$ = c$: readstate = 5
  250.                             CASE "0" TO "9", "+", "-", ".":
  251.                                 par$ = par$ + c$
  252.                             CASE "&", ")":
  253.                                 y2$ = par$: par$ = "": readstate = 10
  254.                             CASE ELSE: readstate = 99
  255.                         END SELECT
  256.                     CASE 5:
  257.                         SELECT CASE c$
  258.                             CASE "0" TO "9", "+", "-", ".":
  259.                                 par$ = par$ + c$
  260.                             CASE "(":
  261.                                 repcnt$ = par$: par$ = "": csstart$ = c$: readstate = 10
  262.                             CASE "&", ")":
  263.                                 repcnt$ = par$: par$ = "": readstate = 10
  264.                             CASE ELSE: readstate = 99
  265.                         END SELECT
  266.                 END SELECT
  267.             NEXT i
  268.  
  269.             IF readstate = 99 THEN DS.ErrDsc = "Error in statement: " + LEFT$(stat$, LEN(stat$) - 1) ELSE DS.ErrDsc = ""
  270.             IF code$ = "K" THEN
  271.                 IF x2$ <> "" THEN ' defining KFset
  272.                     tsdelta = 0: tedelta = 0
  273.                     kid = VAL(label$)
  274.                     KFset(kid).id = kid
  275.                     KFset(kid).defined = 1
  276.                     IF krel$ <> "" THEN
  277.                         krel = VAL(krel$)
  278.                         IF sgnx1$ <> "" THEN tsdelta = KFset(krel).timestart
  279.                         IF sgnx2$ <> "" THEN tedelta = KFset(krel).timeend
  280.                     END IF
  281.                     KFset(kid).timestart = VAL(x1$) + tsdelta
  282.                     KFset(kid).timeend = VAL(x2$) + tedelta
  283.                     KFset(kid).repeat = rep$
  284.                     KFset(kid).repeatcount = VAL(repcnt$)
  285.                     DS.ActKFSetIdx = kid
  286.                 ELSE ' referencing KFset
  287.                     IF label$ = "" AND x1$ <> "" THEN label$ = x1$
  288.                     kid = VAL(label$)
  289.                     DS.ActKFSetIdx = kid
  290.                 END IF
  291.  
  292.             ELSEIF code$ = "Q" THEN
  293.                 IF x1$ <> "" OR x2$ <> "" AND label$ <> "" THEN
  294.                     csid = VAL(label$)
  295.                     CmdSeq(csid).timestart = VAL(x1$)
  296.                     CmdSeq(csid).timeend = VAL(x2$)
  297.                 END IF
  298.                 IF label$ = "" AND x1$ <> "" AND x2$ = "" THEN label$ = x1$
  299.                 csid = VAL(label$)
  300.                 CmdSeq(csid).id = csid
  301.                 IF repcnt$ <> "" THEN CmdSeq(csid).repeatcount = VAL(repcnt$)
  302.  
  303.                 ipos = 0
  304.                 IF csstart$ = "(" THEN ' defining command sequence
  305.                     parcnt = 1: c$ = ""
  306.                     DO ' Find corresponding right parenthes in the source string
  307.                         ipos = ipos + 1
  308.                         c$ = MID$(SrcStr$, DS.SrcPos + ipos, 1)
  309.                         IF c$ = "(" THEN parcnt = parcnt + 1
  310.                         IF c$ = ")" THEN parcnt = parcnt - 1
  311.                     LOOP UNTIL (c$ = ")" AND parcnt = 0) OR DS.SrcPos + ipos >= DS.SrcLen OR ipos >= CMD_LEN_MAX
  312.                     IF (c$ = ")" AND parcnt = 0) THEN
  313.                         CmdSeq(csid).CmdStr = MID$(SrcStr, DS.SrcPos, ipos)
  314.                         CmdSeq(csid).defined = 1
  315.                     ELSE
  316.                         CmdSeq(csid).defined = 0
  317.                     END IF
  318.                 ELSE 'Referencing command sequence
  319.                 END IF
  320.  
  321.                 IF CmdSeq(csid).defined = 1 THEN 'modify source string if command sequence defined
  322.                     IF CmdSeq(csid).repeatcount > 0 THEN
  323.                         rpt = CmdSeq(csid).repeatcount
  324.                     ELSEIF rep$ = "*" THEN
  325.                         rpt = 0
  326.                     ELSE
  327.                         rpt = 1
  328.                     END IF
  329.                     IF CmdSeq(csid).timeend <> 0 AND (frametime < CmdSeq(csid).timestart OR frametime > CmdSeq(csid).timeend) THEN rpt = 0
  330.                     IF frametime < CmdSeq(csid).timestart THEN rpt = 0
  331.                     cmdrpt$ = ""
  332.                     FOR i = 1 TO rpt: cmdrpt$ = cmdrpt$ + RTRIM$(CmdSeq(csid).CmdStr): NEXT i
  333.                     SrcStr = RTRIM$(cmdrpt$) + RIGHT$(SrcStr, DS.SrcLen - DS.SrcPos - ipos + 1)
  334.                     DS.SrcLen = LEN(SrcStr)
  335.                     DS.SrcPos = 0
  336.                     char = ""
  337.                 END IF
  338.  
  339.             ELSE 'do for other graphics statements
  340.                 x1 = VAL(x1$): y1 = VAL(y1$): x2 = VAL(x2$): y2 = VAL(y2$)
  341.                 kid = DS.ActKFSetIdx
  342.                 IF KFenabled = 1 AND KFset(kid).defined = 1 THEN 'change parameters if statement is keyframed
  343.                     fk = (frametime - KFset(kid).timestart) / (KFset(kid).timeend - KFset(kid).timestart)
  344.                     IF (frametime >= KFset(kid).timestart AND frametime <= KFset(kid).timeend) THEN
  345.                         IF x1$ <> "" THEN x1 = x1 + (x2 - x1) * fk
  346.                         IF y1$ <> "" THEN y1 = y1 + (y2 - y1) * fk
  347.                     ELSEIF (frametime > KFset(kid).timeend AND exclto$ <> "!") THEN
  348.                         period = INT((frametime - KFset(kid).timestart) / (KFset(kid).timeend - KFset(kid).timestart))
  349.                         IF (KFset(kid).repeat = "*" OR KFset(kid).repeat = "#") AND (period < KFset(kid).repeatcount OR KFset(kid).repeatcount = 0) THEN
  350.                             IF KFset(kid).repeat = "#" AND period MOD 2 = 1 THEN
  351.                                 fk = (KFset(kid).timeend - frametime + period * (KFset(kid).timeend - KFset(kid).timestart)) / (KFset(kid).timeend - KFset(kid).timestart)
  352.                             ELSE
  353.                                 fk = (frametime - KFset(kid).timestart - period * (KFset(kid).timeend - KFset(kid).timestart)) / (KFset(kid).timeend - KFset(kid).timestart)
  354.                             END IF
  355.                             IF x1$ <> "" THEN x1 = x1 + (x2 - x1) * fk
  356.                             IF y1$ <> "" THEN y1 = y1 + (y2 - y1) * fk
  357.                         ELSE
  358.                             IF KFset(kid).repeat = "#" AND KFset(kid).repeatcount MOD 2 = 0 THEN
  359.                                 IF x1$ <> "" THEN x1 = x1
  360.                                 IF y1$ <> "" THEN y1 = y1
  361.                             ELSE
  362.                                 IF x1$ <> "" THEN x1 = x2
  363.                                 IF y1$ <> "" THEN y1 = y2
  364.                             END IF
  365.                         END IF
  366.                     ELSEIF (frametime < KFset(kid).timestart AND exclfrom$ <> "!") THEN
  367.                         omitstate = 0
  368.                     ELSE
  369.                         omitstate = 1
  370.                     END IF
  371.                 END IF
  372.                 IF omitstate = 0 THEN
  373.                     SELECT CASE code$
  374.                         CASE "T", "TA":
  375.                             x1 = RoundDec(x1, 6)
  376.                             DS.ActTA = x1
  377.                             IF (DS.ActTA > 360) OR (DS.ActTA < -360) THEN DS.ActTA = DS.ActTA + (DS.ActTA > 0) * 360
  378.                         CASE "V":
  379.                             DS.ActTA = DS.ActTA + RoundDec(x1, 6)
  380.                             IF (DS.ActTA > 360) OR (DS.ActTA < -360) THEN DS.ActTA = DS.ActTA + (DS.ActTA > 0) * 360
  381.                             code$ = "TA"
  382.                             x1 = RoundDec(DS.ActTA, 6)
  383.                         CASE "C":
  384.                             x1 = _ROUND(x1)
  385.                         CASE "M", "D", "E", "F", "G", "H", "L", "R", "U":
  386.                             x1 = RoundDec(x1 * size, 4)
  387.                             y1 = RoundDec(y1 * size, 4)
  388.                         CASE "S":
  389.                             IF percx1$ <> "" OR percx2$ <> "" THEN
  390.                                 x1 = RoundDec(x1 * DS.ActS / 100, 5)
  391.                                 IF x1 > 8 THEN x1 = 8
  392.                             ELSE
  393.                                 DS.ActS = x1
  394.                             END IF
  395.                     END SELECT
  396.                     IF sgnx1$ <> "" AND x1 < 0 THEN sgnx1$ = ""
  397.                     IF sgnx1$ <> "" AND x1 > 0 THEN sgnx1$ = "+"
  398.                     IF sgny1$ <> "" AND y1 < 0 THEN sgny1$ = ""
  399.                     IF sgny1$ <> "" AND y1 > 0 THEN sgny1$ = "+"
  400.                     ParseStatement$ = code$
  401.                     IF x1$ <> "" THEN
  402.                         ParseStatement$ = ParseStatement$ + sgnx1$ + LTRIM$(STR$(x1))
  403.                         IF y1$ <> "" THEN ParseStatement$ = ParseStatement$ + "," + sgny1$ + LTRIM$(STR$(y1))
  404.                     END IF
  405.                 ELSE
  406.                     ParseStatement$ = ""
  407.                 END IF
  408.             END IF
  409.  
  410.             ''---DEBUG BEGIN-----------
  411.             'IF CmdSeq(csid).defined = 1 THEN cmd$ = RTRIM$(CmdSeq(csid).CmdStr) ELSE cmd$ = ""
  412.             'PRINT
  413.             'PRINT stat$ + " > ", , code$ + "/" + label$ + "/" + x1$ + "/" + y1$ + "/" + x2$ + "/" + y2$ + "/" + exclfrom$ + "/" + exclto$ + "/" + rep$ + "/" + repcnt$
  414.             'PRINT "TrgStr: "; TrgStr
  415.             'PRINT "SrcStr: "; SrcStr
  416.             'PRINT "cmd$: ", cmd$
  417.             'PRINT "DS.Srcpos", DS.SrcPos
  418.             'PRINT "ParseStatement$: ", ParseStatement$
  419.             'IF stat$ = "Q1*(&" OR stat$ = "Q1(&" THEN stopable = 1
  420.             'IF stopable THEN
  421.             '    DO
  422.             '    LOOP UNTIL _KEYHIT = 32
  423.             'END IF
  424.             ''---DEBUG END-------------
  425.  
  426.             '-------------------------------------------Parser end-----------------------------------------------------------
  427.             TrgStr = TrgStr + ParseStatement$
  428.             IF LTRIM$(DS.ErrDsc) <> "" THEN PRINT RTRIM$(DS.ErrDsc) + " at position:" + STR$(DS.SrcPos - LEN(stat$))
  429.             stat$ = ""
  430.         END IF
  431.         IF char <> " " THEN
  432.             stat$ = stat$ + char
  433.         END IF
  434.         prevchar = char
  435.     LOOP WHILE DS.SrcPos < DS.SrcLen
  436.  
  437.     DRAW TrgStr
  438.  
  439.     'PRINT SrcStr '---DEBUG code----
  440.     'PRINT TrgStr '---DEBUG code----
  441.  
  442. '----------------------------------------------------------------------------------------------------------------------------------------------------
  443. FUNCTION RoundDec (x AS SINGLE, n AS INTEGER)
  444.     RoundDec = _ROUND(x * 10 ^ n) / (10 ^ n)
  445.  
  446. '----------------------------------------------------------------------------------------------------------------------------------------------------
  447.  
« Last Edit: January 21, 2020, 08:40:19 am by dajan »